Skip to content
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

fix: notification count #6109

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions apiserver/plane/app/views/notification/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ def list(self, request, slug):
Notification.objects.filter(
workspace__slug=slug, receiver_id=request.user.id
)
.filter(
project__project_projectmember__member=request.user,
project__project_projectmember__is_active=True,
)
.filter(entity_name="issue")
.annotate(is_inbox_issue=Exists(intake_issue))
.annotate(is_intake_issue=Exists(intake_issue))
Expand Down
9 changes: 8 additions & 1 deletion apiserver/plane/bgtasks/notification_task.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Python imports
import json
import uuid
from uuid import UUID


# Module imports
from plane.db.models import (
Expand Down Expand Up @@ -255,7 +257,7 @@ def notifications(
)

new_mentions = [
str(mention) for mention in new_mentions if mention in new_mentions
str(mention) for mention in new_mentions if mention in set(project_members)
]
removed_mention = get_removed_mentions(
requested_instance=requested_data, current_instance=current_instance
Expand Down Expand Up @@ -287,6 +289,11 @@ def notifications(
new_value=issue_comment_new_value,
)
comment_mentions = comment_mentions + new_comment_mentions
comment_mentions = [
mention
for mention in comment_mentions
if UUID(mention) in set(project_members)
]
Comment on lines +292 to +296
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add error handling for UUID conversion

The UUID conversion could raise a ValueError for invalid UUIDs. Consider adding error handling to gracefully skip invalid mentions.

                    comment_mentions = [
                        mention
                        for mention in comment_mentions
-                        if UUID(mention) in set(project_members)
+                        if _is_valid_uuid_member(mention, project_members)
                    ]

+def _is_valid_uuid_member(mention, project_members):
+    try:
+        return UUID(mention) in set(project_members)
+    except ValueError:
+        return False
📝 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
comment_mentions = [
mention
for mention in comment_mentions
if UUID(mention) in set(project_members)
]
comment_mentions = [
mention
for mention in comment_mentions
if _is_valid_uuid_member(mention, project_members)
]
def _is_valid_uuid_member(mention, project_members):
try:
return UUID(mention) in set(project_members)
except ValueError:
return False


comment_mention_subscribers = extract_mentions_as_subscribers(
project_id=project_id, issue_id=issue_id, mentions=all_comment_mentions
Expand Down
Loading