fix: maintenance mode not enqeuing notifications

This commit is contained in:
Ben Allfree 2024-01-24 22:16:13 +00:00
parent 197b2f5370
commit bccd1a0d31
2 changed files with 37 additions and 30 deletions

View File

@ -4,12 +4,13 @@ onModelAfterUpdate((e) => {
const newModel = /** @type {models.Record} */ (e.model)
const oldModel = newModel.originalCopy()
const { mkLog, enqueueNotification } = /** @type {Lib} */ (
const { mkLog, enqueueNotification, audit } = /** @type {Lib} */ (
require(`${__hooks}/lib.js`)
)
const log = mkLog(`maintenance-mode`)
try {
// Bail out if we aren't in maintenance mode
const isMaintenance = newModel.get('maintenance')
// log({ isMaintenance })
@ -34,7 +35,7 @@ onModelAfterUpdate((e) => {
const subdomain = newModel.getString(`subdomain`)
const address = user.getString(`email`)
log({ instanceId, subdomain, address })
enqueueNotification(`email`, `maintenance_mode`, uid, {
enqueueNotification(`email`, `maintenance-mode`, uid, {
log,
dao,
message_template_vars: {
@ -42,4 +43,10 @@ onModelAfterUpdate((e) => {
instanceId,
},
})
} catch (e) {
audit('ERROR', `Failed to enqueue template with ${e}`, {
log,
dao,
})
}
}, 'instances')

View File

@ -24,7 +24,7 @@ interface Lib {
enqueueNotification: (
channel: 'email' | 'lemonbot',
template:
| 'maintenance_mode'
| 'maintenance-mode'
| 'lemon_order_email'
| 'lemon_order_discord'
| 'welcome',