Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently on the last line of privatemsg_message_change_recipient, hook_privatemsg_message_recipient_changed is invoked, this happens even if the recipient we're adding already exists, I don't think this is correct. This is causing multiple email notifications to be sent to the same user, if this user belongs to multiple non-user recipients (for example, roles).
Comment | File | Size | Author |
---|---|---|---|
#3 | privatemsg-1529498-3.patch | 1.6 KB | jrao |
#1 | privatemsg-1529498.patch | 1.66 KB | jrao |
Comments
Comment #1
jrao CreditAttribution: jrao commentedSurprisingly hard to get this right, and the tests took forever to run. Let's see if this patch works.
Comment #2
BerdirShould use two spaces instead of tabs.
Took me a while to understand that the first if is just setting the default value. Shouldn't it be possible to change that to a empty($author_added[$mid]), which would make the first condition unessary?
I have to say that I'm not sure if I do understand why this is necessary. Why exactly do we need to send the author a notification? There's always the possibility that there is a bug in the tests :)
Comment #3
jrao CreditAttribution: jrao commentedTab issue and empty($author_added[$mid]) issue fixed.
For why we need to send author a notification, the reason is privatemsg_message_change_recipient is called when we need to add user as message recipient when handling non-user recipients, so if privatemsg_message_change_recipient is adding author, this means one or more non-user recipient included the author, I think in this case sending notification to author is the right thing to do. The test case for this is in pm_email_notify.test, search for "Send a message to all users"
Comment #4
ptmkenny CreditAttribution: ptmkenny commented#3: privatemsg-1529498-3.patch queued for re-testing.
Comment #5
ivnish CreditAttribution: ivnish commented