]> git.mxchange.org Git - friendica.git/commitdiff
Don't create notifications for own posts
authorMichael <heluecht@pirati.ca>
Sun, 5 Jan 2020 09:48:31 +0000 (09:48 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 5 Jan 2020 09:48:31 +0000 (09:48 +0000)
src/Model/UserItem.php

index 029e7afb629f77e9de118d0c8185d7a6ca867d87..698176454dd3f4219238c0f4775cfa551e03584b 100644 (file)
@@ -31,8 +31,7 @@ class UserItem
         */
        public static function setNotification(int $iid)
        {
-               $fields = ['id', 'uid', 'body', 'parent', 'gravity', 'tag', 'contact-id',
-                       'thr-parent', 'parent-uri', 'mention'];
+               $fields = ['id', 'uid', 'body', 'parent', 'gravity', 'tag', 'contact-id', 'thr-parent', 'author-id'];
                $item = Item::selectFirst($fields, ['id' => $iid, 'origin' => false]);
                if (!DBA::isResult($item)) {
                        return;
@@ -56,8 +55,7 @@ class UserItem
         */
        private static function setNotificationForUser(array $item, int $uid)
        {
-               $fields = ['ignored', 'mention'];
-               $thread = Item::selectFirstThreadForUser($uid, $fields, ['iid' => $item['parent'], 'deleted' => false]);
+               $thread = Item::selectFirstThreadForUser($uid, ['ignored'], ['iid' => $item['parent'], 'deleted' => false]);
                if ($thread['ignored']) {
                        return;
                }
@@ -70,14 +68,6 @@ class UserItem
 
                $profiles = self::getProfileForUser($uid);
 
-               if (self::checkImplicitMention($item, $uid, $profiles)) {
-                       $notification_type = $notification_type | self::NOTIF_IMPLICIT_TAGGED;
-               }
-
-               if (self::checkExplicitMention($item, $uid, $profiles)) {
-                       $notification_type = $notification_type | self::NOTIF_EXPLICIT_TAGGED;
-               }
-
                // Fetch all contacts for the given profiles
                $contacts = [];
                $ret = DBA::select('contact', ['id'], ['uid' => 0, 'nurl' => $profiles]);
@@ -86,6 +76,19 @@ class UserItem
                }
                DBA::close($ret);
 
+               // Don't create notifications for user's posts
+               if (in_array($item['author-id'], $contacts)) {
+                       return;
+               }
+
+               if (self::checkImplicitMention($item, $uid, $profiles)) {
+                       $notification_type = $notification_type | self::NOTIF_IMPLICIT_TAGGED;
+               }
+
+               if (self::checkExplicitMention($item, $uid, $profiles)) {
+                       $notification_type = $notification_type | self::NOTIF_EXPLICIT_TAGGED;
+               }
+
                if (self::checkCommentedThread($item, $uid, $contacts)) {
                        $notification_type = $notification_type | self::NOTIF_THREAD_COMMENT;
                }