From: Mikael Nordfeldth Date: Fri, 7 Mar 2014 01:49:42 +0000 (+0100) Subject: Get group attentions back into the "all" feed X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5842c59ba7e738724f026429590e29eb89af92b4;p=quix0rs-gnu-social.git Get group attentions back into the "all" feed --- diff --git a/classes/Notice.php b/classes/Notice.php index fe1442ea97..39b49a284a 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -979,30 +979,23 @@ class Notice extends Managed_DataObject } } - if (is_null($groups)) { - $groups = $this->getGroups(); - } - if (is_null($recipients)) { $recipients = $this->getReplies(); } - $users = $this->getSubscribedUsers(); - $ptags = $this->getProfileTags(); - - // FIXME: kind of ignoring 'transitional'... - // we'll probably stop supporting inboxless mode - // in 0.9.x - $ni = array(); // Give plugins a chance to add folks in at start... if (Event::handle('StartNoticeWhoGets', array($this, &$ni))) { + $users = $this->getSubscribedUsers(); foreach ($users as $id) { $ni[$id] = NOTICE_INBOX_SOURCE_SUB; } + if (is_null($groups)) { + $groups = $this->getGroups(); + } foreach ($groups as $group) { $users = $group->getUserMembers(); foreach ($users as $id) { @@ -1012,12 +1005,10 @@ class Notice extends Managed_DataObject } } - foreach ($ptags as $ptag) { - $users = $ptag->getUserSubscribers(); - foreach ($users as $id) { - if (!array_key_exists($id, $ni)) { - $ni[$id] = NOTICE_INBOX_SOURCE_PROFILE_TAG; - } + $ptAtts = $this->getAttentionsFromProfileTags(); + foreach ($ptAtts as $key=>$val) { + if (!array_key_exists($key, $ni)) { + $ni[$key] = $val; } } @@ -1104,6 +1095,19 @@ class Notice extends Managed_DataObject return $ptags; } + public function getAttentionsFromProfileTags() + { + $ni = array(); + $ptags = $this->getProfileTags(); + foreach ($ptags as $ptag) { + $users = $ptag->getUserSubscribers(); + foreach ($users as $id) { + $ni[$id] = NOTICE_INBOX_SOURCE_PROFILE_TAG; + } + } + return $ni; + } + /** * Record this notice to the given group inboxes for delivery. * Overrides the regular parsing of !group markup. diff --git a/lib/distribqueuehandler.php b/lib/distribqueuehandler.php index 4a671fe802..036d970f2a 100644 --- a/lib/distribqueuehandler.php +++ b/lib/distribqueuehandler.php @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } +if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); } /** * Base class for queue handlers. @@ -43,7 +43,7 @@ class DistribQueueHandler * @return string */ - function transport() + public function transport() { return 'distrib'; } @@ -61,8 +61,22 @@ class DistribQueueHandler * @param Notice $notice * @return boolean true on success, false on failure */ - function handle($notice) + public function handle(Notice $notice) { + // We have to manually add attentions to non-profile subs and non-mentions + $ptAtts = $notice->getAttentionsFromProfileTags(); + foreach (array_keys($ptAtts) as $profile_id) { + $profile = Profile::getKV('id', $profile_id); + if ($profile instanceof Profile) { + try { + common_debug('Adding Attention for '.$notice->getID().' profile '.$profile->getID()); + Attention::saveNew($notice, $profile); + } catch (Exception $e) { + $this->logit($notice, $e); + } + } + } + try { $notice->sendReplyNotifications(); } catch (Exception $e) { diff --git a/lib/inboxnoticestream.php b/lib/inboxnoticestream.php index 84cac7c67b..57c5e0c80e 100644 --- a/lib/inboxnoticestream.php +++ b/lib/inboxnoticestream.php @@ -107,7 +107,8 @@ class RawInboxNoticeStream extends NoticeStream // Subscription:: is a table of subscriptions (every user is subscribed to themselves) $notice->whereAdd( sprintf('notice.id IN (SELECT notice_id FROM reply WHERE profile_id=%1$d) ' . - 'OR notice.profile_id IN (SELECT subscribed FROM subscription WHERE subscriber=%d) ' . + 'OR notice.profile_id IN (SELECT subscribed FROM subscription WHERE subscriber=%1$d) ' . + 'OR notice.id IN (SELECT notice_id FROM group_inbox WHERE group_id IN (SELECT group_id FROM group_member WHERE profile_id=%1$d))' . 'OR notice.id IN (SELECT notice_id FROM attention WHERE profile_id=%1$d)', $this->target->id) );