backup notifications show a real title and message instead of "undefined"
This commit is contained in:
1 file changed
+6
-2
@@ -43,6 +43,7 @@ import { EXIT_MARKER } from './restic-script';
|
|||||||
import { parseRetention, buildForgetArgs, checkWouldWipe, retentionActive } from './retention';
|
import { parseRetention, buildForgetArgs, checkWouldWipe, retentionActive } from './retention';
|
||||||
import { liveTargetKey } from './locks';
|
import { liveTargetKey } from './locks';
|
||||||
import type { DiscoveredVolume } from './discovery-core';
|
import type { DiscoveredVolume } from './discovery-core';
|
||||||
|
import { formatBytes } from '../../utils/format';
|
||||||
import { STACKDIR_VOLUME_KEY, type StackDirProbeHint } from './stackdir-plan';
|
import { STACKDIR_VOLUME_KEY, type StackDirProbeHint } from './stackdir-plan';
|
||||||
|
|
||||||
/** What the service needs from the outside world. All injected for testability. */
|
/** What the service needs from the outside world. All injected for testability. */
|
||||||
@@ -467,7 +468,7 @@ export class BackupService {
|
|||||||
const { code, message } = errorInfo(err);
|
const { code, message } = errorInfo(err);
|
||||||
try { await this.ports.setConfigStatus(job.configId, 'failed'); } catch { /* non-fatal */ }
|
try { await this.ports.setConfigStatus(job.configId, 'failed'); } catch { /* non-fatal */ }
|
||||||
await op.close({ kind: 'error', code, message }, { errorCode: code });
|
await op.close({ kind: 'error', code, message }, { errorCode: code });
|
||||||
try { await this.ports.notify('backup_failed', { target: job.targetName, kind: 'backup', errorCode: code, message }, envId); } catch { /* non-fatal */ }
|
try { await this.ports.notify('backup_failed', { title: 'Backup failed', message: `Backup of "${job.targetName}" failed: ${message} (${code})`, type: 'error', target: job.targetName, kind: 'backup', errorCode: code, message }, envId); } catch { /* non-fatal */ }
|
||||||
// Per-config failure webhook.
|
// Per-config failure webhook.
|
||||||
if (job.options.webhookFailure) {
|
if (job.options.webhookFailure) {
|
||||||
try {
|
try {
|
||||||
@@ -561,7 +562,7 @@ export class BackupService {
|
|||||||
const names = failed.map((f) => f.name).join(', ');
|
const names = failed.map((f) => f.name).join(', ');
|
||||||
const msg = `Backup finished but ${names} could not be restarted and is STILL STOPPED — start it manually.`;
|
const msg = `Backup finished but ${names} could not be restarted and is STILL STOPPED — start it manually.`;
|
||||||
op.progress('warning', msg);
|
op.progress('warning', msg);
|
||||||
try { await this.ports.notify('backup_failed', { target: job.targetName, kind: 'backup', errorCode: 'STOPPED_RESTART_FAILED', message: msg }, job.environmentId); } catch { /* non-fatal */ }
|
try { await this.ports.notify('backup_failed', { title: 'Backup: container not restarted', message: msg, type: 'error', target: job.targetName, kind: 'backup', errorCode: 'STOPPED_RESTART_FAILED' }, job.environmentId); } catch { /* non-fatal */ }
|
||||||
} else {
|
} else {
|
||||||
op.progress('restarted', `${job.targetName} restarted.`);
|
op.progress('restarted', `${job.targetName} restarted.`);
|
||||||
}
|
}
|
||||||
@@ -577,6 +578,9 @@ export class BackupService {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await this.ports.notify('backup_success', {
|
await this.ports.notify('backup_success', {
|
||||||
|
title: partial ? 'Backup completed (partial)' : 'Backup completed',
|
||||||
|
message: `Backup of "${job.targetName}" ${partial ? 'completed with warnings' : 'completed successfully'} (snapshot ${summary.snapshotId}, +${formatBytes(summary.dataAdded)})`,
|
||||||
|
type: partial ? 'warning' : 'success',
|
||||||
target: job.targetName, kind: 'backup', snapshotId: summary.snapshotId,
|
target: job.targetName, kind: 'backup', snapshotId: summary.snapshotId,
|
||||||
dataAdded: summary.dataAdded, partial,
|
dataAdded: summary.dataAdded, partial,
|
||||||
}, envId);
|
}, envId);
|
||||||
|
|||||||
Reference in new issue
Block a user