From: Mikael Nordfeldth Date: Fri, 7 Nov 2014 15:08:16 +0000 (+0100) Subject: UserActivityStream export of DMs moved to plugin X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=38d9b4d3a492e64de969e31e5ab492bee52af908;p=quix0rs-gnu-social.git UserActivityStream export of DMs moved to plugin --- diff --git a/lib/useractivitystream.php b/lib/useractivitystream.php index 21dfff1db5..a94fee2139 100644 --- a/lib/useractivitystream.php +++ b/lib/useractivitystream.php @@ -75,10 +75,8 @@ class UserActivityStream extends AtomUserNoticeFeed $subscriptions = $this->getSubscriptions(); $subscribers = $this->getSubscribers(); $groups = $this->getGroups(); - $messagesFrom = $this->getMessagesFrom(); - $messagesTo = $this->getMessagesTo(); - $objs = array_merge($subscriptions, $subscribers, $groups, $notices, $messagesFrom, $messagesTo); + $objs = array_merge($subscriptions, $subscribers, $groups, $notices); Event::handle('AppendUserActivityStreamObjects', array($this, &$objs)); @@ -353,32 +351,6 @@ class UserActivityStream extends AtomUserNoticeFeed return $groups; } - function getMessagesTo() - { - $msgMap = Message::listGet('to_profile', array($this->user->id)); - - $messages = $msgMap[$this->user->id]; - - if (!empty($this->after)) { - $messages = array_filter($messages, array($this, 'createdAfter')); - } - - return $messages; - } - - function getMessagesFrom() - { - $msgMap = Message::listGet('from_profile', array($this->user->id)); - - $messages = $msgMap[$this->user->id]; - - if (!empty($this->after)) { - $messages = array_filter($messages, array($this, 'createdAfter')); - } - - return $messages; - } - function createdAfter($item) { $created = strtotime((empty($item->created)) ? $item->modified : $item->created); return ($created >= $this->after); diff --git a/plugins/DirectMessage/DirectMessagePlugin.php b/plugins/DirectMessage/DirectMessagePlugin.php index 1e717833ad..190246de3d 100644 --- a/plugins/DirectMessage/DirectMessagePlugin.php +++ b/plugins/DirectMessage/DirectMessagePlugin.php @@ -55,6 +55,27 @@ class DirectMessagePlugin extends Plugin return true; } + public function onAppendUserActivityStreamObjects(UserActivityStream $uas, array &$objs) + { + // Messages _from_ the user + $msgMap = Message::listGet('from_profile', array($this->user->id)); + $messages = $msgMap[$uas->user->id]; + if (!empty($uas->after)) { + $messages = array_filter($messages, array($uas, 'createdAfter')); + } + $objs[] = $messages; + + // Messages _to_ the user + $msgMap = Message::listGet('to_profile', array($this->user->id)); + $messages = $msgMap[$uas->user->id]; + if (!empty($uas->after)) { + $messages = array_filter($messages, array($uas, 'createdAfter')); + } + $objs[] = $messages; + + return true; + } + public function onEndPersonalGroupNav(Menu $menu, Profile $target, Profile $scoped=null) { if ($scoped instanceof Profile && $scoped->id == $target->id