'fields' => array(
'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'),
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'who made the update'),
'fields' => array(
'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'),
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'who made the update'),
'notice_repeat_of_fkey' => array('notice', array('repeat_of' => 'id')), # @fixme: what about repeats of deleted notices?
),
'indexes' => array(
'notice_repeat_of_fkey' => array('notice', array('repeat_of' => 'id')), # @fixme: what about repeats of deleted notices?
),
'indexes' => array(
'notice_profile_id_idx' => array('profile_id', 'created', 'id'),
'notice_profile_id_idx' => array('profile_id', 'created', 'id'),
- 'notice_conversation_idx' => array('conversation'),
- 'notice_created_idx' => array('created'),
- 'notice_replyto_idx' => array('reply_to'),
- 'notice_repeatof_idx' => array('repeat_of'),
+ 'notice_repeat_of_created_id_idx' => array('repeat_of', 'created', 'id'),
+ 'notice_conversation_created_id_idx' => array('conversation', 'created', 'id'),
+ 'notice_replyto_idx' => array('reply_to')
$users = $ptag->getUserSubscribers();
foreach ($users as $id) {
if (!array_key_exists($id, $ni)) {
$users = $ptag->getUserSubscribers();
foreach ($users as $id) {
if (!array_key_exists($id, $ni)) {
- $user = User::staticGet('id', $id);
- if (!$user->hasBlocked($profile)) {
- $ni[$id] = NOTICE_INBOX_SOURCE_PROFILE_TAG;
- }
+ $ni[$id] = NOTICE_INBOX_SOURCE_PROFILE_TAG;
if (!array_key_exists($recipient, $ni)) {
$ni[$recipient] = NOTICE_INBOX_SOURCE_REPLY;
}
if (!array_key_exists($recipient, $ni)) {
$ni[$recipient] = NOTICE_INBOX_SOURCE_REPLY;
}
- // Exclude any deleted, non-local, or blocking recipients.
- $profile = $this->getProfile();
- $originalProfile = null;
- if ($this->repeat_of) {
- // Check blocks against the original notice's poster as well.
- $original = Notice::staticGet('id', $this->repeat_of);
- if ($original) {
- $originalProfile = $original->getProfile();
- }
+ // Exclude any deleted, non-local, or blocking recipients.
+ $profile = $this->getProfile();
+ $originalProfile = null;
+ if ($this->repeat_of) {
+ // Check blocks against the original notice's poster as well.
+ $original = Notice::staticGet('id', $this->repeat_of);
+ if ($original) {
+ $originalProfile = $original->getProfile();
$act->time = strtotime($this->created);
$act->link = $this->bestUrl();
$act->content = common_xml_safe_str($this->rendered);
$act->time = strtotime($this->created);
$act->link = $this->bestUrl();
$act->content = common_xml_safe_str($this->rendered);
- $bResult = $this->_inScope($profile);
+ $bResult = false;
+ if (Event::handle('StartNoticeInScope', array($this, $profile, &$bResult))) {
+ $bResult = $this->_inScope($profile);
+ Event::handle('EndNoticeInScope', array($this, $profile, &$bResult));
+ }
$result = ($bResult) ? 1 : 0;
self::cacheSet($keypart, $result, 0, 300);
}
$result = ($bResult) ? 1 : 0;
self::cacheSet($keypart, $result, 0, 300);
}
- if ($scope & Notice::SITE_SCOPE) {
- $user = $profile->getUser();
- if (empty($user)) {
- return false;
+ if ($this->profile_id == $profile->id) {
+ return true;
+ }
+
+ // Only for users on this site
+
+ if ($scope & Notice::SITE_SCOPE) {
+ $user = $profile->getUser();
+ if (empty($user)) {
+ return false;
+ }
- $repl = Reply::pkeyGet(array('notice_id' => $this->id,
- 'profile_id' => $profile->id));
+ $repl = Reply::pkeyGet(array('notice_id' => $this->id,
+ 'profile_id' => $profile->id));
- if (!$foundOne) {
- return false;
+ // Only for followers of the author
+
+ $author = null;
+
+ if ($scope & Notice::FOLLOWER_SCOPE) {
+
+ try {
+ $author = $this->getProfile();
+ } catch (Exception $e) {
+ return false;
+ }
+
+ if (!Subscription::exists($profile, $author)) {
+ return false;
+ }
- if ($scope & Notice::FOLLOWER_SCOPE) {
- $author = $this->getProfile();
- if (!Subscription::exists($profile, $author)) {
- return false;
+ try {
+ $author = $this->getProfile();
+ } catch(Exception $e) {
+ // If we can't get an author, keep it hidden.
+ // XXX: technically not spam, but, whatever.
+ return true;
+ }
+
+ if ($author->hasRole(Profile_role::SILENCED)) {
+ if (empty($profile) || (($profile->id !== $author->id) && (!$profile->hasRight(Right::REVIEWSPAM)))) {
+ return true;
+ }