Consistent behaviour for ScopingNoticeStream $scoped

We don't guess the current profile anymore if the value of the profile === -1

Also sets $this->scoped for all ScopingNoticeStream inheritors, which just
like in an Action can be null if we're not scoped in any way (logged in).
This commit is contained in:
Mikael Nordfeldth
2016-03-01 14:51:47 +01:00
parent 7862b853bf
commit 63c087a255
38 changed files with 151 additions and 239 deletions

View File

@@ -42,19 +42,15 @@ if (!defined('GNUSOCIAL')) { exit(1); }
*/
class FaveNoticeStream extends ScopingNoticeStream
{
function __construct($user_id, $own, $profile = -1)
function __construct(Profile $target, Profile $scoped=null)
{
$stream = new RawFaveNoticeStream($user_id, $own);
if ($own) {
$stream = new RawFaveNoticeStream($target, $scoped);
if ($target->sameAs($scoped)) {
$key = 'fave:ids_by_user_own:'.$user_id;
} else {
$key = 'fave:ids_by_user:'.$user_id;
}
if (is_int($profile) && $profile == -1) {
$profile = Profile::current();
}
parent::__construct(new CachingNoticeStream($stream, $key),
$profile);
parent::__construct(new CachingNoticeStream($stream, $key), $scoped);
}
}
@@ -75,12 +71,12 @@ class RawFaveNoticeStream extends NoticeStream
protected $selectVerbs = array();
function __construct($user_id, $own)
function __construct(Profile $target, Profile $scoped=null)
{
parent::__construct();
$this->user_id = $user_id;
$this->own = $own;
$this->user_id = $target->getID();
$this->own = $target->sameAs($scoped);
}
/**