Add option to send mails ASAP aka with next cron run

Signed-off-by: t2d <td@tem.li>
This commit is contained in:
t2d 2017-08-10 15:53:25 +02:00
Родитель 09717ef4eb
Коммит 14af75cd8b
6 изменённых файлов: 14 добавлений и 0 удалений

Просмотреть файл

@ -97,6 +97,8 @@ class SendEmails extends Command {
$restrictEmails = UserSettings::EMAIL_SEND_DAILY;
} else if ($restrictBatching === 'weekly') {
$restrictEmails = UserSettings::EMAIL_SEND_WEEKLY;
} else if ($restrictBatching === 'asap') {
$restrictEmails = UserSettings::EMAIL_SEND_ASAP;
} else {
$restrictEmails = null;
}

Просмотреть файл

@ -128,6 +128,8 @@ class Settings extends Controller {
$email_batch_time = 3600 * 24;
} else if ($notify_setting_batchtime === UserSettings::EMAIL_SEND_WEEKLY) {
$email_batch_time = 3600 * 24 * 7;
} else if ($notify_setting_batchtime === UserSettings::EMAIL_SEND_ASAP) {
$email_batch_time = 0;
}
$this->config->setUserValue(
@ -188,6 +190,8 @@ class Settings extends Controller {
$email_batch_time = 3600 * 24;
} else if ($notify_setting_batchtime === UserSettings::EMAIL_SEND_WEEKLY) {
$email_batch_time = 3600 * 24 * 7;
} else if ($notify_setting_batchtime === UserSettings::EMAIL_SEND_ASAP) {
$email_batch_time = 0;
}
$this->config->setAppValue(
@ -258,6 +262,8 @@ class Settings extends Controller {
$settingBatchTime = UserSettings::EMAIL_SEND_WEEKLY;
} else if ($currentSetting === 3600 * 24) {
$settingBatchTime = UserSettings::EMAIL_SEND_DAILY;
} else if ($currentSetting === 0) {
$settingBatchTime = UserSettings::EMAIL_SEND_ASAP;
}
return new TemplateResponse('activity', 'settings/personal', [

Просмотреть файл

@ -231,6 +231,8 @@ class MailQueueHandler {
$query->where($query->expr()->eq('amq_timestamp', $query->createFunction($query->getColumnName('amq_latest_send') . ' + ' . 3600 * 24)));
} else if ($restrictEmails === UserSettings::EMAIL_SEND_WEEKLY) {
$query->where($query->expr()->eq('amq_timestamp', $query->createFunction($query->getColumnName('amq_latest_send') . ' + ' . 3600 * 24 * 7)));
} else if ($restrictEmails === UserSettings::EMAIL_SEND_ASAP) {
$query->where($query->expr()->eq('amq_timestamp', 'amq_latest_send'));
}
}

Просмотреть файл

@ -101,6 +101,8 @@ class Admin implements ISettings {
$settingBatchTime = UserSettings::EMAIL_SEND_WEEKLY;
} else if ($currentSetting === 3600 * 24) {
$settingBatchTime = UserSettings::EMAIL_SEND_DAILY;
} else if ($currentSetting === 0) {
$settingBatchTime = UserSettings::EMAIL_SEND_ASAP;
}
return new TemplateResponse('activity', 'settings/admin', [

Просмотреть файл

@ -43,6 +43,7 @@ class UserSettings {
const EMAIL_SEND_HOURLY = 0;
const EMAIL_SEND_DAILY = 1;
const EMAIL_SEND_WEEKLY = 2;
const EMAIL_SEND_ASAP = 3;
/**
* @param IManager $manager

Просмотреть файл

@ -84,6 +84,7 @@
<br />
<label for="notify_setting_batchtime"><?php p($l->t('Send emails:')); ?></label>
<select id="notify_setting_batchtime" name="notify_setting_batchtime">
<option value="3"<?php if ($_['setting_batchtime'] === \OCA\Activity\UserSettings::EMAIL_SEND_ASAP): ?> selected="selected"<?php endif; ?>><?php p($l->t('As soon as possible')); ?></option>
<option value="0"<?php if ($_['setting_batchtime'] === \OCA\Activity\UserSettings::EMAIL_SEND_HOURLY): ?> selected="selected"<?php endif; ?>><?php p($l->t('Hourly')); ?></option>
<option value="1"<?php if ($_['setting_batchtime'] === \OCA\Activity\UserSettings::EMAIL_SEND_DAILY): ?> selected="selected"<?php endif; ?>><?php p($l->t('Daily')); ?></option>
<option value="2"<?php if ($_['setting_batchtime'] === \OCA\Activity\UserSettings::EMAIL_SEND_WEEKLY): ?> selected="selected"<?php endif; ?>><?php p($l->t('Weekly')); ?></option>