Skip to content

Commit

Permalink
fix: Add integration brain to subscription route (#2410)
Browse files Browse the repository at this point in the history
# Description

Please include a summary of the changes and the related issue. Please
also include relevant motivation and context.

## Checklist before requesting a review

Please delete options that are not relevant.

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented hard-to-understand areas
- [ ] I have ideally added tests that prove my fix is effective or that
my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged

## Screenshots (if appropriate):
  • Loading branch information
StanGirard authored Apr 7, 2024
1 parent 68db4e0 commit 6acf5fc
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions backend/routes/subscription_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@
SubscriptionInvitationService,
resend_invitation_email,
)
from modules.brain.repository import (
IntegrationBrain,
)
from routes.headers.get_origin_header import get_origin_header
from logger import get_logger

logger = get_logger(__name__)

subscription_router = APIRouter()
subscription_service = SubscriptionInvitationService()
Expand All @@ -30,6 +36,7 @@
brain_user_service = BrainUserService()
brain_service = BrainService()
api_brain_definition_service = ApiBrainDefinitionService()
integration_brains_repository = IntegrationBrain()


@subscription_router.post(
Expand Down Expand Up @@ -249,7 +256,18 @@ async def accept_invitation(
rights=invitation["rights"],
is_default_brain=False,
)
shared_brain = brain_service.get_brain_by_id(brain_id)
integration_brain = integration_brains_repository.get_integration_brain(
brain_id=brain_id,
)
integration_brains_repository.add_integration_brain(
brain_id=brain_id,
user_id=current_user.id,
integration_id=integration_brain.integration_id,
settings=integration_brain.settings,
)
except Exception as e:
logger.error(f"Error adding user to brain: {e}")
raise HTTPException(status_code=400, detail=f"Error adding user to brain: {e}")

try:
Expand Down

0 comments on commit 6acf5fc

Please sign in to comment.