Do notifications after message edits.

If a message edit causes a message to become notifiable, we send
a notification to the user, but only if they haven't had any previous
notifications for this message.

(imported from commit cee854de2d42c31a7352a350f79490caf94b613c)
This commit is contained in:
Steve Howell
2014-01-08 16:02:02 -05:00
committed by Waseem Daher
parent 117915edc5
commit 813fc05b5b
2 changed files with 10 additions and 0 deletions

View File

@@ -321,6 +321,13 @@ function message_is_notifiable(message) {
if (message.sent_by_me) {
return false;
}
// If a message is edited multiple times, we want to err on the side of
// not spamming notifications.
if (message.notification_sent) {
return false;
}
// @-mentions take precent over muted-ness. See Trac #1929
if (exports.speaking_at_me(message)) {
return true;
@@ -362,6 +369,8 @@ exports.received_messages = function (messages) {
return;
}
message.notification_sent = true;
if (page_params.desktop_notifications_enabled &&
browser_desktop_notifications_on()) {
process_notification({message: message, webkit_notify: true});

View File

@@ -761,6 +761,7 @@ function update_messages(events) {
msg.last_edit_timestamp = event.edit_timestamp;
delete msg.last_edit_timestr;
notifications.received_messages([msg]);
alert_words.process_message(msg);
});