-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: activate public brain subscription #1241
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Risk Level 2 - /home/runner/work/quivr/quivr/frontend/lib/api/subscription/subscription.ts The code changes seem to be well-structured and follow the SOLID principles. However, there is a TODO comment about renaming 'rights' to 'role' in the Backend and using 'InvitationBrain' instead of 'BackendInvitationBrain'. This indicates that there might be some confusion or inconsistency in the naming conventions used in the code. It's recommended to address this TODO comment to improve the readability and maintainability of the code. Risk Level 2 - /home/runner/work/quivr/quivr/frontend/app/brains-management/[brainId]/components/BrainManagementTabs/BrainManagementTabs.tsx The code seems to be well written and follows good practices. However, there are a few areas that could be improved for better readability and maintainability:
Example: const isPublicBrain = useMemo(() => brain?.status === \"public\", [brain]);
const hasEditRights = useMemo(() => !isPublicBrain || isCurrentUserBrainOwner, [isPublicBrain, isCurrentUserBrainOwner]); Risk Level 3 - /home/runner/work/quivr/quivr/backend/routes/subscription_routes.py The code changes are generally good, but there are a few areas that could be improved for better readability and maintainability.
def validate_owner_rights(brain_id: UUID, current_user: UserIdentity, rights: str):
if rights == \"Owner\":
try:
validate_brain_authorization(brain_id, current_user.id, RoleEnum.Owner)
except HTTPException:
raise HTTPException(status_code=403, detail=\"You don't have the rights to give owner permissions\") Then in validate_owner_rights(brain_id, current_user, subscription.rights)
def check_brain_exists(brain_id: UUID):
brain = get_brain_by_id(brain_id)
if brain is None:
raise HTTPException(status_code=404, detail=\"Brain not found\")
def check_brain_public(brain_id: UUID):
brain = get_brain_by_id(brain_id)
if brain.status != \"public\":
raise HTTPException(status_code=403, detail=\"You cannot subscribe to this brain without invitation\")
def check_already_subscribed(brain_id: UUID, current_user: UserIdentity):
user_brain = get_brain_for_user(current_user.id, brain_id)
if user_brain is not None:
raise HTTPException(status_code=403, detail=\"You are already subscribed to this brain\") Then in check_brain_exists(brain_id)
check_brain_public(brain_id)
check_already_subscribed(brain_id, current_user) 📚🔍🔄 Powered by Code Review GPT |
8e477cc
to
02cc8d9
Compare
02cc8d9
to
da0caa6
Compare
/Post subscribe
endpoint to subscribe to a public brainScreen.Recording.2023-09-21.at.18.04.53.mp4
#1210