Skip to content

Notifications: exclude system users (TM, sync, GT) from recipients#4174

Open
ayshushus wants to merge 2 commits into
mozilla:mainfrom
ayshushus:3954
Open

Notifications: exclude system users (TM, sync, GT) from recipients#4174
ayshushus wants to merge 2 commits into
mozilla:mainfrom
ayshushus:3954

Conversation

@ayshushus
Copy link
Copy Markdown
Collaborator

@ayshushus ayshushus commented May 25, 2026

Fix #3954

System users (pontoon-sync, pontoon-gt, pontoon-tm) have translation/review activity attributed. Have UserProfile.system_user=True but no callsite check.

  • Add profile__system_user=False filter to every notify.send() recipient queryset:
    • sync.core.notify_users (new strings)
    • messaging.management.commands.send_deadline_notifications
    • messaging.management.commands.send_review_notifications (filter on user__profile__system_user)
    • messaging.management.commands.send_suggestion_notifications
    • translations.views.create_translation (new-contributor notification to locale managers)
    • base.views._send_add_comment_notifications and _send_pin_comment_notifications
  • Early-return in messaging.notifications.send_badge_notification when user.profile.system_user.
  • Filter messaging.views.get_recipients return queryset.

Add tests (@functionzz) in pontoon/messaging/tests/test_send_notifications.py covering all four commands, badge notification; new pontoon/sync/tests/test_notify_users.py covering sync.core.notify_users.

@ayshushus ayshushus self-assigned this May 25, 2026
@ayshushus ayshushus requested a review from functionzz May 25, 2026 19:47
@ayshushus ayshushus marked this pull request as ready for review May 25, 2026 19:49
Copy link
Copy Markdown
Collaborator

@flodolo flodolo left a comment

Choose a reason for hiding this comment

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

Passing by thought, since I'm touching some of this code for another issue.

Instead of spreading the filter, have you considered using a helper function in pontoon/messaging/notifications.py to filter+send? e.g. something like

def send_notification(sender, recipient, **kwargs):
    if recipient.profile.system_user:
        return
    notify.send(sender, recipient=recipient, **kwargs)

I think we're filtering out system users before sending notifications in 4/5 places, and I don't see a scenario where we want to notify system users.

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.

Ignore "system" users (TM, sync, GT) in notifications

2 participants