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:
@@ -74,19 +74,17 @@ class SpamAction extends Action
|
||||
|
||||
// User must be logged in.
|
||||
|
||||
$user = common_current_user();
|
||||
|
||||
if (empty($user)) {
|
||||
if (!$this->scoped instanceof Profile) {
|
||||
throw new ClientException(_("You must be logged in to review."), 403);
|
||||
}
|
||||
|
||||
// User must have the right to review spam
|
||||
|
||||
if (!$user->hasRight(ActivitySpamPlugin::REVIEWSPAM)) {
|
||||
if (!$this->scoped->hasRight(ActivitySpamPlugin::REVIEWSPAM)) {
|
||||
throw new ClientException(_('You cannot review spam on this site.'), 403);
|
||||
}
|
||||
|
||||
$stream = new SpamNoticeStream($user->getProfile());
|
||||
$stream = new SpamNoticeStream($this->scoped);
|
||||
|
||||
$this->notices = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
|
||||
NOTICES_PER_PAGE + 1);
|
||||
|
@@ -28,11 +28,7 @@
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
if (!defined('STATUSNET')) {
|
||||
// This check helps protect against security problems;
|
||||
// your code file can't be executed directly from the web.
|
||||
exit(1);
|
||||
}
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
/**
|
||||
* Spam notice stream
|
||||
@@ -47,13 +43,10 @@ if (!defined('STATUSNET')) {
|
||||
|
||||
class SpamNoticeStream extends ScopingNoticeStream
|
||||
{
|
||||
function __construct($tag, $profile = -1)
|
||||
function __construct(Profile $scoped=null)
|
||||
{
|
||||
if (is_int($profile) && $profile == -1) {
|
||||
$profile = Profile::current();
|
||||
}
|
||||
parent::__construct(new CachingNoticeStream(new RawSpamNoticeStream(),
|
||||
'spam_score:notice_ids'));
|
||||
parent::__construct(new CachingNoticeStream(new RawSpamNoticeStream(), 'spam_score:notice_ids'),
|
||||
$scoped);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user