trigger pusher on system messages too

This commit is contained in:
Matteo Pagliazzi
2016-09-07 17:18:48 +02:00
parent 41079a65c6
commit 7ea9debe3f

View File

@@ -351,6 +351,12 @@ schema.methods.sendChat = function sendChat (message, user) {
User.update(query, lastSeenUpdate, {multi: true}).exec();
// If the message being sent is a system message (not gone through the api.postChat controller)
// then notify Pusher about it (only parties for now)
if (newMessage.uuid === 'system' && this.privacy === 'private' && this.type === 'party') {
pusher.trigger(`presence-group-${this._id}`, 'new-chat', newMessage);
}
return newMessage;
};