Skip to content

Conversation

@ussaama
Copy link
Contributor

@ussaama ussaama commented Jul 15, 2025

Summary by CodeRabbit

  • New Features
    • Added a new indicator showing whether project notification subscription is allowed for each project.

@ussaama ussaama requested a review from spashii July 15, 2025 11:29
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 15, 2025

Walkthrough

A boolean field named is_project_notification_subscription_allowed was introduced to the PublicProjectSchema Pydantic model, enabling explicit representation of whether project notification subscriptions are permitted for each project. No additional logic or endpoints were changed.

Changes

File(s) Change Summary
echo/server/dembrane/api/participant.py Added is_project_notification_subscription_allowed to PublicProjectSchema

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API
    participant PublicProjectSchema

    Client ->> API: Request project data
    API ->> PublicProjectSchema: Populate fields (including is_project_notification_subscription_allowed)
    PublicProjectSchema -->> API: Return project data with new field
    API -->> Client: Respond with project data (now includes is_project_notification_subscription_allowed)
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ussaama ussaama enabled auto-merge July 15, 2025 11:29
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cb2c249 and 3184b0d.

📒 Files selected for processing (1)
  • echo/server/dembrane/api/participant.py (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: ussaama
PR: Dembrane/echo#205
File: echo/frontend/src/lib/query.ts:1444-1506
Timestamp: 2025-07-10T12:48:20.663Z
Learning: ussaama prefers string concatenation over template literals for simple cases where readability is clearer, even when linting tools suggest template literals. Human readability takes precedence over strict linting rules in straightforward concatenation scenarios.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: ci-check-server


is_conversation_allowed: bool
is_get_reply_enabled: bool
is_project_notification_subscription_allowed: bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

LGTM - clean addition, but needs authorization integration!

The new field follows proper naming conventions and is positioned logically with other permission fields. However, the notification subscription endpoints (lines 261-322) don't currently check this permission field.

Consider adding authorization checks to the notification endpoints:

@ParticipantRouter.post("/report/subscribe")
async def subscribe_notifications(data: NotificationSubscriptionRequest) -> dict:
+    # Check if project allows notification subscriptions
+    try:
+        project = project_service.get_by_id_or_raise(data.project_id)
+        if not project.get("is_project_notification_subscription_allowed", False):
+            raise HTTPException(status_code=403, detail="Project notification subscription not allowed")
+    except ProjectNotFoundException as e:
+        raise HTTPException(status_code=404, detail="Project not found") from e
+
    """
    Subscribe multiple users to project notifications.

Also verify that the service layer populates this field correctly.


🏁 Script executed:

#!/bin/bash
# Check if the service layer populates the new field
rg -A 5 -B 5 "is_project_notification_subscription_allowed" --type py

Length of output: 907


Ensure Notification Subscription Authorization is Enforced

The new is_project_notification_subscription_allowed: bool field is added to the public project schema but isn’t used in any of the notification subscription endpoints (participant.py around lines 261–322). We need to:

• Enforce this permission in both the /report/subscribe and /report/unsubscribe endpoints by:
– Loading the project (e.g. via project_service.get_by_id_or_raise)
– Checking project.is_project_notification_subscription_allowed
– Throwing HTTPException(status_code=403, ...) if the flag is false
• Update the service layer (where projects are fetched) so that the is_project_notification_subscription_allowed field is populated on each project returned.

Suggested diff for the subscribe endpoint:

@ParticipantRouter.post("/report/subscribe")
async def subscribe_notifications(data: NotificationSubscriptionRequest) -> dict:
+    # Enforce project-level notification subscription permission
+    try:
+        project = project_service.get_by_id_or_raise(data.project_id)
+    except ProjectNotFoundException as e:
+        raise HTTPException(status_code=404, detail="Project not found") from e
+
+    if not project.get("is_project_notification_subscription_allowed", False):
+        raise HTTPException(
+            status_code=403,
+            detail="Project notification subscription is not allowed"
+        )
     """
     Subscribe multiple users to project notifications.
     …

Repeat similar logic in the unsubscribe endpoint. Finally, verify in the service implementation that is_project_notification_subscription_allowed is included in the project payload returned to the API layer.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
is_project_notification_subscription_allowed: bool
@ParticipantRouter.post("/report/subscribe")
async def subscribe_notifications(data: NotificationSubscriptionRequest) -> dict:
# Enforce project-level notification subscription permission
try:
project = project_service.get_by_id_or_raise(data.project_id)
except ProjectNotFoundException as e:
raise HTTPException(status_code=404, detail="Project not found") from e
if not project.get("is_project_notification_subscription_allowed", False):
raise HTTPException(
status_code=403,
detail="Project notification subscription is not allowed"
)
"""
Subscribe multiple users to project notifications.
🤖 Prompt for AI Agents
In echo/server/dembrane/api/participant.py around lines 261 to 322, the new
field is_project_notification_subscription_allowed is added to the project
schema but not enforced in the /report/subscribe and /report/unsubscribe
endpoints. Fix this by loading the project using
project_service.get_by_id_or_raise in both endpoints, checking the project's
is_project_notification_subscription_allowed flag, and raising an HTTPException
with status 403 if the flag is false. Also, update the service layer to ensure
this field is populated on each project returned to the API layer.

@ussaama ussaama added this pull request to the merge queue Jul 15, 2025
Merged via the queue into main with commit bed9da1 Jul 15, 2025
12 checks passed
@ussaama ussaama deleted the report-notification-subscription-public-permission-fix branch July 15, 2025 11:36
spashii pushed a commit that referenced this pull request Nov 18, 2025
Add is_project_notification_subscription_allowed field to PublicProjectSchema in participant.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants