From 1381a0729e91440bfc63172e7e21b86019c72593 Mon Sep 17 00:00:00 2001 From: Antoine Dewez <44063631+Zewed@users.noreply.github.com> Date: Thu, 21 Mar 2024 11:51:10 -0700 Subject: [PATCH] fix(frontend & backend): unsubscribe from brain (#2373) # 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): --- backend/routes/subscription_routes.py | 6 +----- frontend/app/studio/[brainId]/page.tsx | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/backend/routes/subscription_routes.py b/backend/routes/subscription_routes.py index 6c2725db9..785226e43 100644 --- a/backend/routes/subscription_routes.py +++ b/backend/routes/subscription_routes.py @@ -458,11 +458,7 @@ async def unsubscribe_from_brain_handler( if brain is None: raise HTTPException(status_code=404, detail="Brain not found") - if brain.status != "public": - raise HTTPException( - status_code=403, - detail="You cannot subscribe to this brain without invitation", - ) + # check if user is already subscribed to brain user_brain = brain_user_service.get_brain_for_user(current_user.id, brain_id) if user_brain is None: diff --git a/frontend/app/studio/[brainId]/page.tsx b/frontend/app/studio/[brainId]/page.tsx index d27ac44d8..edaf0cbb0 100644 --- a/frontend/app/studio/[brainId]/page.tsx +++ b/frontend/app/studio/[brainId]/page.tsx @@ -42,7 +42,7 @@ const BrainsManagement = (): JSX.Element => { hidden: !isOwnedByCurrentUser || !brain?.max_files, }, { - label: "Delete brain", + label: isOwnedByCurrentUser ? "Delete Brain" : "Unsubscribe from Brain", color: "dangerous", onClick: () => { setIsDeleteOrUnsubscribeModalOpened(true);