-
-
Notifications
You must be signed in to change notification settings - Fork 1k
NoMongo (fix): allow all organization admins to block users #3459
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
NoMongo (fix): allow all organization admins to block users #3459
Conversation
""" WalkthroughThe changes refactor the data fetching and authorization logic in the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant GraphQLServer
participant DB
Client->>GraphQLServer: blockUser/unblockUser Mutation
GraphQLServer->>DB: Fetch current user, org, and user-org membership
DB-->>GraphQLServer: Return user, org, membership
GraphQLServer->>GraphQLServer: Check admin role (global/org)
alt Not authorized
GraphQLServer-->>Client: Return unauthorized error
else Authorized
GraphQLServer->>DB: Fetch target user and block record
DB-->>GraphQLServer: Return target user, block
GraphQLServer->>GraphQLServer: Validate target user and block existence
alt Valid
GraphQLServer->>DB: Perform block/unblock transaction
DB-->>GraphQLServer: Return updated block state
GraphQLServer-->>Client: Return result
else Invalid
GraphQLServer-->>Client: Return validation error
end
end
Assessment against linked issues
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (3)
🧰 Additional context used🧬 Code Graph Analysis (2)src/utilities/authorization.ts (1)
src/graphql/types/Mutation/blockUser.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms (2)
🔇 Additional comments (10)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop-postgres #3459 +/- ##
====================================================
+ Coverage 59.60% 59.63% +0.03%
====================================================
Files 523 524 +1
Lines 40782 40817 +35
Branches 1786 1787 +1
====================================================
+ Hits 24307 24343 +36
Misses 16464 16464
+ Partials 11 10 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
src/graphql/types/Mutation/blockUser.ts
(1 hunks)src/graphql/types/Mutation/unblockUser.ts
(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/graphql/types/Mutation/unblockUser.ts (1)
src/utilities/TalawaGraphQLError.ts (1)
TalawaGraphQLError
(264-277)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Check App Startup and Health
- GitHub Check: Test Deployment to https://docs-api.talawa.io
Please fix the failing test. |
Sure sir. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The coderabbitai suggestion looks valid. Unresolve and Incorporate them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
src/utilities/authorization.ts
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/utilities/authorization.ts (1)
src/utilities/TalawaGraphQLError.ts (1)
TalawaGraphQLError
(264-277)
🪛 GitHub Actions: Pull request workflow
src/utilities/authorization.ts
[error] 2-24: Prettier formatting check failed. Run 'prettier --write' to fix code style issues in this file.
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Analyse Code With CodeQL (typescript)
🔇 Additional comments (1)
src/utilities/authorization.ts (1)
1-23
: Well-designed authorization utility function.The new
assertOrganizationAdmin
utility function effectively centralizes authorization checks for administrative privileges, which follows the DRY principle and improves code maintainability. The function properly checks both global admin rights and organization-specific admin rights, which aligns with the PR objective to allow all organization admins to block users.
5937880
into
PalisadoesFoundation:develop-postgres
What kind of change does this PR introduce?
Issue Number:
Fixes #3329
Snapshots/Videos:
If relevant, did you update the documentation?
Summary
Does this PR introduce a breaking change?
Checklist
CodeRabbit AI Review
Test Coverage
Other information
Have you read the contributing guide?
Summary by CodeRabbit