diff --git a/www/common/notifications.js b/www/common/notifications.js index 2e4bfce62..20352876c 100644 --- a/www/common/notifications.js +++ b/www/common/notifications.js @@ -90,6 +90,21 @@ define([ } }; + // New support message from the admins + handlers['SUPPORT_MESSAGE'] = function (common, data) { + var content = data.content; + content.getFormatText = function () { + return Messages.support_notification; + }; + content.handler = function () { + common.openURL('/support/'); + defaultDismiss(common, data)(); + }; + if (!content.archived) { + content.dismissHandler = defaultDismiss(common, data); + } + }; + return { add: function (common, data) { var type = data.content.msg.type; diff --git a/www/common/outer/mailbox-handlers.js b/www/common/outer/mailbox-handlers.js index 10e61fb60..6aa919112 100644 --- a/www/common/outer/mailbox-handlers.js +++ b/www/common/outer/mailbox-handlers.js @@ -201,6 +201,14 @@ define([ } }; + // Hide duplicates when receiving a SUPPORT_MESSAGE notification + var supportMessage = false; + handlers['SUPPORT_MESSAGE'] = function (ctx, box, data, cb) { + if (supportMessage) { return void cb(true); } + supportMessage = true; + cb(); + }; + return { add: function (ctx, box, data, cb) { /** diff --git a/www/support/ui.js b/www/support/ui.js index 903a86167..8a66e7886 100644 --- a/www/support/ui.js +++ b/www/support/ui.js @@ -37,6 +37,13 @@ define([ channel: dest.channel, curvePublic: dest.curvePublic }); + + if (ctx.isAdmin) { + common.mailbox.sendTo('SUPPORT_MESSAGE', {}, { + channel: dest.notifications, + curvePublic: dest.curvePublic + }); + } }; var sendForm = function (ctx, id, form, dest) {