Make sure we track restore/backlog success logs as well.

This commit is contained in:
Guo Xiang Tan 2016-08-03 16:18:35 +08:00
parent b860d1b254
commit adc8336949
4 changed files with 27 additions and 9 deletions

View file

@ -1882,9 +1882,16 @@ en:
backup_succeeded:
subject_template: "Backup completed successfully"
text_body_template: "The backup was successful.
text_body_template: |
The backup was successful.
Visit the [admin > backup section](%{base_url}/admin/backups) to download your new backup."
Visit the [admin > backup section](%{base_url}/admin/backups) to download your new backup."
Here's the log:
```text
%{logs}
```
backup_failed:
subject_template: "Backup failed"
@ -1893,13 +1900,20 @@ en:
Here's the log:
```
```text
%{logs}
```
restore_succeeded:
subject_template: "Restore completed successfully"
text_body_template: "The restore was successful."
text_body_template: |
The restore was successful.
Here's the log:
```text
%{logs}
```
restore_failed:
subject_template: "Restore failed"
@ -1908,7 +1922,7 @@ en:
Here's the log:
```
```text
%{logs}
```

View file

@ -260,9 +260,9 @@ module BackupRestore
def notify_user
log "Notifying '#{@user.username}' of the end of the backup..."
if @success
SystemMessage.create_from_system_user(@user, :backup_succeeded)
SystemMessage.create_from_system_user(@user, :backup_succeeded, logs: pretty_logs(@logs))
else
SystemMessage.create_from_system_user(@user, :backup_failed, logs: @logs.join("\n"))
SystemMessage.create_from_system_user(@user, :backup_failed, logs: pretty_logs(@logs))
end
end

View file

@ -378,9 +378,9 @@ module BackupRestore
if user = User.find_by(email: @user_info[:email])
log "Notifying '#{user.username}' of the end of the restore..."
if @success
SystemMessage.create_from_system_user(user, :restore_succeeded)
SystemMessage.create_from_system_user(user, :restore_succeeded, logs: pretty_logs(@logs))
else
SystemMessage.create_from_system_user(user, :restore_failed, logs: @logs.join("\n"))
SystemMessage.create_from_system_user(user, :restore_failed, logs: pretty_logs(@logs))
end
else
log "Could not send notification to '#{@user_info[:username]}' (#{@user_info[:email]}), because the user does not exists..."

View file

@ -10,5 +10,9 @@ module BackupRestore
output
end
def pretty_logs(logs)
logs.join("\n")
end
end
end