From 3edfe3da21c168e3aac58824ec5ab53057260954 Mon Sep 17 00:00:00 2001 From: Sebastien Hut Date: Sun, 1 Feb 2015 23:44:09 +0100 Subject: [PATCH] Notify all users of the room with '@all' --- clientapp/models/message.js | 6 +++--- clientapp/models/muc.js | 13 ++++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/clientapp/models/message.js b/clientapp/models/message.js index 1b63773..990efa0 100644 --- a/clientapp/models/message.js +++ b/clientapp/models/message.js @@ -113,8 +113,8 @@ var Message = module.exports = HumanModel.define({ body = body.substr(4); } body = htmlify.toHTML(body); - if (this.mentions) { - var existing = htmlify.toHTML(this.mentions); + for (var i = 0; i < this.mentions.length; i++) { + var existing = htmlify.toHTML(this.mentions[i]); var parts = body.split(existing); body = parts.join('' + existing + ''); } @@ -202,7 +202,7 @@ var Message = module.exports = HumanModel.define({ receiptReceived: ['bool', true, false], edited: ['bool', true, false], delay: 'object', - mentions: ['string', false, ''] + mentions: ['array', false, []] }, correct: function (msg) { if (this.from.full !== msg.from.full) return false; diff --git a/clientapp/models/muc.js b/clientapp/models/muc.js index 03404ac..17f9b66 100644 --- a/clientapp/models/muc.js +++ b/clientapp/models/muc.js @@ -85,14 +85,21 @@ module.exports = HumanModel.define({ if (mine) { message._mucMine = true; } - if (!mine && message.body.toLowerCase().indexOf(this.nick.toLowerCase()) >= 0) { - message.mentions = this.nick; + else { + var mentions = []; + if (message.body.toLowerCase().indexOf('@' + this.nick.toLowerCase()) >= 0) { + mentions.push('@' + this.nick); + } + if (message.body.toLowerCase().indexOf('@all') >= 0) { + mentions.push('@all'); + } + message.mentions = mentions; } var localTime = new Date(); if (Math.round((localTime - message.created) / 1000) < 5 && notify && (!this.activeContact || (this.activeContact && !app.state.focused)) && !mine) { this.unreadCount++; - if (message.mentions) { + if (message.mentions.length) { app.notifications.create(this.displayName, { body: message.body, icon: this.avatar,