Merge pull request #3516 from nextcloud/enh/3485/disable-successful-backup-notifications

This commit is contained in:
Simon L 2023-10-18 13:59:11 +02:00 committed by GitHub
commit 9ac528423e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 4 deletions

View file

@ -49,8 +49,13 @@ class ConfigurationController
} else {
$enableAutomaticUpdates = false;
}
if (isset($request->getParsedBody()['success_notification'])) {
$successNotification = true;
} else {
$successNotification = false;
}
$dailyBackupTime = $request->getParsedBody()['daily_backup_time'] ?? '';
$this->configurationManager->SetDailyBackupTime($dailyBackupTime, $enableAutomaticUpdates);
$this->configurationManager->SetDailyBackupTime($dailyBackupTime, $enableAutomaticUpdates, $successNotification);
}
if (isset($request->getParsedBody()['delete_daily_backup_time'])) {

View file

@ -21,7 +21,11 @@ $nextcloudContainer = $containerDefinitionFetcher->GetContainerById($id);
$backupExitCode = $dockerActionManger->GetBackupcontainerExitCode();
if ($backupExitCode === 0) {
$dockerActionManger->sendNotification($nextcloudContainer, 'Daily backup successful!', 'You can get further info by looking at the backup logs in the AIO interface.');
if (getenv('SEND_SUCCESS_NOTIFICATIONS') === "0") {
error_log("Daily backup successful! Only logging successful backup and not sending backup notification since that has been disabled! You can get further info by looking at the backup logs in the AIO interface.");
} else {
$dockerActionManger->sendNotification($nextcloudContainer, 'Daily backup successful!', 'You can get further info by looking at the backup logs in the AIO interface.');
}
}
if ($backupExitCode > 0) {

View file

@ -676,7 +676,7 @@ class ConfigurationManager
/**
* @throws InvalidSettingConfigurationException
*/
public function SetDailyBackupTime(string $time, bool $enableAutomaticUpdates) : void {
public function SetDailyBackupTime(string $time, bool $enableAutomaticUpdates, bool $successNotification) : void {
if ($time === "") {
throw new InvalidSettingConfigurationException("The daily backup time must not be empty!");
}
@ -688,6 +688,9 @@ class ConfigurationManager
if ($enableAutomaticUpdates === false) {
$time .= PHP_EOL . 'automaticUpdatesAreNotEnabled';
}
if ($successNotification === false) {
$time .= PHP_EOL . 'successNotificationsAreNotEnabled';
}
file_put_contents(DataConst::GetDailyBackupTimeFile(), $time);
}

View file

@ -481,6 +481,7 @@
<input type="hidden" name="{{csrf.keys.value}}" value="{{csrf.value}}">
<input class="button" type="submit" value="Submit backup time" /><br>
<input type="checkbox" id="automatic_updates" name="automatic_updates" checked="checked"><label for="automatic_updates">Automatically update all containers, the mastercontainer and on saturdays your Nextcloud apps</label><br>
<input type="checkbox" id="success_notification" name="success_notification" checked="checked"><label for="success_notification">Send notifications about successful backups (notifications about unsuccessful backups will always be sent)</label><br>
</form>
{% else %}
Daily backups will be created at <b>{{ daily_backup_time }} UTC</b> which includes a notification about the result of the backup.