From: Michael Date: Sun, 23 Jan 2022 21:47:16 +0000 (+0000) Subject: Improved notification for announced posts X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=27a306185ab4684d957a63f2155e68fa3cc0dd76;p=friendica.git Improved notification for announced posts --- diff --git a/src/Model/Post/UserNotification.php b/src/Model/Post/UserNotification.php index 77aecee290..ad7b9c4904 100644 --- a/src/Model/Post/UserNotification.php +++ b/src/Model/Post/UserNotification.php @@ -406,21 +406,6 @@ class UserNotification 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; } diff --git a/src/Navigation/Notifications/Factory/Notification.php b/src/Navigation/Notifications/Factory/Notification.php index b0f57f0e44..51885539c5 100644 --- a/src/Navigation/Notifications/Factory/Notification.php +++ b/src/Navigation/Notifications/Factory/Notification.php @@ -114,7 +114,8 @@ class Notification extends BaseFactory implements ICanCreateFromTableRow 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']]); @@ -123,17 +124,10 @@ class Notification extends BaseFactory implements ICanCreateFromTableRow } } - 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])) { @@ -231,18 +225,6 @@ class Notification extends BaseFactory implements ICanCreateFromTableRow 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; }