notifications: send email when manual app update is required
This commit is contained in:
@@ -350,6 +350,33 @@ async function pin(type, title, message, options) {
|
||||
return result.id;
|
||||
}
|
||||
|
||||
async function manualAppUpdate(appsNeedingUpdate) {
|
||||
assert(Array.isArray(appsNeedingUpdate));
|
||||
|
||||
const appsNeedingEmail = [];
|
||||
|
||||
for (const app of appsNeedingUpdate) {
|
||||
const message = `Changelog:\n${app.updateInfo.manifest.changelog}\n`;
|
||||
const existing = await getByType(TYPE_MANUAL_APP_UPDATE_NEEDED, app.id);
|
||||
|
||||
if (!existing || (existing.acknowledged && existing.message !== message)) {
|
||||
appsNeedingEmail.push({ title: app.manifest.title, fqdn: app.fqdn, version: app.updateInfo.manifest.version });
|
||||
}
|
||||
|
||||
await pin(TYPE_MANUAL_APP_UPDATE_NEEDED, `${app.manifest.title} at ${app.fqdn} requires manual update to version ${app.updateInfo.manifest.version}`,
|
||||
message, { context: app.id });
|
||||
}
|
||||
|
||||
if (appsNeedingEmail.length === 0) return;
|
||||
|
||||
const admins = await users.getAdmins();
|
||||
for (const admin of admins) {
|
||||
if (admin.notificationConfig.includes(TYPE_MANUAL_UPDATE_REQUIRED)) {
|
||||
await safe(mailer.appManualUpdateRequired(admin.email, appsNeedingEmail), { debug: log });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function unpin(type, options) {
|
||||
assert.strictEqual(typeof type, 'string'); // TYPE_
|
||||
assert.strictEqual(typeof options, 'object');
|
||||
@@ -432,5 +459,6 @@ export default {
|
||||
TYPE_DOMAIN_CONFIG_CHECK_FAILED,
|
||||
pin,
|
||||
unpin,
|
||||
manualAppUpdate,
|
||||
_add: add,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user