diff --git a/privatemsg.module b/privatemsg.module index 2a54f65..a4e37f3 100644 --- a/privatemsg.module +++ b/privatemsg.module @@ -2484,6 +2484,7 @@ function privatemsg_recipient_get_type($type) { * If TRUE, adds the recipient, if FALSE, removes it. */ function privatemsg_message_change_recipient($mid, $uid, $type = 'user', $add = TRUE) { + $author_added = &drupal_static(__FUNCTION__, array()); // The message is statically cached, so only a single load is necessary. $message = privatemsg_message_load($mid); $thread_id = $message->thread_id; @@ -2517,6 +2518,17 @@ function privatemsg_message_change_recipient($mid, $uid, $type = 'user', $add = 'deleted' => 0, )) ->execute(); + module_invoke_all('privatemsg_message_recipient_changed', $mid, $thread_id, $uid, $type, $add); + } + else if ($uid == $message->author->uid) { + // Special handling for author, author already exists in pm_index, we still need to send notification once. + if (!isset($author_added[$mid])) { + $author_added[$mid] = FALSE; + } + if (!$author_added[$mid]) { + $author_added[$mid] = TRUE; + module_invoke_all('privatemsg_message_recipient_changed', $mid, $thread_id, $uid, $type, $add); + } } } else { @@ -2525,8 +2537,8 @@ function privatemsg_message_change_recipient($mid, $uid, $type = 'user', $add = ->condition('recipient', $uid) ->condition('type', $type) ->execute(); + module_invoke_all('privatemsg_message_recipient_changed', $mid, $thread_id, $uid, $type, $add); } - module_invoke_all('privatemsg_message_recipient_changed', $mid, $thread_id, $uid, $type, $add); } /**