fix(notifications): deliver @mention notifications and match full usernames#15196
Merged
Conversation
Maffooch
requested changes
Jul 9, 2026
Maffooch
left a comment
Contributor
There was a problem hiding this comment.
Can you please add some regression tests for this to lock in behavior
valentijnscholten
left a comment
Member
There was a problem hiding this comment.
Does this superseed #14927?
Contributor
Author
@valentijnscholten Yes, this supersedes #14927. Both fix the same root cause (#14923): On top of that delivery fix, this PR also broadens the mention regex from |
Jino-T
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Notifying a user with
@usernamein a note has two bugs inprocess_tag_notifications(dojo/notifications/helper.py):Notifications were never delivered. The function collects
Dojo_Userobjects and passes them as
recipientstocreate_notification. ButNotificationManager._process_recipientsresolves recipients withNotifications.objects.filter(user__username__in=recipients).usernameis a
CharField, so eachDojo_Useris coerced tostr(user)="First Last (username)", which never equals a stored username — zerorecipients match, and no alert/email/Slack message is sent. This fix passes
user.usernamestrings, which is what the parameter expects (see theexisting
recipients=["admin"]cases inunittests/test_notifications.py).Usernames with
. - @ +couldn't be fully mentioned. Django'susername validators allow those characters, but the mention regex only
captured
\w+, so@jane.doeresolved tojane. The capture is broadenedto
[\w.@+-]+; the leading(?:\A|\s)@anchor still prevents emailaddresses written in prose (e.g.
contact a@b.com) from triggering amention, and a trailing sentence period is stripped so
thanks @jane.still resolves to
jane.Behavior change
@mentionnotifications now actually reach the mentioned user (previously asilent no-op).
@jane.doe-style (and SSO/email-style) usernames now resolve to the fullusername instead of a truncated prefix — which also avoids accidentally
notifying a different user who happens to own that prefix.
Testing
unittests/test_notifications.pypasses (itsuser_mentionedcases alreadyuse
recipients=["admin"], matching the corrected caller).@<active-user>creates analert for that user (previously none was created).