New mechanism for "all" feed (InboxNoticeStream)
Also cleaned up and made typing stricter for the stream, so only profiles can be submitted. This reasonably also means we can create "inbox" or "all" streams for foreign profiles as well using the same stream handler (but of course only for messages we already know about). To avoid looking up posts for a long time in a large notice database, the lookback period for the inbox is no longer than the profile creation date. (this matches the behaviour of Inbox) Inbox class can probably be removed now.
This commit is contained in:
parent
c812e7c0d6
commit
4b2a66ed29
@ -213,7 +213,7 @@ class AllAction extends ProfileAction
|
||||
// XXX: make this a little more convenient
|
||||
|
||||
if (!common_config('performance', 'high')) {
|
||||
$pop = new PopularNoticeSection($this, Profile::current());
|
||||
$pop = new PopularNoticeSection($this, $this->scoped);
|
||||
$pop->show();
|
||||
$pop = new InboxTagCloudSection($this, $this->target);
|
||||
$pop->show();
|
||||
@ -223,8 +223,8 @@ class AllAction extends ProfileAction
|
||||
|
||||
class ThreadingInboxNoticeStream extends ThreadingNoticeStream
|
||||
{
|
||||
function __construct($user, $profile)
|
||||
function __construct(Profile $target, Profile $scoped=null)
|
||||
{
|
||||
parent::__construct(new InboxNoticeStream($user, $profile));
|
||||
parent::__construct(new InboxNoticeStream($target, $scoped));
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ class AllrssAction extends Rss10Action
|
||||
*/
|
||||
function getNotices($limit=0)
|
||||
{
|
||||
$stream = new InboxNoticeStream($this->user);
|
||||
$stream = new InboxNoticeStream($this->user->getProfile());
|
||||
$notice = $stream->getNotices(0, $limit, null, null);
|
||||
|
||||
$notices = array();
|
||||
|
@ -274,7 +274,7 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
|
||||
{
|
||||
$notices = array();
|
||||
|
||||
$stream = new InboxNoticeStream($this->target->getUser(), $this->scoped);
|
||||
$stream = new InboxNoticeStream($this->target, $this->scoped);
|
||||
|
||||
$notice = $stream->getNotices(($this->page-1) * $this->count,
|
||||
$this->count,
|
||||
|
@ -102,19 +102,22 @@ class RawInboxNoticeStream extends NoticeStream
|
||||
{
|
||||
$notice = new Notice();
|
||||
$notice->selectAdd();
|
||||
$notice->selectAdd('notice_id');
|
||||
// Reply is a class for mentions
|
||||
$notice->joinAdd(array('id', 'reply:notice_id'));
|
||||
|
||||
$notice->profile_id = $this->target->id;
|
||||
$notice->selectAdd('id');
|
||||
$notice->whereAdd(sprintf('notice.created > "%s"', $notice->escape($this->target->created)));
|
||||
// Reply:: is a table of mentions
|
||||
// Subscription:: is a table of subscriptions (every user is subscribed to themselves)
|
||||
$notice->whereAdd(
|
||||
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)', $this->target->id)
|
||||
);
|
||||
$notice->limit($offset, $limit);
|
||||
$notice->orderBy('created DESC');
|
||||
$notice->orderBy('notice.created DESC');
|
||||
|
||||
if (!$notice->find()) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$ids = $notice->fetchAll('notice_id');
|
||||
$ids = $notice->fetchAll('id');
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
@ -42,12 +42,12 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
*/
|
||||
class InboxTagCloudSection extends TagCloudSection
|
||||
{
|
||||
var $user = null;
|
||||
protected $target = null;
|
||||
|
||||
function __construct($out=null, $user=null)
|
||||
function __construct($out=null, Profile $target)
|
||||
{
|
||||
parent::__construct($out);
|
||||
$this->user = $user;
|
||||
$this->target = $target;
|
||||
}
|
||||
|
||||
function title()
|
||||
@ -60,14 +60,14 @@ class InboxTagCloudSection extends TagCloudSection
|
||||
{
|
||||
$profile = Profile::current();
|
||||
|
||||
$keypart = sprintf('Inbox:notice_tag:%d:%d', $this->user->id,
|
||||
$keypart = sprintf('Inbox:notice_tag:%d:%d', $this->target,
|
||||
$profile instanceof Profile ? $profile->id : 0);
|
||||
|
||||
$tag = Memcached_DataObject::cacheGet($keypart);
|
||||
|
||||
if ($tag === false) {
|
||||
|
||||
$stream = new InboxNoticeStream($this->user, $profile);
|
||||
$stream = new InboxNoticeStream($this->target, $profile);
|
||||
|
||||
$ids = $stream->getNoticeIds(0, Inbox::MAX_NOTICES, null, null);
|
||||
|
||||
|
@ -102,7 +102,8 @@ class UserEmailSummaryHandler extends QueueHandler
|
||||
return true;
|
||||
}
|
||||
|
||||
$stream = new InboxNoticeStream($user, $user->getProfile());
|
||||
// An InboxNoticeStream for a certain user, scoped to its own view
|
||||
$stream = new InboxNoticeStream($profile, $profile);
|
||||
|
||||
$notice = $stream->getNotices(0, self::MAX_NOTICES, $since_id);
|
||||
|
||||
|
@ -47,8 +47,7 @@ class AllmapAction extends MapAction
|
||||
function prepare($args)
|
||||
{
|
||||
if (parent::prepare($args)) {
|
||||
$cur = common_current_user();
|
||||
$stream = new InboxNoticeStream($this->user, $cur->getProfile());
|
||||
$stream = new InboxNoticeStream($this->user->getProfile(), $this->scoped);
|
||||
$this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
|
||||
NOTICES_PER_PAGE + 1,
|
||||
null,
|
||||
|
@ -95,7 +95,7 @@ function newNotice($i, $tagmax)
|
||||
$content = testNoticeContent();
|
||||
|
||||
if ($is_reply == 0) {
|
||||
$stream = new InboxNoticeStream($user, $user->getProfile());
|
||||
$stream = new InboxNoticeStream($user->getProfile(), $user->getProfile());
|
||||
$notices = $stream->getNotices(0, 20);
|
||||
if ($notices->N > 0) {
|
||||
$nval = rand(0, $notices->N - 1);
|
||||
|
Loading…
Reference in New Issue
Block a user