UserActivityStream export of DMs moved to plugin

This commit is contained in:
Mikael Nordfeldth 2014-11-07 16:08:16 +01:00
parent d493fd0772
commit 38d9b4d3a4
2 changed files with 22 additions and 29 deletions

View File

@ -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);

View File

@ -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