Update for Xmpp support
This commit is contained in:
parent
61ef313b1c
commit
f3b46515c5
@ -3,9 +3,16 @@ import moment from 'moment'
|
|||||||
|
|
||||||
export const configurationSchema = {
|
export const configurationSchema = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
description: 'an array of emails (receivers)',
|
|
||||||
properties: {
|
properties: {
|
||||||
to: {
|
toMails: {
|
||||||
|
type: 'array',
|
||||||
|
items: {
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
minItems: 1
|
||||||
|
},
|
||||||
|
toXmpp: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
items: {
|
items: {
|
||||||
type: 'string'
|
type: 'string'
|
||||||
@ -23,8 +30,9 @@ class BackupReportsXoPlugin {
|
|||||||
this._report = ::this._wrapper
|
this._report = ::this._wrapper
|
||||||
}
|
}
|
||||||
|
|
||||||
configure ({to}) {
|
configure ({ toMails, toXmpp }) {
|
||||||
this._receivers = to
|
this._mailsReceivers = toMails
|
||||||
|
this._xmppReceivers = toXmpp
|
||||||
}
|
}
|
||||||
|
|
||||||
load () {
|
load () {
|
||||||
@ -108,12 +116,24 @@ class BackupReportsXoPlugin {
|
|||||||
` - Failed backed up VM: ${nCalls - nSuccess}`
|
` - Failed backed up VM: ${nCalls - nSuccess}`
|
||||||
].join('\n'))
|
].join('\n'))
|
||||||
|
|
||||||
|
const markdown = text.join('\n')
|
||||||
|
|
||||||
// TODO : Handle errors when `sendEmail` isn't present. (Plugin dependencies)
|
// TODO : Handle errors when `sendEmail` isn't present. (Plugin dependencies)
|
||||||
await this._xo.sendEmail({
|
|
||||||
to: this._receivers,
|
if (this._xo.sendEmail) {
|
||||||
subject: 'Backup Reports (XenOrchestra)',
|
await this._xo.sendEmail({
|
||||||
markdown: text.join('\n')
|
to: this._mailsReceivers,
|
||||||
})
|
subject: 'Backup Reports (XenOrchestra)',
|
||||||
|
markdown
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._xo.sendToXmppClient) {
|
||||||
|
this._xo.sendToXmppClient({
|
||||||
|
to: this._xmppReceivers,
|
||||||
|
message: markdown
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user