}
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
}
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]);
}
}
* @return Activity activity object representing this Notice.
*/
- function asActivity($cur)
+ function asActivity($cur=null)
{
$act = self::cacheGet(Cache::codeKey('notice:as-activity:'.$this->id));
$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();
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);
}
$attachments = $this->attachments();
foreach ($attachments as $attachment) {
- $enclosure = $attachment->getEnclosure();
- if ($enclosure) {
- $act->enclosures[] = $enclosure;
+ // Save local attachments
+ if (!empty($attachment->filename)) {
+ $act->attachments[] = ActivityObject::fromFile($attachment);
}
}
$rprofile = Profile::staticGet('id', $id);
if (!empty($rprofile)) {
$ctx->attention[] = $rprofile->getUri();
+ $ctx->attentionType[$rprofile->getUri()] = ActivityObject::PERSON;
}
}
foreach ($groups as $group) {
$ctx->attention[] = $group->getUri();
+ $ctx->attentionType[$group->getUri()] = ActivityObject::GROUP;
+ }
+
+ switch ($this->scope) {
+ case Notice::PUBLIC_SCOPE:
+ $ctx->attention[] = "http://activityschema.org/collection/public";
+ $ctx->attentionType["http://activityschema.org/collection/public"] = ActivityObject::COLLECTION;
+ break;
+ case Notice::FOLLOWER_SCOPE:
+ $surl = common_local_url("subscribers", array('nickname' => $profile->nickname));
+ $ctx->attention[] = $surl;
+ $ctx->attentionType[$surl] = ActivityObject::COLLECTION;
+ break;
}
// XXX: deprecated; use ActivityVerb::SHARE instead
$act->context = $ctx;
+ $source = $this->getSource();
+
+ if ($source) {
+ $act->generator = ActivityObject::fromNoticeSource($source);
+ }
+
// Source
$atom_feed = $profile->getAtomFeed();
if ($scope & Notice::FOLLOWER_SCOPE) {
- $author = $this->getProfile();
+ try {
+ $author = $this->getProfile();
+ } catch (Exception $e) {
+ return false;
+ }
if (!Subscription::exists($profile, $author)) {
return false;
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->hasRole(Profile_role::MODERATOR)) {
+ if (empty($profile) || (($profile->id !== $author->id) && (!$profile->hasRight(Right::REVIEWSPAM)))) {
return true;
}
}