|
|
|
@ -1,9 +1,21 @@ |
|
|
|
|
/* globals KonchatNotification, fireGlobalEvent, readMessage */ |
|
|
|
|
/* globals KonchatNotification, fireGlobalEvent, readMessage, CachedChatSubscription */ |
|
|
|
|
|
|
|
|
|
// Show notifications and play a sound for new messages.
|
|
|
|
|
// We trust the server to only send notifications for interesting messages, e.g. direct messages or
|
|
|
|
|
// group messages in which the user is mentioned.
|
|
|
|
|
|
|
|
|
|
function notifyNewRoom(sub) { |
|
|
|
|
|
|
|
|
|
// Do not play new room sound if user is busy
|
|
|
|
|
if (Session.equals(`user_${ Meteor.userId() }_status`, 'busy')) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!(FlowRouter.getParam('name') && FlowRouter.getParam('name') === sub.name) && !sub.ls && sub.alert === true) { |
|
|
|
|
return KonchatNotification.newRoom(sub.rid); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Meteor.startup(function() { |
|
|
|
|
Tracker.autorun(function() { |
|
|
|
|
if (Meteor.userId()) { |
|
|
|
@ -56,15 +68,14 @@ Meteor.startup(function() { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
RocketChat.Notifications.onUser('subscriptions-changed', function(action, sub) { |
|
|
|
|
// Do not play new room sound if user is busy
|
|
|
|
|
if (Session.equals(`user_${ Meteor.userId() }_status`, 'busy')) { |
|
|
|
|
return; |
|
|
|
|
CachedChatSubscription.onSyncData = function(action, sub) { |
|
|
|
|
if (action === 'changed') { |
|
|
|
|
notifyNewRoom(sub); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if (!(FlowRouter.getParam('name') && FlowRouter.getParam('name') === sub.name) && !sub.ls && sub.alert === true) { |
|
|
|
|
return KonchatNotification.newRoom(sub.rid); |
|
|
|
|
} |
|
|
|
|
RocketChat.Notifications.onUser('subscriptions-changed', (action, sub) => { |
|
|
|
|
notifyNewRoom(sub); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|