Skip to content

Commit

Permalink
Merge pull request #181 from nextcloud/issue-178-no-emails-for-disabl…
Browse files Browse the repository at this point in the history
…ed-users

Don't send emails to disabled users
  • Loading branch information
nickvergessen authored Aug 2, 2017
2 parents 0505686 + 253054d commit 982d226
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/MailQueueHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public function sendEmails($limit, $sendTime, $forceSending = false, $restrictEm
$userLanguages = $this->config->getUserValueForUsers('core', 'lang', $affectedUsers);
$userTimezones = $this->config->getUserValueForUsers('core', 'timezone', $affectedUsers);
$userEmails = $this->config->getUserValueForUsers('settings', 'email', $affectedUsers);
$userEnabled = $this->config->getUserValueForUsers('core', 'enabled', $affectedUsers);

// Send Email
$default_lang = $this->config->getSystemValue('default_language', 'en');
Expand All @@ -163,10 +164,16 @@ public function sendEmails($limit, $sendTime, $forceSending = false, $restrictEm
$deleteItemsForUsers = [];
$this->activityManager->setRequirePNG(true);
foreach ($affectedUsers as $user) {
if (isset($userEnabled[$user]) && $userEnabled[$user] === 'no') {
$deleteItemsForUsers[] = $user;
continue;
}

if (empty($userEmails[$user])) {
// The user did not setup an email address
// So we will not send an email :(
$this->logger->debug("Couldn't send notification email to user '{user}' (email address isn't set for that user)", ['user' => $user, 'app' => 'activity']);
$deleteItemsForUsers[] = $user;
continue;
}

Expand Down

0 comments on commit 982d226

Please sign in to comment.