Don't create notify for deleted user accounts

This commit is contained in:
Hypolite Petovan 2022-11-12 10:00:29 -05:00
parent 48b1dceb19
commit cbe8d463b1
1 changed files with 13 additions and 3 deletions

View 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'];