finally found a fix for #92

This commit is contained in:
Hannes Mannerheim 2015-06-16 20:20:28 +02:00
parent 492da05663
commit 80b9ca7fec

View File

@ -522,10 +522,16 @@ class QvitterPlugin extends Plugin {
function insertNotification($to_profile_id, $from_profile_id, $ntype, $notice_id=false) function insertNotification($to_profile_id, $from_profile_id, $ntype, $notice_id=false)
{ {
// no notifications from blocked profiles
$to_user = User::getKV('id', $to_profile_id); $to_user = User::getKV('id', $to_profile_id);
$from_user = Profile::getKV($from_profile_id); $from_profile = Profile::getKV($from_profile_id);
if ($to_user instanceof User && $to_user->hasBlocked($from_user)) {
// don't notify remote profiles
if (!$to_user instanceof User) {
return false;
}
// no notifications from blocked profiles
if ($to_user->hasBlocked($from_profile)) {
return false; return false;
} }
@ -548,6 +554,7 @@ class QvitterPlugin extends Plugin {
return true; return true;
} }
/** /**
@ -630,25 +637,23 @@ class QvitterPlugin extends Plugin {
} }
} }
// check for mentions to insert in notifications // check for mentions to insert in notifications
$mentions = common_find_mentions($notice->content, $notice); $mentions = $notice->getReplies();
$sender = Profile::getKV($notice->profile_id); $sender = Profile::getKV($notice->profile_id);
$all_mentioned_user_ids = array(); $all_mentioned_user_ids = array();
foreach ($mentions as $mention) { foreach ($mentions as $mentioned) {
foreach ($mention['mentioned'] as $mentioned) {
// no duplicate mentions
// no duplicate mentions if(in_array($mentioned, $all_mentioned_user_ids)) {
if(in_array($mentioned->id, $all_mentioned_user_ids)) { continue;
continue; }
} $all_mentioned_user_ids[] = $mentioned;
$all_mentioned_user_ids[] = $mentioned->id;
// only notify if mentioned user is not already notified for reply
// only notify if mentioned user is not already notified for reply if($reply_notification_to != $mentioned) {
if($reply_notification_to != $mentioned->id) { $this->insertNotification($mentioned, $notice->profile_id, 'mention', $notice->id);
$this->insertNotification($mentioned->id, $notice->profile_id, 'mention', $notice->id);
}
} }
} }
} }
return true; return true;