]> git.mxchange.org Git - friendica.git/commitdiff
Improved handling with empty user configuration
authorMichael <heluecht@pirati.ca>
Mon, 6 Jun 2022 05:43:24 +0000 (05:43 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 6 Jun 2022 05:43:24 +0000 (05:43 +0000)
src/Navigation/Notifications/Repository/Notification.php
src/Navigation/Notifications/Repository/Notify.php

index e7ef0621145822214b94962a310cd5005bfc4be5..bb835c33e9531e042a7d07d08a2eceb18a8a91ed 100644 (file)
@@ -117,7 +117,13 @@ class Notification extends BaseRepository
         */
        public function selectDetailedForUser(int $uid): Collection\Notifications
        {
-               $condition = ["`type` & ? != 0", $this->pconfig->get($uid, 'system', 'notify_type', 3 | 72 | 4 | 16 | 32) | 128 | 256];
+               $notify_type = $this->pconfig->get($uid, 'system', 'notify_type');
+               if (!is_null($notify_type)) {
+                       $condition = ["`type` & ? != 0", $notify_type | UserNotification::TYPE_SHARED | UserNotification::TYPE_FOLLOW];
+               } else {
+                       $condition = [];
+               }
+
                if (!$this->pconfig->get($uid, 'system', 'notify_like')) {
                        $condition = DBA::mergeConditions($condition, ['NOT `vid` IN (?, ?)', Verb::getID(\Friendica\Protocol\Activity::LIKE), Verb::getID(\Friendica\Protocol\Activity::DISLIKE)]);
                }
@@ -138,7 +144,14 @@ class Notification extends BaseRepository
         */
        public function selectDigestForUser(int $uid): Collection\Notifications
        {
-               $values = [$uid, $this->pconfig->get($uid, 'system', 'notify_type', 3 | 72 | 4 | 16 | 32) | 128 | 256];
+               $values = [$uid];
+
+               $type_condition = '';
+               $notify_type = $this->pconfig->get($uid, 'system', 'notify_type');
+               if (!is_null($notify_type)) {
+                       $type_condition = 'AND `type` & ? != 0';
+                       $values[] = $notify_type | UserNotification::TYPE_SHARED | UserNotification::TYPE_FOLLOW;
+               }
 
                $like_condition = '';
                if (!$this->pconfig->get($uid, 'system', 'notify_like')) {
@@ -159,7 +172,8 @@ class Notification extends BaseRepository
                WHERE `id` IN (
                    SELECT MAX(`id`)
                    FROM `notification`
-                   WHERE `uid` = ? AND `type` & ? != 0
+                   WHERE `uid` = ?
+                       $type_condition
                    $like_condition
                    $announce_condition
                    GROUP BY IFNULL(`parent-uri-id`, `actor-id`)
index 1cfd7ff7401187071f8fa74ff76ecd2db74b00ff..be5c6d731887694ec329299b104e0516962a74ed 100644 (file)
@@ -675,9 +675,14 @@ class Notify extends BaseRepository
                        return true;
                }
 
-               $notify_type = $this->pConfig->get($Notification->uid, 'system', 'notify_type', 3 | 72 | 4 | 16 | 32);
+               $notify_type = $this->pConfig->get($Notification->uid, 'system', 'notify_type');
 
-               if ($notify_type & $Notification->type) {
+               // Fallback for the case when the notify type isn't set at all
+               if (is_null($notify_type) && !in_array($type, [Notification::TYPE_RESHARE, Notification::TYPE_LIKE])) {
+                               return true;
+               }
+
+               if (!is_null($notify_type) && ($notify_type & $Notification->type)) {
                        return true;
                }