mirror of
https://github.com/moparisthebest/kaiwa
synced 2024-11-05 17:15:04 -05:00
Notify all users of the room with '@all'
This commit is contained in:
parent
4af8998da9
commit
3edfe3da21
@ -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('<span class="mention">' + existing + '</span>');
|
||||
}
|
||||
@ -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;
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user