mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-15 01:21:48 +03:00
d9a72b368a
Issue: https://github.com/StanGirard/quivr/issues/1683 Demo: https://github.com/StanGirard/quivr/assets/63923024/67cf2a0f-4cfe-420c-9181-baffaa584c78 https://github.com/StanGirard/quivr/assets/63923024/eee57598-1520-4c11-bd64-887869878f46
31 lines
920 B
Python
31 lines
920 B
Python
from uuid import UUID
|
|
|
|
from fastapi import HTTPException
|
|
from models.settings import get_supabase_db
|
|
|
|
from repository.api_brain_definition.get_api_brain_definition import (
|
|
get_api_brain_definition,
|
|
)
|
|
from repository.external_api_secret import delete_secret
|
|
|
|
|
|
def delete_brain_secrets_values(brain_id: UUID) -> None:
|
|
supabase_db = get_supabase_db()
|
|
|
|
brain_definition = get_api_brain_definition(brain_id=brain_id)
|
|
|
|
if brain_definition is None:
|
|
raise HTTPException(status_code=404, detail="Brain definition not found.")
|
|
|
|
secrets = brain_definition.secrets
|
|
|
|
if len(secrets) > 0:
|
|
brain_users = supabase_db.get_brain_users(brain_id=brain_id)
|
|
for user in brain_users:
|
|
for secret in secrets:
|
|
delete_secret(
|
|
user_id=user.user_id,
|
|
brain_id=brain_id,
|
|
secret_name=secret.name,
|
|
)
|