forked from GNUsocial/gnu-social
pre-fill the addressees of notices in a list
This commit is contained in:
parent
ba6235a446
commit
16042387a0
@ -1303,6 +1303,8 @@ class Notice extends Memcached_DataObject
|
|||||||
return $reply;
|
return $reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected $_replies = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pull the complete list of @-reply targets for this notice.
|
* Pull the complete list of @-reply targets for this notice.
|
||||||
*
|
*
|
||||||
@ -1310,31 +1312,28 @@ class Notice extends Memcached_DataObject
|
|||||||
*/
|
*/
|
||||||
function getReplies()
|
function getReplies()
|
||||||
{
|
{
|
||||||
$keypart = sprintf('notice:reply_ids:%d', $this->id);
|
if ($this->_replies != -1) {
|
||||||
|
return $this->_replies;
|
||||||
|
}
|
||||||
|
|
||||||
$idstr = self::cacheGet($keypart);
|
$replyMap = Memcached_DataObject::listGet('Reply', 'notice_id', array($this->id));
|
||||||
|
|
||||||
if ($idstr !== false) {
|
|
||||||
$ids = explode(',', $idstr);
|
|
||||||
} else {
|
|
||||||
$ids = array();
|
$ids = array();
|
||||||
|
|
||||||
$reply = new Reply();
|
foreach ($replyMap[$this->id] as $reply) {
|
||||||
$reply->selectAdd();
|
|
||||||
$reply->selectAdd('profile_id');
|
|
||||||
$reply->notice_id = $this->id;
|
|
||||||
|
|
||||||
if ($reply->find()) {
|
|
||||||
while($reply->fetch()) {
|
|
||||||
$ids[] = $reply->profile_id;
|
$ids[] = $reply->profile_id;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
self::cacheSet($keypart, implode(',', $ids));
|
$this->_replies = $ids;
|
||||||
}
|
|
||||||
|
|
||||||
return $ids;
|
return $ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _setReplies($replies)
|
||||||
|
{
|
||||||
|
$this->_replies = $replies;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pull the complete list of @-reply targets for this notice.
|
* Pull the complete list of @-reply targets for this notice.
|
||||||
*
|
*
|
||||||
@ -2436,7 +2435,7 @@ class Notice extends Memcached_DataObject
|
|||||||
function __sleep()
|
function __sleep()
|
||||||
{
|
{
|
||||||
$vars = parent::__sleep();
|
$vars = parent::__sleep();
|
||||||
$skip = array('_original', '_profile', '_groups', '_attachments', '_faves');
|
$skip = array('_original', '_profile', '_groups', '_attachments', '_faves', '_replies');
|
||||||
return array_diff($vars, $skip);
|
return array_diff($vars, $skip);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2579,4 +2578,18 @@ class Notice extends Memcached_DataObject
|
|||||||
$notice->_setFaves($faveMap[$notice->id]);
|
$notice->_setFaves($faveMap[$notice->id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function fillReplies(&$notices)
|
||||||
|
{
|
||||||
|
$ids = self::_idsOf($notices);
|
||||||
|
$replyMap = Memcached_DataObject::listGet('Reply', 'notice_id', $ids);
|
||||||
|
foreach ($notices as $notice) {
|
||||||
|
$replies = $replyMap[$notice->id];
|
||||||
|
$ids = array();
|
||||||
|
foreach ($replies as $reply) {
|
||||||
|
$ids[] = $reply->profile_id;
|
||||||
|
}
|
||||||
|
$notice->_setReplies($ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,7 @@ abstract class FilteringNoticeStream extends NoticeStream
|
|||||||
// XXX: this should probably only be in the scoping one.
|
// XXX: this should probably only be in the scoping one.
|
||||||
|
|
||||||
Notice::fillGroups($notices);
|
Notice::fillGroups($notices);
|
||||||
|
Notice::fillReplies($notices);
|
||||||
|
|
||||||
foreach ($notices as $notice) {
|
foreach ($notices as $notice) {
|
||||||
if ($this->filter($notice)) {
|
if ($this->filter($notice)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user