Get group attentions back into the "all" feed

This commit is contained in:
Mikael Nordfeldth 2014-03-07 02:49:42 +01:00
parent 0bc7d9c6c6
commit 5842c59ba7
3 changed files with 40 additions and 21 deletions

View File

@ -979,30 +979,23 @@ class Notice extends Managed_DataObject
} }
} }
if (is_null($groups)) {
$groups = $this->getGroups();
}
if (is_null($recipients)) { if (is_null($recipients)) {
$recipients = $this->getReplies(); $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(); $ni = array();
// Give plugins a chance to add folks in at start... // Give plugins a chance to add folks in at start...
if (Event::handle('StartNoticeWhoGets', array($this, &$ni))) { if (Event::handle('StartNoticeWhoGets', array($this, &$ni))) {
$users = $this->getSubscribedUsers();
foreach ($users as $id) { foreach ($users as $id) {
$ni[$id] = NOTICE_INBOX_SOURCE_SUB; $ni[$id] = NOTICE_INBOX_SOURCE_SUB;
} }
if (is_null($groups)) {
$groups = $this->getGroups();
}
foreach ($groups as $group) { foreach ($groups as $group) {
$users = $group->getUserMembers(); $users = $group->getUserMembers();
foreach ($users as $id) { foreach ($users as $id) {
@ -1012,12 +1005,10 @@ class Notice extends Managed_DataObject
} }
} }
foreach ($ptags as $ptag) { $ptAtts = $this->getAttentionsFromProfileTags();
$users = $ptag->getUserSubscribers(); foreach ($ptAtts as $key=>$val) {
foreach ($users as $id) { if (!array_key_exists($key, $ni)) {
if (!array_key_exists($id, $ni)) { $ni[$key] = $val;
$ni[$id] = NOTICE_INBOX_SOURCE_PROFILE_TAG;
}
} }
} }
@ -1104,6 +1095,19 @@ class Notice extends Managed_DataObject
return $ptags; 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. * Record this notice to the given group inboxes for delivery.
* Overrides the regular parsing of !group markup. * Overrides the regular parsing of !group markup.

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }
/** /**
* Base class for queue handlers. * Base class for queue handlers.
@ -43,7 +43,7 @@ class DistribQueueHandler
* @return string * @return string
*/ */
function transport() public function transport()
{ {
return 'distrib'; return 'distrib';
} }
@ -61,8 +61,22 @@ class DistribQueueHandler
* @param Notice $notice * @param Notice $notice
* @return boolean true on success, false on failure * @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 { try {
$notice->sendReplyNotifications(); $notice->sendReplyNotifications();
} catch (Exception $e) { } catch (Exception $e) {

View File

@ -107,7 +107,8 @@ class RawInboxNoticeStream extends NoticeStream
// Subscription:: is a table of subscriptions (every user is subscribed to themselves) // Subscription:: is a table of subscriptions (every user is subscribed to themselves)
$notice->whereAdd( $notice->whereAdd(
sprintf('notice.id IN (SELECT notice_id FROM reply WHERE profile_id=%1$d) ' . 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)', 'OR notice.id IN (SELECT notice_id FROM attention WHERE profile_id=%1$d)',
$this->target->id) $this->target->id)
); );