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.
Comments
Comment #1
te-brian commentedAnd 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.
Comment #2
te-brian commentedChanging status
Comment #3
berdirLooks good, commited to 6.x-2.x, 7.x-1.x and 7.x-2.x :)
Comment #4
berdirNote: The test bot will soon not apply -p0 patches anymore, I suggest you switch to creating standard git patches (with the a/b prefix) :)