]> git.mxchange.org Git - friendica.git/commitdiff
Don't create notify for deleted user accounts
authorHypolite Petovan <hypolite@mrpetovan.com>
Sat, 12 Nov 2022 15:00:29 +0000 (10:00 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 14 Nov 2022 22:02:42 +0000 (17:02 -0500)
src/Navigation/Notifications/Repository/Notify.php

index 52c51fcb8ebdf3f7f6217ae67e85d5f2ffd68d4c..683725e4ba97856a199d096d4d226071d02a6a76 100644 (file)
@@ -230,7 +230,7 @@ class Notify extends BaseRepository
                }
 
                // Ensure that the important fields are set at any time
-               $fields = ['nickname', 'account-type', 'notify-flags', 'language', 'username', 'email'];
+               $fields = ['nickname', 'account-type', 'notify-flags', 'language', 'username', 'email', 'account_removed', 'account_expired'];
                $user = DBA::selectFirst('user', $fields, ['uid' => $params['uid']]);
 
                if (!DBA::isResult($user)) {
@@ -238,6 +238,10 @@ class Notify extends BaseRepository
                        return false;
                }
 
+               if ($user['account_removed'] || $user['account_expired']) {
+                       return false;
+               }
+
                // There is no need to create notifications for forum accounts
                if ($user['account-type'] == Model\User::ACCOUNT_TYPE_COMMUNITY) {
                        return false;
@@ -503,7 +507,7 @@ class Notify extends BaseRepository
                                                $tsitelink = sprintf($sitelink, $params['link']);
                                                $hsitelink = sprintf($sitelink, '<a href="' . $params['link'] . '">' . $sitename . '</a><br><br>');
                                                break;
-       
+
                                        case 'SYSTEM_DB_UPDATE_FAIL': // @TODO Unused (only here)
                                                break;
                                }
@@ -525,8 +529,11 @@ class Notify extends BaseRepository
                $parent_uri_id = $params['item']['parent-uri-id'] ?? null;
 
                // Ensure that the important fields are set at any time
-               $fields = ['nickname'];
+               $fields = ['nickname', 'account_removed', 'account_expired'];
                $user = Model\User::getById($params['uid'], $fields);
+               if ($user['account_removed'] || $user['user_expired']) {
+                       return false;
+               }
 
                $sitename = $this->config->get('config', 'sitename');
 
@@ -711,6 +718,9 @@ class Notify extends BaseRepository
                $params['otype'] = Model\Notification\ObjectType::ITEM;
 
                $user = Model\User::getById($Notification->uid);
+               if ($user['account_removed'] || $user['account_expired']) {
+                       return false;
+               }
 
                $params['notify_flags'] = $user['notify-flags'];
                $params['language']     = $user['language'];