return true;
}
- // The following check doesn't make sense on activities, so quit here
- if ($item['verb'] == Activity::ANNOUNCE) {
- return false;
- }
-
- // Check if the contact is a mentioned forum
- $tags = DBA::select('tag-view', ['url'], ['uri-id' => $item['uri-id'], 'type' => [Tag::MENTION, Tag::EXCLUSIVE_MENTION]]);
- while ($tag = DBA::fetch($tags)) {
- $condition = ['nurl' => Strings::normaliseLink($tag['url']), 'uid' => $uid, 'notify_new_posts' => true, 'contact-type' => Contact::TYPE_COMMUNITY];
- if (DBA::exists('contact', $condition)) {
- return true;
- }
- }
- DBA::close($tags);
-
return false;
}
return $message;
}
- if ($Notification->verb == Activity::POST) {
+ if (($Notification->verb == Activity::POST) ||
+ (($Notification->type === Post\UserNotification::TYPE_SHARED) && ($Notification->verb == Activity::ANNOUNCE))) {
$item = Post::selectFirst([], ['uri-id' => $item['thr-parent-id'], 'uid' => [0, $Notification->uid]], ['order' => ['uid' => true]]);
if (empty($item)) {
$this->logger->info('Thread parent post not found', ['uri-id' => $item['thr-parent-id']]);
}
}
- if ($item['owner-id'] != $item['author-id']) {
- $cid = $item['owner-id'];
- }
- if (!empty($item['causer-id']) && ($item['causer-id'] != $item['author-id'])) {
- $cid = $item['causer-id'];
- }
-
- if (($Notification->type === Post\UserNotification::TYPE_SHARED) && !empty($cid)) {
- $causer = Contact::getById($cid, ['id', 'name', 'url']);
- if (empty($causer)) {
- $this->logger->info('Causer not found', ['causer' => $cid]);
+ if ($Notification->type === Post\UserNotification::TYPE_SHARED) {
+ $author = Contact::getById($item['author-id'], ['id', 'name', 'url']);
+ if (empty($author)) {
+ $this->logger->info('Author not found', ['author' => $item['author-id']]);
return $message;
}
} elseif (in_array($Notification->type, [Post\UserNotification::TYPE_COMMENT_PARTICIPATION, Post\UserNotification::TYPE_ACTIVITY_PARTICIPATION])) {
case Post\UserNotification::TYPE_DIRECT_THREAD_COMMENT:
$msg = $userL10n->t('%1$s commented on your thread %2$s');
break;
-
- case Post\UserNotification::TYPE_SHARED:
- if (($causer['id'] != $author['id']) && ($title != '')) {
- $msg = $userL10n->t('%1$s shared the post %2$s from %3$s');
- } elseif ($causer['id'] != $author['id']) {
- $msg = $userL10n->t('%1$s shared a post from %3$s');
- } elseif ($title != '') {
- $msg = $userL10n->t('%1$s shared the post %2$s');
- } else {
- $msg = $userL10n->t('%1$s shared a post');
- }
- break;
}
break;
}