UserActivityStream export of DMs moved to plugin
This commit is contained in:
parent
d493fd0772
commit
38d9b4d3a4
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user