feat(xo-server-backup-reports): error when transports not enabled
This commit is contained in:
parent
3f8436b58b
commit
2e689592f1
@ -32,6 +32,7 @@
|
|||||||
- @xen-orchestra/mixins minor
|
- @xen-orchestra/mixins minor
|
||||||
- @xen-orchestra/xapi minor
|
- @xen-orchestra/xapi minor
|
||||||
- xo-server minor
|
- xo-server minor
|
||||||
|
- xo-server-backup-reports minor
|
||||||
- xo-web minor
|
- xo-web minor
|
||||||
|
|
||||||
<!--packages-end-->
|
<!--packages-end-->
|
||||||
|
@ -595,24 +595,28 @@ class BackupReportsXoPlugin {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
_sendReport({ mailReceivers, markdown, subject, success }) {
|
async _sendReport({ mailReceivers, markdown, subject, success }) {
|
||||||
if (mailReceivers === undefined || mailReceivers.length === 0) {
|
if (mailReceivers === undefined || mailReceivers.length === 0) {
|
||||||
mailReceivers = this._mailsReceivers
|
mailReceivers = this._mailsReceivers
|
||||||
}
|
}
|
||||||
|
|
||||||
const xo = this._xo
|
const xo = this._xo
|
||||||
return Promise.all([
|
const promises = [
|
||||||
xo.sendEmail !== undefined &&
|
mailReceivers !== undefined &&
|
||||||
xo.sendEmail({
|
(xo.sendEmail === undefined
|
||||||
to: mailReceivers,
|
? Promise.reject(new Error('transport-email plugin not enabled'))
|
||||||
subject,
|
: xo.sendEmail({
|
||||||
markdown,
|
to: mailReceivers,
|
||||||
}),
|
subject,
|
||||||
xo.sendToXmppClient !== undefined &&
|
markdown,
|
||||||
xo.sendToXmppClient({
|
})),
|
||||||
to: this._xmppReceivers,
|
this._xmppReceivers !== undefined &&
|
||||||
message: markdown,
|
(xo.sendEmail === undefined
|
||||||
}),
|
? Promise.reject(new Error('transport-xmpp plugin not enabled'))
|
||||||
|
: xo.sendToXmppClient({
|
||||||
|
to: this._xmppReceivers,
|
||||||
|
message: markdown,
|
||||||
|
})),
|
||||||
xo.sendSlackMessage !== undefined &&
|
xo.sendSlackMessage !== undefined &&
|
||||||
xo.sendSlackMessage({
|
xo.sendSlackMessage({
|
||||||
message: markdown,
|
message: markdown,
|
||||||
@ -622,7 +626,22 @@ class BackupReportsXoPlugin {
|
|||||||
status: success ? 'OK' : 'CRITICAL',
|
status: success ? 'OK' : 'CRITICAL',
|
||||||
message: markdown,
|
message: markdown,
|
||||||
}),
|
}),
|
||||||
])
|
]
|
||||||
|
|
||||||
|
const errors = []
|
||||||
|
const pushError = errors.push.bind(errors)
|
||||||
|
|
||||||
|
await Promise.all(promises.filter(Boolean).map(_ => _.catch(pushError)))
|
||||||
|
|
||||||
|
if (errors.length !== 0) {
|
||||||
|
throw new AggregateError(
|
||||||
|
errors,
|
||||||
|
errors
|
||||||
|
.map(_ => _.message)
|
||||||
|
.filter(_ => _ != null && _.length !== 0)
|
||||||
|
.join(', ')
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_legacyVmHandler(status) {
|
_legacyVmHandler(status) {
|
||||||
|
Loading…
Reference in New Issue
Block a user