mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-14 17:03:29 +03:00
fix: add user id while creating default brain (#1616)
This commit is contained in:
parent
5dc4f15a6c
commit
f24779ff14
@ -1,17 +1,18 @@
|
|||||||
from models import BrainEntity, UserIdentity
|
from models import BrainEntity, UserIdentity
|
||||||
from models.databases.supabase.brains import CreateBrainProperties
|
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 import create_brain, create_brain_user, get_user_default_brain
|
||||||
from repository.brain.create_brain import create_brain
|
from repository.brain.create_brain import create_brain
|
||||||
from repository.brain.create_brain_user import create_brain_user
|
from repository.brain.create_brain_user import create_brain_user
|
||||||
from repository.brain.get_default_user_brain import get_user_default_brain
|
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:
|
def get_default_user_brain_or_create_new(user: UserIdentity) -> BrainEntity:
|
||||||
default_brain = get_user_default_brain(user.id)
|
default_brain = get_user_default_brain(user.id)
|
||||||
|
|
||||||
if not default_brain:
|
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)
|
create_brain_user(user.id, default_brain.brain_id, RoleEnum.Owner, True)
|
||||||
|
|
||||||
return default_brain
|
return default_brain
|
||||||
|
Loading…
Reference in New Issue
Block a user