We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit e21b0948 authored by Evan Prodromou's avatar Evan Prodromou

Sanity check on profile streams

parent 4ea9a0a7
...@@ -47,15 +47,44 @@ if (!defined('STATUSNET')) { ...@@ -47,15 +47,44 @@ if (!defined('STATUSNET')) {
class ProfileNoticeStream extends ScopingNoticeStream class ProfileNoticeStream extends ScopingNoticeStream
{ {
var $streamProfile;
function __construct($profile, $userProfile = -1) function __construct($profile, $userProfile = -1)
{ {
if (is_int($userProfile) && $userProfile == -1) { if (is_int($userProfile) && $userProfile == -1) {
$userProfile = Profile::current(); $userProfile = Profile::current();
} }
$this->streamProfile = $profile;
parent::__construct(new CachingNoticeStream(new RawProfileNoticeStream($profile), parent::__construct(new CachingNoticeStream(new RawProfileNoticeStream($profile),
'profile:notice_ids:' . $profile->id), 'profile:notice_ids:' . $profile->id),
$userProfile); $userProfile);
} }
function getNoticeIds($offset, $limit, $since_id, $max_id)
{
// Sanity check
if (common_config('notice', 'hidespam')) {
if ($this->streamProfile->hasRole(Profile_role::SILENCED) &&
(empty($this->profile) || !$this->profile->hasRole(Profile_role::MODERATOR))) {
throw new ClientException(_("This account silenced by moderators."), 403);
}
}
return parent::getNoticeIds($offset, $limit, $since_id, $max_id);
}
function getNotices($offset, $limit, $sinceId = null, $maxId = null)
{
// Sanity check
if (common_config('notice', 'hidespam')) {
if ($this->streamProfile->hasRole(Profile_role::SILENCED) &&
(empty($this->profile) || !$this->profile->hasRole(Profile_role::MODERATOR))) {
throw new ClientException(_("This account silenced by moderators."), 403);
}
}
return parent::getNotices($offset, $limit, $sinceId, $maxId);
}
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment