]> git.mxchange.org Git - friendica.git/commitdiff
Improved notification for announced posts
authorMichael <heluecht@pirati.ca>
Sun, 23 Jan 2022 21:47:16 +0000 (21:47 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 23 Jan 2022 21:47:16 +0000 (21:47 +0000)
src/Model/Post/UserNotification.php
src/Navigation/Notifications/Factory/Notification.php

index 77aecee290e161f3beabb7d52d68a79d14f13f09..ad7b9c4904b4cb616175e9562b3baedfb9d61d1d 100644 (file)
@@ -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;
        }
 
index b0f57f0e44b824859a4a6039b58f3a6fa88441a2..51885539c566a6d753860a9ca0992682db859b51 100644 (file)
@@ -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;
                        }