Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't send emails to disabled users #181

Merged
merged 2 commits into from
Aug 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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