From 6215ff8e07612d6cd2d8bba725a17c7286eba1ed Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 21 Mar 2012 16:18:38 -0400 Subject: [PATCH] Don't try to find groupnoticestream if impossible --- lib/groupnoticestream.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lib/groupnoticestream.php b/lib/groupnoticestream.php index 26784458e0..849dfeaaf5 100644 --- a/lib/groupnoticestream.php +++ b/lib/groupnoticestream.php @@ -46,15 +46,47 @@ if (!defined('STATUSNET')) { */ class GroupNoticeStream extends ScopingNoticeStream { + var $group; + function __construct($group, $profile = -1) { if (is_int($profile) && $profile == -1) { $profile = Profile::current(); } + $this->group = $group; + parent::__construct(new CachingNoticeStream(new RawGroupNoticeStream($group), 'user_group:notice_ids:' . $group->id), $profile); } + + function getNoticeIds($offset, $limit, $since_id, $max_id) + { + if ($this->impossibleStream()) { + return array(); + } else { + return parent::getNoticeIds($offset, $limit, $since_id, $max_id); + } + } + + function getNotices($offset, $limit, $sinceId = null, $maxId = null) + { + if ($this->impossibleStream()) { + return array(); + } else { + return parent::getNotices($offset, $limit, $sinceId, $maxId); + } + } + + function impossibleStream() + { + if ($this->group->force_scope && + (empty($this->profile) || !$this->profile->isMember($group))) { + return true; + } + + return false; + } } /** -- 2.39.5