diff --git a/src/mailer.js b/src/mailer.js index 4546098f1..737c0373b 100644 --- a/src/mailer.js +++ b/src/mailer.js @@ -296,9 +296,10 @@ function appDied(mailTo, app) { }); } -function appUpdated(mailTo, app) { +function appUpdated(mailTo, app, callback) { assert.strictEqual(typeof mailTo, 'string'); assert.strictEqual(typeof app, 'object'); + callback = callback || NOOP_CALLBACK; debug('Sending mail for app %s @ %s updated', app.id, app.fqdn); @@ -312,7 +313,7 @@ function appUpdated(mailTo, app) { text: render('app_updated.ejs', { title: app.manifest.title, appFqdn: app.fqdn, version: app.manifest.version, format: 'text' }) }; - sendMail(mailOptions); + sendMail(mailOptions, callback); }); } diff --git a/src/notifications.js b/src/notifications.js index de3a11f3b..d792b58ac 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -236,8 +236,14 @@ function appUpdated(eventId, app, callback) { assert.strictEqual(typeof callback, 'function'); actionForAllAdmins([], function (admin, done) { - mailer.appUpdated(admin.email, app); - add(admin.id, eventId, `App ${app.fqdn} updated`, `The application ${app.manifest.title} installed at https://${app.fqdn} was updated to package version ${app.manifest.version}.`, done); + add(admin.id, eventId, `App ${app.fqdn} updated`, `The application ${app.manifest.title} installed at https://${app.fqdn} was updated to package version ${app.manifest.version}.`, function (error) { + if (error) return callback(error); + + mailer.appUpdated(admin.email, app, function (error) { + if (error) console.error('Failed to send app updated email', error); // non fatal + done(); + }); + }); }, callback); }