all filtering stream classes take an optional profile parameter

This commit is contained in:
Evan Prodromou 2011-04-11 12:32:35 -04:00
parent 1b00eb2599
commit d7f96307dc
12 changed files with 65 additions and 20 deletions

View File

@ -46,8 +46,12 @@ if (!defined('STATUSNET')) {
*/
class ConversationNoticeStream extends ScopingNoticeStream
{
function __construct($id, $profile = null)
function __construct($id, $profile = -1)
{
if (is_int($profile) && $profile == -1) {
$profile = Profile::current();
}
parent::__construct(new CachingNoticeStream(new RawConversationNoticeStream($id),
'notice:conversation_ids:'.$id),
$profile);

View File

@ -46,7 +46,7 @@ if (!defined('STATUSNET')) {
*/
class FaveNoticeStream extends ScopingNoticeStream
{
function __construct($user_id, $own)
function __construct($user_id, $own, $profile = -1)
{
$stream = new RawFaveNoticeStream($user_id, $own);
if ($own) {
@ -54,7 +54,11 @@ class FaveNoticeStream extends ScopingNoticeStream
} else {
$key = 'fave:ids_by_user:'.$user_id;
}
parent::__construct(new CachingNoticeStream($stream, $key));
if (is_int($profile) && $profile == -1) {
$profile = Profile::current();
}
parent::__construct(new CachingNoticeStream($stream, $key),
$profile);
}
}

View File

@ -36,10 +36,14 @@ if (!defined('STATUSNET')) {
class FileNoticeStream extends ScopingNoticeStream
{
function __construct($file)
function __construct($file, $profile = -1)
{
if (is_int($profile) && $profile == -1) {
$profile = Profile::current();
}
parent::__construct(new CachingNoticeStream(new RawFileNoticeStream($file),
'file:notice-ids:'.$this->url));
'file:notice-ids:'.$this->url),
$profile);
}
}

View File

@ -46,8 +46,11 @@ if (!defined('STATUSNET')) {
*/
class GroupNoticeStream extends ScopingNoticeStream
{
function __construct($group, $profile = null)
function __construct($group, $profile = -1)
{
if (is_int($profile) && $profile == -1) {
$profile = Profile::current();
}
parent::__construct(new CachingNoticeStream(new RawGroupNoticeStream($group),
'user_group:notice_ids:' . $group->id),
$profile);

View File

@ -51,8 +51,11 @@ class InboxNoticeStream extends ScopingNoticeStream
*
* @param User $user User to get a stream for
*/
function __construct($user, $profile = null)
function __construct($user, $profile = -1)
{
if (is_int($profile) && $profile == -1) {
$profile = Profile::current();
}
// Note: we don't use CachingNoticeStream since RawInboxNoticeStream
// uses Inbox::staticGet(), which is cached.
parent::__construct(new RawInboxNoticeStream($user), $profile);

View File

@ -47,10 +47,14 @@ if (!defined('STATUSNET')) {
*/
class PeopletagNoticeStream extends ScopingNoticeStream
{
function __construct($plist)
function __construct($plist, $profile = -1)
{
if (is_int($profile) && $profile == -1) {
$profile = Profile::current();
}
parent::__construct(new CachingNoticeStream(new RawPeopletagNoticeStream($plist),
'profile_tag:notice_ids:' . $plist->id));
'profile_tag:notice_ids:' . $plist->id),
$profile);
}
}

View File

@ -47,10 +47,14 @@ if (!defined('STATUSNET')) {
class ProfileNoticeStream extends ScopingNoticeStream
{
function __construct($profile)
function __construct($profile, $userProfile = -1)
{
if (is_int($userProfile) && $userProfile == -1) {
$userProfile = Profile::current();
}
parent::__construct(new CachingNoticeStream(new RawProfileNoticeStream($profile),
'profile:notice_ids:' . $profile->id));
'profile:notice_ids:' . $profile->id),
$userProfile);
}
}

View File

@ -47,10 +47,14 @@ if (!defined('STATUSNET')) {
class RepeatedByMeNoticeStream extends ScopingNoticeStream
{
function __construct($user)
function __construct($user, $profile = -1)
{
if (is_int($profile) && $profile == -1) {
$profile = Profile::current();
}
parent::__construct(new CachingNoticeStream(new RawRepeatedByMeNoticeStream($user),
'user:repeated_by_me:'.$user->id));
'user:repeated_by_me:'.$user->id),
$profile);
}
}

View File

@ -47,10 +47,14 @@ if (!defined('STATUSNET')) {
class RepeatsOfMeNoticeStream extends ScopingNoticeStream
{
function __construct($user)
function __construct($user, $profile=-1)
{
if (is_int($profile) && $profile == -1) {
$profile = Profile::current();
}
parent::__construct(new CachingNoticeStream(new RawRepeatsOfMeNoticeStream($user),
'user:repeats_of_me:'.$user->id));
'user:repeats_of_me:'.$user->id),
$profile);
}
}

View File

@ -47,10 +47,14 @@ if (!defined('STATUSNET')) {
class ReplyNoticeStream extends ScopingNoticeStream
{
function __construct($userId)
function __construct($userId, $profile=-1)
{
if (is_int($profile) && $profile == -1) {
$profile = Profile::current();
}
parent::__construct(new CachingNoticeStream(new RawReplyNoticeStream($userId),
'reply:stream:' . $userId));
'reply:stream:' . $userId),
$profile);
}
}

View File

@ -47,10 +47,14 @@ if (!defined('STATUSNET')) {
class TaggedProfileNoticeStream extends ScopingNoticeStream
{
function __construct($profile, $tag)
function __construct($profile, $tag, $userProfile)
{
if (is_int($userProfile) && $userProfile == -1) {
$userProfile = Profile::current();
}
parent::__construct(new CachingNoticeStream(new RawTaggedProfileNoticeStream($profile, $tag),
'profile:notice_ids_tagged:'.$profile->id.':'.Cache::keyize($tag)));
'profile:notice_ids_tagged:'.$profile->id.':'.Cache::keyize($tag)),
$userProfile);
}
}

View File

@ -47,8 +47,11 @@ if (!defined('STATUSNET')) {
class TagNoticeStream extends ScopingNoticeStream
{
function __construct($tag)
function __construct($tag, $profile = -1)
{
if (is_int($profile) && $profile == -1) {
$profile = Profile::current();
}
parent::__construct(new CachingNoticeStream(new RawTagNoticeStream($tag),
'notice_tag:notice_ids:' . Cache::keyize($tag)));
}