In implementing some custom ignoring and blocking logic, I stumbled into what appears to be an oversight.

In privatemsg.module in the privatemsg_message_change_recipient() function, no context is passed for replies when 'hook_privatemsg_block_message' is invoked.

function privatemsg_message_change_recipient($mid, $uid, $type = 'user', $add = TRUE) {

  $thread_id = db_result(db_query('SELECT thread_id FROM {pm_index} WHERE mid = %d', $mid));
  if ($add) {
    // Only add the recipient if he does not block the author.
    $author_uid = db_result(db_query('SELECT author FROM {pm_message} WHERE mid = %d', $mid));
    $recipient = privatemsg_user_load($uid);
    $user_blocked = module_invoke_all('privatemsg_block_message', privatemsg_user_load($author_uid), array(privatemsg_recipient_key($recipient) => $recipient));
    if (count($user_blocked) <> 0) {
      return;
    }

    [.... the rest of the function ...]

In theory you can just compare thread_id to mid to see if this is a reply or a new message, and if it is a reply, you can pass the proper context.

Patch forthcoming.

CommentFileSizeAuthor
#1 issue-1182962.patch1.5 KBte-brian

Comments

te-brian’s picture

StatusFileSize
new1.5 KB

And here's the patch. I think some pesky white-space got in though. I ran the test suite so things should be good. The only real question is if it was originally intended to NOT pass the context.

te-brian’s picture

Status: Active » Needs review

Changing status

berdir’s picture

Status: Needs review » Fixed

Looks good, commited to 6.x-2.x, 7.x-1.x and 7.x-2.x :)

berdir’s picture

Note: The test bot will soon not apply -p0 patches anymore, I suggest you switch to creating standard git patches (with the a/b prefix) :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.