fix: add user id while creating default brain (#1616)

This commit is contained in:
Mamadou DICKO 2023-11-13 12:16:38 +01:00 committed by GitHub
parent 5dc4f15a6c
commit f24779ff14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,17 +1,18 @@
from models import BrainEntity, UserIdentity
from models.databases.supabase.brains import CreateBrainProperties
from routes.authorizations.types import RoleEnum
from repository.brain import create_brain, create_brain_user, get_user_default_brain
from repository.brain.create_brain import create_brain
from repository.brain.create_brain_user import create_brain_user
from repository.brain.get_default_user_brain import get_user_default_brain
from routes.authorizations.types import RoleEnum
def get_default_user_brain_or_create_new(user: UserIdentity) -> BrainEntity:
default_brain = get_user_default_brain(user.id)
if not default_brain:
default_brain = create_brain(CreateBrainProperties())
default_brain = create_brain(brain=CreateBrainProperties(), user_id=user.id)
create_brain_user(user.id, default_brain.brain_id, RoleEnum.Owner, True)
return default_brain