From 07f70b43b503af7f3178d87077de255e4cdf86ee Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 21 Mar 2012 14:22:45 -0400 Subject: [PATCH] Sanity check on profile streams --- lib/profilenoticestream.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/profilenoticestream.php b/lib/profilenoticestream.php index 64cd31abc4..d2948e60c8 100644 --- a/lib/profilenoticestream.php +++ b/lib/profilenoticestream.php @@ -47,15 +47,44 @@ if (!defined('STATUSNET')) { class ProfileNoticeStream extends ScopingNoticeStream { + var $streamProfile; + function __construct($profile, $userProfile = -1) { if (is_int($userProfile) && $userProfile == -1) { $userProfile = Profile::current(); } + $this->streamProfile = $profile; parent::__construct(new CachingNoticeStream(new RawProfileNoticeStream($profile), 'profile:notice_ids:' . $profile->id), $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); + } } /** -- 2.39.5