X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FNotice.php;h=3891f431e460a04cd947e80edfb78dba3d8b43d3;hb=15d466ebe6576aa34efa7d4b5bb008e0d2cbc116;hp=fc1a941679481e5ba2bef9c5a24e5e01a87544bf;hpb=a51d2ece50ebb2eed4321c08d76cacbd053b3149;p=quix0rs-gnu-social.git diff --git a/classes/Notice.php b/classes/Notice.php index fc1a941679..3891f431e4 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -645,7 +645,7 @@ class Notice extends Managed_DataObject } self::blow('notice:list-ids:conversation:%s', $this->conversation); - self::blow('conversation::notice_count:%d', $this->conversation); + self::blow('conversation:notice_count:%d', $this->conversation); if (!empty($this->repeat_of)) { // XXX: we should probably only use one of these @@ -1031,9 +1031,15 @@ class Notice extends Managed_DataObject } foreach ($ni as $id => $source) { - $user = User::staticGet('id', $id); - if (empty($user) || $user->hasBlocked($profile) || - ($originalProfile && $user->hasBlocked($originalProfile))) { + try { + $user = User::staticGet('id', $id); + if (empty($user) || + $user->hasBlocked($profile) || + ($originalProfile && $user->hasBlocked($originalProfile))) { + unset($ni[$id]); + } + } catch (UserNoProfileException $e) { + // User doesn't have a profile; invalid; skip them. unset($ni[$id]); } } @@ -1487,7 +1493,7 @@ class Notice extends Managed_DataObject * @return Activity activity object representing this Notice. */ - function asActivity($cur) + function asActivity($cur=null) { $act = self::cacheGet(Cache::codeKey('notice:as-activity:'.$this->id)); @@ -1502,7 +1508,6 @@ class Notice extends Managed_DataObject $act->time = strtotime($this->created); $act->link = $this->bestUrl(); $act->content = common_xml_safe_str($this->rendered); - $act->title = common_xml_safe_str($this->content); $profile = $this->getProfile(); @@ -1513,7 +1518,9 @@ class Notice extends Managed_DataObject if ($this->repeat_of) { $repeated = Notice::staticGet('id', $this->repeat_of); - $act->objects[] = $repeated->asActivity($cur); + if (!empty($repeated)) { + $act->objects[] = $repeated->asActivity($cur); + } } else { $act->objects[] = ActivityObject::fromNotice($this); } @@ -2452,7 +2459,11 @@ class Notice extends Managed_DataObject if ($scope & Notice::FOLLOWER_SCOPE) { - $author = $this->getProfile(); + try { + $author = $this->getProfile(); + } catch (Exception $e) { + return false; + } if (!Subscription::exists($profile, $author)) { return false; @@ -2469,10 +2480,16 @@ class Notice extends Managed_DataObject if (common_config('notice', 'hidespam')) { - $author = $this->getProfile(); + 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->hasRight(Right::REVIEWSPAM)) { + if (empty($profile) || (($profile->id !== $author->id) && (!$profile->hasRight(Right::REVIEWSPAM)))) { return true; } }