From 998db39b1ab60380a55316f8665949bb450c6263 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Wed, 30 Dec 2015 17:35:47 +0100 Subject: [PATCH] Notification mails are sent again fixes ssue #99 The problem was that the ActivityVerbPostPlugin handled 'post' verbs but didn't handle the notifications for them, so now we're returning true in the event so the default behaviour (sending to 'getReplies' recipients) is done by default. --- classes/Notice.php | 7 ++++--- lib/activityhandlerplugin.php | 8 ++++---- lib/mail.php | 4 +--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index c5c07e6d19..22796abcfa 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1732,7 +1732,6 @@ class Notice extends Managed_DataObject function sendReplyNotifications() { // Don't send reply notifications for repeats - if ($this->isRepeat()) { return array(); } @@ -1742,9 +1741,11 @@ class Notice extends Managed_DataObject require_once INSTALLDIR.'/lib/mail.php'; foreach ($recipientIds as $recipientId) { - $user = User::getKV('id', $recipientId); - if ($user instanceof User) { + try { + $user = User::getByID($recipientId); mail_notify_attn($user, $this); + } catch (NoResultException $e) { + // No such user } } Event::handle('EndNotifyMentioned', array($this, $recipientIds)); diff --git a/lib/activityhandlerplugin.php b/lib/activityhandlerplugin.php index 967454bad5..d22b4d2f44 100644 --- a/lib/activityhandlerplugin.php +++ b/lib/activityhandlerplugin.php @@ -233,6 +233,9 @@ abstract class ActivityHandlerPlugin extends Plugin protected function notifyMentioned(Notice $stored, array &$mentioned_ids) { // pass through silently by default + + // If we want to stop any other plugin from notifying based on this activity, return false instead. + return true; } /** @@ -305,10 +308,7 @@ abstract class ActivityHandlerPlugin extends Plugin return true; } - $this->notifyMentioned($stored, $mentioned_ids); - - // If it was _our_ notice, only we should do anything with the mentions. - return false; + return $this->notifyMentioned($stored, $mentioned_ids); } /** diff --git a/lib/mail.php b/lib/mail.php index a5e9efded1..2076476f87 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -30,9 +30,7 @@ * @link http://status.net/ */ -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); -} +if (!defined('GNUSOCIAL')) { exit(1); } require_once 'Mail.php';