From c1af73a29145120ffdddd4e803979b196d0f2f23 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Mon, 30 Mar 2020 17:24:19 -0300 Subject: [PATCH 1/4] Reduce notifyUser propagation --- app/lib/server/methods/addUsersToRoom.js | 2 +- app/lib/server/methods/filterATAllTag.js | 2 +- app/lib/server/methods/filterATHereTag.js | 2 +- app/lib/server/methods/sendMessage.js | 2 +- app/lib/server/startup/userDataStream.js | 6 +++--- app/mentions/server/server.js | 2 +- app/reactions/server/setReaction.js | 2 +- app/slashcommands-archiveroom/server/server.js | 6 +++--- app/slashcommands-create/server/server.js | 2 +- app/slashcommands-help/server/server.js | 2 +- app/slashcommands-hide/server/hide.js | 6 +++--- app/slashcommands-invite/server/server.js | 8 ++++---- app/slashcommands-inviteall/server/server.js | 8 ++++---- app/slashcommands-join/server/server.js | 2 +- app/slashcommands-kick/server/server.js | 4 ++-- app/slashcommands-leave/server/leave.js | 2 +- app/slashcommands-msg/server/server.js | 4 ++-- app/slashcommands-mute/server/mute.js | 4 ++-- app/slashcommands-mute/server/unmute.js | 4 ++-- app/slashcommands-status/lib/status.js | 4 ++-- app/slashcommands-unarchiveroom/server/server.js | 6 +++--- app/sms/server/services/twilio.js | 2 +- 22 files changed, 41 insertions(+), 41 deletions(-) diff --git a/app/lib/server/methods/addUsersToRoom.js b/app/lib/server/methods/addUsersToRoom.js index 63eaa7594a83..4c285c0635d3 100644 --- a/app/lib/server/methods/addUsersToRoom.js +++ b/app/lib/server/methods/addUsersToRoom.js @@ -73,7 +73,7 @@ Meteor.methods({ if (!subscription) { addUserToRoom(data.rid, newUser, user); } else { - Notifications.notifyUser(userId, 'message', { + Notifications.notifyUserInThisInstance(userId, 'message', { _id: Random.id(), rid: data.rid, ts: new Date(), diff --git a/app/lib/server/methods/filterATAllTag.js b/app/lib/server/methods/filterATAllTag.js index 9ada82426f3b..49b0c171f5a3 100644 --- a/app/lib/server/methods/filterATAllTag.js +++ b/app/lib/server/methods/filterATAllTag.js @@ -27,7 +27,7 @@ callbacks.add('beforeSaveMessage', function(message) { // Add a notification to the chat, informing the user that this // action is not allowed. - Notifications.notifyUser(message.u._id, 'message', { + Notifications.notifyUserInThisInstance(message.u._id, 'message', { _id: Random.id(), rid: message.rid, ts: new Date(), diff --git a/app/lib/server/methods/filterATHereTag.js b/app/lib/server/methods/filterATHereTag.js index 79198e1aaf5d..93d4d28a00ea 100644 --- a/app/lib/server/methods/filterATHereTag.js +++ b/app/lib/server/methods/filterATHereTag.js @@ -26,7 +26,7 @@ callbacks.add('beforeSaveMessage', function(message) { // Add a notification to the chat, informing the user that this // action is not allowed. - Notifications.notifyUser(message.u._id, 'message', { + Notifications.notifyUserInThisInstance(message.u._id, 'message', { _id: Random.id(), rid: message.rid, ts: new Date(), diff --git a/app/lib/server/methods/sendMessage.js b/app/lib/server/methods/sendMessage.js index d25284a3639f..be47509d9288 100644 --- a/app/lib/server/methods/sendMessage.js +++ b/app/lib/server/methods/sendMessage.js @@ -82,7 +82,7 @@ export function executeSendMessage(uid, message) { SystemLogger.error('Error sending message:', error); - Notifications.notifyUser(uid, 'message', { + Notifications.notifyUserInThisInstance(uid, 'message', { _id: Random.id(), rid: message.rid, ts: new Date(), diff --git a/app/lib/server/startup/userDataStream.js b/app/lib/server/startup/userDataStream.js index 09d3db52083c..8cdc95e4b66b 100644 --- a/app/lib/server/startup/userDataStream.js +++ b/app/lib/server/startup/userDataStream.js @@ -4,13 +4,13 @@ import { Notifications } from '../../../notifications/server'; Users.on('change', ({ clientAction, id, data, diff }) => { switch (clientAction) { case 'updated': - Notifications.notifyUser(id, 'userData', { diff, type: clientAction }); + Notifications.notifyUserInThisInstance(id, 'userData', { diff, type: clientAction }); break; case 'inserted': - Notifications.notifyUser(id, 'userData', { data, type: clientAction }); + Notifications.notifyUserInThisInstance(id, 'userData', { data, type: clientAction }); break; case 'removed': - Notifications.notifyUser(id, 'userData', { id, type: clientAction }); + Notifications.notifyUserInThisInstance(id, 'userData', { id, type: clientAction }); break; } }); diff --git a/app/mentions/server/server.js b/app/mentions/server/server.js index 9c515e4ecdec..24ace658f81c 100644 --- a/app/mentions/server/server.js +++ b/app/mentions/server/server.js @@ -21,7 +21,7 @@ const mention = new MentionsServer({ const { language } = this.getUser(sender._id); const msg = TAPi18n.__('Group_mentions_disabled_x_members', { total: this.messageMaxAll }, language); - Notifications.notifyUser(sender._id, 'message', { + Notifications.notifyUserInThisInstance(sender._id, 'message', { _id: Random.id(), rid, ts: new Date(), diff --git a/app/reactions/server/setReaction.js b/app/reactions/server/setReaction.js index f9a6751e6134..36e8075d56a7 100644 --- a/app/reactions/server/setReaction.js +++ b/app/reactions/server/setReaction.js @@ -31,7 +31,7 @@ export function setReaction(room, user, message, reaction, shouldReact) { } if (Array.isArray(room.muted) && room.muted.indexOf(user.username) !== -1) { - Notifications.notifyUser(Meteor.userId(), 'message', { + Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { _id: Random.id(), rid: room._id, ts: new Date(), diff --git a/app/slashcommands-archiveroom/server/server.js b/app/slashcommands-archiveroom/server/server.js index 6085a2597426..0a30639ac345 100644 --- a/app/slashcommands-archiveroom/server/server.js +++ b/app/slashcommands-archiveroom/server/server.js @@ -26,7 +26,7 @@ function Archive(command, params, item) { const user = Meteor.users.findOne(Meteor.userId()); if (!room) { - return Notifications.notifyUser(Meteor.userId(), 'message', { + return Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -43,7 +43,7 @@ function Archive(command, params, item) { } if (room.archived) { - Notifications.notifyUser(Meteor.userId(), 'message', { + Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -57,7 +57,7 @@ function Archive(command, params, item) { Meteor.call('archiveRoom', room._id); Messages.createRoomArchivedByRoomIdAndUser(room._id, Meteor.user()); - Notifications.notifyUser(Meteor.userId(), 'message', { + Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-create/server/server.js b/app/slashcommands-create/server/server.js index 898d44bdaac1..eecbe3a9071f 100644 --- a/app/slashcommands-create/server/server.js +++ b/app/slashcommands-create/server/server.js @@ -36,7 +36,7 @@ function Create(command, params, item) { const user = Meteor.users.findOne(Meteor.userId()); const room = Rooms.findOneByName(channel); if (room != null) { - Notifications.notifyUser(Meteor.userId(), 'message', { + Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-help/server/server.js b/app/slashcommands-help/server/server.js index ba76736dc9a5..48e1a453c925 100644 --- a/app/slashcommands-help/server/server.js +++ b/app/slashcommands-help/server/server.js @@ -39,7 +39,7 @@ slashCommands.add('help', function Help(command, params, item) { }, ]; keys.forEach((key) => { - Notifications.notifyUser(Meteor.userId(), 'message', { + Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-hide/server/hide.js b/app/slashcommands-hide/server/hide.js index 2a316417d4d5..07bb7b201c59 100644 --- a/app/slashcommands-hide/server/hide.js +++ b/app/slashcommands-hide/server/hide.js @@ -29,7 +29,7 @@ function Hide(command, param, item) { }); if (!roomObject) { - return Notifications.notifyUser(user._id, 'message', { + return Notifications.notifyUserInThisInstance(user._id, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -41,7 +41,7 @@ function Hide(command, param, item) { } if (!Subscriptions.findOneByRoomIdAndUserId(room._id, user._id, { fields: { _id: 1 } })) { - return Notifications.notifyUser(user._id, 'message', { + return Notifications.notifyUserInThisInstance(user._id, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -56,7 +56,7 @@ function Hide(command, param, item) { Meteor.call('hideRoom', rid, (error) => { if (error) { - return Notifications.notifyUser(user._id, 'message', { + return Notifications.notifyUserInThisInstance(user._id, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-invite/server/server.js b/app/slashcommands-invite/server/server.js index eb804329cc5c..2ee847ac8334 100644 --- a/app/slashcommands-invite/server/server.js +++ b/app/slashcommands-invite/server/server.js @@ -30,7 +30,7 @@ function Invite(command, params, item) { const userId = Meteor.userId(); const currentUser = Meteor.users.findOne(userId); if (users.count() === 0) { - Notifications.notifyUser(userId, 'message', { + Notifications.notifyUserInThisInstance(userId, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -46,7 +46,7 @@ function Invite(command, params, item) { if (subscription == null) { return true; } - Notifications.notifyUser(userId, 'message', { + Notifications.notifyUserInThisInstance(userId, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -66,14 +66,14 @@ function Invite(command, params, item) { }); } catch ({ error }) { if (error === 'cant-invite-for-direct-room') { - Notifications.notifyUser(userId, 'message', { + Notifications.notifyUserInThisInstance(userId, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), msg: TAPi18n.__('Cannot_invite_users_to_direct_rooms', null, currentUser.language), }); } else { - Notifications.notifyUser(userId, 'message', { + Notifications.notifyUserInThisInstance(userId, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-inviteall/server/server.js b/app/slashcommands-inviteall/server/server.js index 1a4171729323..80a86b8726d3 100644 --- a/app/slashcommands-inviteall/server/server.js +++ b/app/slashcommands-inviteall/server/server.js @@ -30,7 +30,7 @@ function inviteAll(type) { const targetChannel = type === 'from' ? Rooms.findOneById(item.rid) : Rooms.findOneByName(channel); if (!baseChannel) { - return Notifications.notifyUser(userId, 'message', { + return Notifications.notifyUserInThisInstance(userId, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -52,7 +52,7 @@ function inviteAll(type) { if (!targetChannel && ['c', 'p'].indexOf(baseChannel.t) > -1) { Meteor.call(baseChannel.t === 'c' ? 'createChannel' : 'createPrivateGroup', channel, users); - Notifications.notifyUser(userId, 'message', { + Notifications.notifyUserInThisInstance(userId, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -67,7 +67,7 @@ function inviteAll(type) { users, }); } - return Notifications.notifyUser(userId, 'message', { + return Notifications.notifyUserInThisInstance(userId, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -75,7 +75,7 @@ function inviteAll(type) { }); } catch (e) { const msg = e.error === 'cant-invite-for-direct-room' ? 'Cannot_invite_users_to_direct_rooms' : e.error; - Notifications.notifyUser(userId, 'message', { + Notifications.notifyUserInThisInstance(userId, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-join/server/server.js b/app/slashcommands-join/server/server.js index 1b1802da704a..df94c06cc5be 100644 --- a/app/slashcommands-join/server/server.js +++ b/app/slashcommands-join/server/server.js @@ -19,7 +19,7 @@ function Join(command, params, item) { const user = Meteor.users.findOne(Meteor.userId()); const room = Rooms.findOneByNameAndType(channel, 'c'); if (!room) { - Notifications.notifyUser(Meteor.userId(), 'message', { + Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-kick/server/server.js b/app/slashcommands-kick/server/server.js index 5bc785cc8214..6055f5d0e911 100644 --- a/app/slashcommands-kick/server/server.js +++ b/app/slashcommands-kick/server/server.js @@ -22,7 +22,7 @@ const Kick = function(command, params, { rid }) { const kickedUser = Users.findOneByUsernameIgnoringCase(username); if (kickedUser == null) { - return Notifications.notifyUser(userId, 'message', { + return Notifications.notifyUserInThisInstance(userId, 'message', { _id: Random.id(), rid, ts: new Date(), @@ -35,7 +35,7 @@ const Kick = function(command, params, { rid }) { const subscription = Subscriptions.findOneByRoomIdAndUserId(rid, user._id, { fields: { _id: 1 } }); if (!subscription) { - return Notifications.notifyUser(userId, 'message', { + return Notifications.notifyUserInThisInstance(userId, 'message', { _id: Random.id(), rid, ts: new Date(), diff --git a/app/slashcommands-leave/server/leave.js b/app/slashcommands-leave/server/leave.js index ce6fc32fb1e6..2ee06c4479da 100644 --- a/app/slashcommands-leave/server/leave.js +++ b/app/slashcommands-leave/server/leave.js @@ -17,7 +17,7 @@ function Leave(command, params, item) { try { Meteor.call('leaveRoom', item.rid); } catch ({ error }) { - Notifications.notifyUser(Meteor.userId(), 'message', { + Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-msg/server/server.js b/app/slashcommands-msg/server/server.js index 5fa33fe901e4..9cdddd0dfb19 100644 --- a/app/slashcommands-msg/server/server.js +++ b/app/slashcommands-msg/server/server.js @@ -19,7 +19,7 @@ function Msg(command, params, item) { const separator = trimmedParams.indexOf(' '); const user = Meteor.users.findOne(Meteor.userId()); if (separator === -1) { - return Notifications.notifyUser(Meteor.userId(), 'message', { + return Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -31,7 +31,7 @@ function Msg(command, params, item) { const targetUsername = targetUsernameOrig.replace('@', ''); const targetUser = Users.findOneByUsernameIgnoringCase(targetUsername); if (targetUser == null) { - Notifications.notifyUser(Meteor.userId(), 'message', { + Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-mute/server/mute.js b/app/slashcommands-mute/server/mute.js index 306edfecde33..af9ef7a44791 100644 --- a/app/slashcommands-mute/server/mute.js +++ b/app/slashcommands-mute/server/mute.js @@ -23,7 +23,7 @@ slashCommands.add('mute', function Mute(command, params, item) { const user = Meteor.users.findOne(userId); const mutedUser = Users.findOneByUsernameIgnoringCase(username); if (mutedUser == null) { - Notifications.notifyUser(userId, 'message', { + Notifications.notifyUserInThisInstance(userId, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -37,7 +37,7 @@ slashCommands.add('mute', function Mute(command, params, item) { const subscription = Subscriptions.findOneByRoomIdAndUserId(item.rid, mutedUser._id, { fields: { _id: 1 } }); if (!subscription) { - Notifications.notifyUser(userId, 'message', { + Notifications.notifyUserInThisInstance(userId, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-mute/server/unmute.js b/app/slashcommands-mute/server/unmute.js index a84c518e48b4..ce3ca9a18e0b 100644 --- a/app/slashcommands-mute/server/unmute.js +++ b/app/slashcommands-mute/server/unmute.js @@ -22,7 +22,7 @@ slashCommands.add('unmute', function Unmute(command, params, item) { const user = Meteor.users.findOne(Meteor.userId()); const unmutedUser = Users.findOneByUsernameIgnoringCase(username); if (unmutedUser == null) { - return Notifications.notifyUser(Meteor.userId(), 'message', { + return Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -35,7 +35,7 @@ slashCommands.add('unmute', function Unmute(command, params, item) { const subscription = Subscriptions.findOneByRoomIdAndUserId(item.rid, unmutedUser._id, { fields: { _id: 1 } }); if (!subscription) { - return Notifications.notifyUser(Meteor.userId(), 'message', { + return Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-status/lib/status.js b/app/slashcommands-status/lib/status.js index 0141fdc1b1b2..87f5dafbea2c 100644 --- a/app/slashcommands-status/lib/status.js +++ b/app/slashcommands-status/lib/status.js @@ -16,7 +16,7 @@ function Status(command, params, item) { } if (err.error === 'error-not-allowed') { - Notifications.notifyUser(Meteor.userId(), 'message', { + Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -26,7 +26,7 @@ function Status(command, params, item) { throw err; } else { - Notifications.notifyUser(Meteor.userId(), 'message', { + Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-unarchiveroom/server/server.js b/app/slashcommands-unarchiveroom/server/server.js index be2c56e47cb0..cf32f961d653 100644 --- a/app/slashcommands-unarchiveroom/server/server.js +++ b/app/slashcommands-unarchiveroom/server/server.js @@ -27,7 +27,7 @@ function Unarchive(command, params, item) { const user = Meteor.users.findOne(Meteor.userId()); if (!room) { - return Notifications.notifyUser(Meteor.userId(), 'message', { + return Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -44,7 +44,7 @@ function Unarchive(command, params, item) { } if (!room.archived) { - Notifications.notifyUser(Meteor.userId(), 'message', { + Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -59,7 +59,7 @@ function Unarchive(command, params, item) { Meteor.call('unarchiveRoom', room._id); Messages.createRoomUnarchivedByRoomIdAndUser(room._id, Meteor.user()); - Notifications.notifyUser(Meteor.userId(), 'message', { + Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/sms/server/services/twilio.js b/app/sms/server/services/twilio.js index c928ed8a447f..a6883d2b696a 100644 --- a/app/sms/server/services/twilio.js +++ b/app/sms/server/services/twilio.js @@ -11,7 +11,7 @@ import { fileUploadIsValidContentType } from '../../../utils/lib/fileUploadRestr const MAX_FILE_SIZE = 5242880; -const notifyAgent = (userId, rid, msg) => Notifications.notifyUser(userId, 'message', { +const notifyAgent = (userId, rid, msg) => Notifications.notifyUserInThisInstance(userId, 'message', { _id: Random.id(), rid, ts: new Date(), From 1d8fb9840501dd6f7ace43643379d301453499a2 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Mon, 30 Mar 2020 17:29:35 -0300 Subject: [PATCH 2/4] More changes --- app/livechat/server/lib/stream/departmentAgents.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/livechat/server/lib/stream/departmentAgents.js b/app/livechat/server/lib/stream/departmentAgents.js index 24800d16461f..a6c6fab75122 100644 --- a/app/livechat/server/lib/stream/departmentAgents.js +++ b/app/livechat/server/lib/stream/departmentAgents.js @@ -9,7 +9,7 @@ const emitNotification = (action, payload = {}) => { return; } - Notifications.notifyUser(agentId, 'departmentAgentData', { + Notifications.notifyUserInThisInstance(agentId, 'departmentAgentData', { action, ...payload, }); From dda00a806491f2d0c11afe0995d3d85879dd3869 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Mon, 30 Mar 2020 17:50:21 -0300 Subject: [PATCH 3/4] Revert slash commands --- app/slashcommands-archiveroom/server/server.js | 6 +++--- app/slashcommands-create/server/server.js | 2 +- app/slashcommands-help/server/server.js | 2 +- app/slashcommands-hide/server/hide.js | 6 +++--- app/slashcommands-invite/server/server.js | 8 ++++---- app/slashcommands-inviteall/server/server.js | 8 ++++---- app/slashcommands-join/server/server.js | 2 +- app/slashcommands-kick/server/server.js | 4 ++-- app/slashcommands-leave/server/leave.js | 2 +- app/slashcommands-msg/server/server.js | 4 ++-- app/slashcommands-mute/server/mute.js | 4 ++-- app/slashcommands-mute/server/unmute.js | 4 ++-- app/slashcommands-status/lib/status.js | 4 ++-- app/slashcommands-unarchiveroom/server/server.js | 6 +++--- 14 files changed, 31 insertions(+), 31 deletions(-) diff --git a/app/slashcommands-archiveroom/server/server.js b/app/slashcommands-archiveroom/server/server.js index 0a30639ac345..6085a2597426 100644 --- a/app/slashcommands-archiveroom/server/server.js +++ b/app/slashcommands-archiveroom/server/server.js @@ -26,7 +26,7 @@ function Archive(command, params, item) { const user = Meteor.users.findOne(Meteor.userId()); if (!room) { - return Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { + return Notifications.notifyUser(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -43,7 +43,7 @@ function Archive(command, params, item) { } if (room.archived) { - Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { + Notifications.notifyUser(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -57,7 +57,7 @@ function Archive(command, params, item) { Meteor.call('archiveRoom', room._id); Messages.createRoomArchivedByRoomIdAndUser(room._id, Meteor.user()); - Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { + Notifications.notifyUser(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-create/server/server.js b/app/slashcommands-create/server/server.js index eecbe3a9071f..898d44bdaac1 100644 --- a/app/slashcommands-create/server/server.js +++ b/app/slashcommands-create/server/server.js @@ -36,7 +36,7 @@ function Create(command, params, item) { const user = Meteor.users.findOne(Meteor.userId()); const room = Rooms.findOneByName(channel); if (room != null) { - Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { + Notifications.notifyUser(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-help/server/server.js b/app/slashcommands-help/server/server.js index 48e1a453c925..ba76736dc9a5 100644 --- a/app/slashcommands-help/server/server.js +++ b/app/slashcommands-help/server/server.js @@ -39,7 +39,7 @@ slashCommands.add('help', function Help(command, params, item) { }, ]; keys.forEach((key) => { - Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { + Notifications.notifyUser(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-hide/server/hide.js b/app/slashcommands-hide/server/hide.js index 07bb7b201c59..2a316417d4d5 100644 --- a/app/slashcommands-hide/server/hide.js +++ b/app/slashcommands-hide/server/hide.js @@ -29,7 +29,7 @@ function Hide(command, param, item) { }); if (!roomObject) { - return Notifications.notifyUserInThisInstance(user._id, 'message', { + return Notifications.notifyUser(user._id, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -41,7 +41,7 @@ function Hide(command, param, item) { } if (!Subscriptions.findOneByRoomIdAndUserId(room._id, user._id, { fields: { _id: 1 } })) { - return Notifications.notifyUserInThisInstance(user._id, 'message', { + return Notifications.notifyUser(user._id, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -56,7 +56,7 @@ function Hide(command, param, item) { Meteor.call('hideRoom', rid, (error) => { if (error) { - return Notifications.notifyUserInThisInstance(user._id, 'message', { + return Notifications.notifyUser(user._id, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-invite/server/server.js b/app/slashcommands-invite/server/server.js index 2ee847ac8334..eb804329cc5c 100644 --- a/app/slashcommands-invite/server/server.js +++ b/app/slashcommands-invite/server/server.js @@ -30,7 +30,7 @@ function Invite(command, params, item) { const userId = Meteor.userId(); const currentUser = Meteor.users.findOne(userId); if (users.count() === 0) { - Notifications.notifyUserInThisInstance(userId, 'message', { + Notifications.notifyUser(userId, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -46,7 +46,7 @@ function Invite(command, params, item) { if (subscription == null) { return true; } - Notifications.notifyUserInThisInstance(userId, 'message', { + Notifications.notifyUser(userId, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -66,14 +66,14 @@ function Invite(command, params, item) { }); } catch ({ error }) { if (error === 'cant-invite-for-direct-room') { - Notifications.notifyUserInThisInstance(userId, 'message', { + Notifications.notifyUser(userId, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), msg: TAPi18n.__('Cannot_invite_users_to_direct_rooms', null, currentUser.language), }); } else { - Notifications.notifyUserInThisInstance(userId, 'message', { + Notifications.notifyUser(userId, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-inviteall/server/server.js b/app/slashcommands-inviteall/server/server.js index 80a86b8726d3..1a4171729323 100644 --- a/app/slashcommands-inviteall/server/server.js +++ b/app/slashcommands-inviteall/server/server.js @@ -30,7 +30,7 @@ function inviteAll(type) { const targetChannel = type === 'from' ? Rooms.findOneById(item.rid) : Rooms.findOneByName(channel); if (!baseChannel) { - return Notifications.notifyUserInThisInstance(userId, 'message', { + return Notifications.notifyUser(userId, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -52,7 +52,7 @@ function inviteAll(type) { if (!targetChannel && ['c', 'p'].indexOf(baseChannel.t) > -1) { Meteor.call(baseChannel.t === 'c' ? 'createChannel' : 'createPrivateGroup', channel, users); - Notifications.notifyUserInThisInstance(userId, 'message', { + Notifications.notifyUser(userId, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -67,7 +67,7 @@ function inviteAll(type) { users, }); } - return Notifications.notifyUserInThisInstance(userId, 'message', { + return Notifications.notifyUser(userId, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -75,7 +75,7 @@ function inviteAll(type) { }); } catch (e) { const msg = e.error === 'cant-invite-for-direct-room' ? 'Cannot_invite_users_to_direct_rooms' : e.error; - Notifications.notifyUserInThisInstance(userId, 'message', { + Notifications.notifyUser(userId, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-join/server/server.js b/app/slashcommands-join/server/server.js index df94c06cc5be..1b1802da704a 100644 --- a/app/slashcommands-join/server/server.js +++ b/app/slashcommands-join/server/server.js @@ -19,7 +19,7 @@ function Join(command, params, item) { const user = Meteor.users.findOne(Meteor.userId()); const room = Rooms.findOneByNameAndType(channel, 'c'); if (!room) { - Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { + Notifications.notifyUser(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-kick/server/server.js b/app/slashcommands-kick/server/server.js index 6055f5d0e911..5bc785cc8214 100644 --- a/app/slashcommands-kick/server/server.js +++ b/app/slashcommands-kick/server/server.js @@ -22,7 +22,7 @@ const Kick = function(command, params, { rid }) { const kickedUser = Users.findOneByUsernameIgnoringCase(username); if (kickedUser == null) { - return Notifications.notifyUserInThisInstance(userId, 'message', { + return Notifications.notifyUser(userId, 'message', { _id: Random.id(), rid, ts: new Date(), @@ -35,7 +35,7 @@ const Kick = function(command, params, { rid }) { const subscription = Subscriptions.findOneByRoomIdAndUserId(rid, user._id, { fields: { _id: 1 } }); if (!subscription) { - return Notifications.notifyUserInThisInstance(userId, 'message', { + return Notifications.notifyUser(userId, 'message', { _id: Random.id(), rid, ts: new Date(), diff --git a/app/slashcommands-leave/server/leave.js b/app/slashcommands-leave/server/leave.js index 2ee06c4479da..ce6fc32fb1e6 100644 --- a/app/slashcommands-leave/server/leave.js +++ b/app/slashcommands-leave/server/leave.js @@ -17,7 +17,7 @@ function Leave(command, params, item) { try { Meteor.call('leaveRoom', item.rid); } catch ({ error }) { - Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { + Notifications.notifyUser(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-msg/server/server.js b/app/slashcommands-msg/server/server.js index 9cdddd0dfb19..5fa33fe901e4 100644 --- a/app/slashcommands-msg/server/server.js +++ b/app/slashcommands-msg/server/server.js @@ -19,7 +19,7 @@ function Msg(command, params, item) { const separator = trimmedParams.indexOf(' '); const user = Meteor.users.findOne(Meteor.userId()); if (separator === -1) { - return Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { + return Notifications.notifyUser(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -31,7 +31,7 @@ function Msg(command, params, item) { const targetUsername = targetUsernameOrig.replace('@', ''); const targetUser = Users.findOneByUsernameIgnoringCase(targetUsername); if (targetUser == null) { - Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { + Notifications.notifyUser(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-mute/server/mute.js b/app/slashcommands-mute/server/mute.js index af9ef7a44791..306edfecde33 100644 --- a/app/slashcommands-mute/server/mute.js +++ b/app/slashcommands-mute/server/mute.js @@ -23,7 +23,7 @@ slashCommands.add('mute', function Mute(command, params, item) { const user = Meteor.users.findOne(userId); const mutedUser = Users.findOneByUsernameIgnoringCase(username); if (mutedUser == null) { - Notifications.notifyUserInThisInstance(userId, 'message', { + Notifications.notifyUser(userId, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -37,7 +37,7 @@ slashCommands.add('mute', function Mute(command, params, item) { const subscription = Subscriptions.findOneByRoomIdAndUserId(item.rid, mutedUser._id, { fields: { _id: 1 } }); if (!subscription) { - Notifications.notifyUserInThisInstance(userId, 'message', { + Notifications.notifyUser(userId, 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-mute/server/unmute.js b/app/slashcommands-mute/server/unmute.js index ce3ca9a18e0b..a84c518e48b4 100644 --- a/app/slashcommands-mute/server/unmute.js +++ b/app/slashcommands-mute/server/unmute.js @@ -22,7 +22,7 @@ slashCommands.add('unmute', function Unmute(command, params, item) { const user = Meteor.users.findOne(Meteor.userId()); const unmutedUser = Users.findOneByUsernameIgnoringCase(username); if (unmutedUser == null) { - return Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { + return Notifications.notifyUser(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -35,7 +35,7 @@ slashCommands.add('unmute', function Unmute(command, params, item) { const subscription = Subscriptions.findOneByRoomIdAndUserId(item.rid, unmutedUser._id, { fields: { _id: 1 } }); if (!subscription) { - return Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { + return Notifications.notifyUser(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-status/lib/status.js b/app/slashcommands-status/lib/status.js index 87f5dafbea2c..0141fdc1b1b2 100644 --- a/app/slashcommands-status/lib/status.js +++ b/app/slashcommands-status/lib/status.js @@ -16,7 +16,7 @@ function Status(command, params, item) { } if (err.error === 'error-not-allowed') { - Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { + Notifications.notifyUser(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -26,7 +26,7 @@ function Status(command, params, item) { throw err; } else { - Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { + Notifications.notifyUser(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), diff --git a/app/slashcommands-unarchiveroom/server/server.js b/app/slashcommands-unarchiveroom/server/server.js index cf32f961d653..be2c56e47cb0 100644 --- a/app/slashcommands-unarchiveroom/server/server.js +++ b/app/slashcommands-unarchiveroom/server/server.js @@ -27,7 +27,7 @@ function Unarchive(command, params, item) { const user = Meteor.users.findOne(Meteor.userId()); if (!room) { - return Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { + return Notifications.notifyUser(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -44,7 +44,7 @@ function Unarchive(command, params, item) { } if (!room.archived) { - Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { + Notifications.notifyUser(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), @@ -59,7 +59,7 @@ function Unarchive(command, params, item) { Meteor.call('unarchiveRoom', room._id); Messages.createRoomUnarchivedByRoomIdAndUser(room._id, Meteor.user()); - Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { + Notifications.notifyUser(Meteor.userId(), 'message', { _id: Random.id(), rid: item.rid, ts: new Date(), From 413e1782376d5285135570355ceb0009989d6eb1 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Mon, 30 Mar 2020 17:56:32 -0300 Subject: [PATCH 4/4] Revert more items --- app/lib/server/methods/addUsersToRoom.js | 2 +- app/lib/server/methods/filterATAllTag.js | 2 +- app/lib/server/methods/filterATHereTag.js | 2 +- app/lib/server/methods/sendMessage.js | 2 +- app/mentions/server/server.js | 2 +- app/reactions/server/setReaction.js | 2 +- app/sms/server/services/twilio.js | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/lib/server/methods/addUsersToRoom.js b/app/lib/server/methods/addUsersToRoom.js index 4c285c0635d3..63eaa7594a83 100644 --- a/app/lib/server/methods/addUsersToRoom.js +++ b/app/lib/server/methods/addUsersToRoom.js @@ -73,7 +73,7 @@ Meteor.methods({ if (!subscription) { addUserToRoom(data.rid, newUser, user); } else { - Notifications.notifyUserInThisInstance(userId, 'message', { + Notifications.notifyUser(userId, 'message', { _id: Random.id(), rid: data.rid, ts: new Date(), diff --git a/app/lib/server/methods/filterATAllTag.js b/app/lib/server/methods/filterATAllTag.js index 49b0c171f5a3..9ada82426f3b 100644 --- a/app/lib/server/methods/filterATAllTag.js +++ b/app/lib/server/methods/filterATAllTag.js @@ -27,7 +27,7 @@ callbacks.add('beforeSaveMessage', function(message) { // Add a notification to the chat, informing the user that this // action is not allowed. - Notifications.notifyUserInThisInstance(message.u._id, 'message', { + Notifications.notifyUser(message.u._id, 'message', { _id: Random.id(), rid: message.rid, ts: new Date(), diff --git a/app/lib/server/methods/filterATHereTag.js b/app/lib/server/methods/filterATHereTag.js index 93d4d28a00ea..79198e1aaf5d 100644 --- a/app/lib/server/methods/filterATHereTag.js +++ b/app/lib/server/methods/filterATHereTag.js @@ -26,7 +26,7 @@ callbacks.add('beforeSaveMessage', function(message) { // Add a notification to the chat, informing the user that this // action is not allowed. - Notifications.notifyUserInThisInstance(message.u._id, 'message', { + Notifications.notifyUser(message.u._id, 'message', { _id: Random.id(), rid: message.rid, ts: new Date(), diff --git a/app/lib/server/methods/sendMessage.js b/app/lib/server/methods/sendMessage.js index be47509d9288..d25284a3639f 100644 --- a/app/lib/server/methods/sendMessage.js +++ b/app/lib/server/methods/sendMessage.js @@ -82,7 +82,7 @@ export function executeSendMessage(uid, message) { SystemLogger.error('Error sending message:', error); - Notifications.notifyUserInThisInstance(uid, 'message', { + Notifications.notifyUser(uid, 'message', { _id: Random.id(), rid: message.rid, ts: new Date(), diff --git a/app/mentions/server/server.js b/app/mentions/server/server.js index 24ace658f81c..9c515e4ecdec 100644 --- a/app/mentions/server/server.js +++ b/app/mentions/server/server.js @@ -21,7 +21,7 @@ const mention = new MentionsServer({ const { language } = this.getUser(sender._id); const msg = TAPi18n.__('Group_mentions_disabled_x_members', { total: this.messageMaxAll }, language); - Notifications.notifyUserInThisInstance(sender._id, 'message', { + Notifications.notifyUser(sender._id, 'message', { _id: Random.id(), rid, ts: new Date(), diff --git a/app/reactions/server/setReaction.js b/app/reactions/server/setReaction.js index 36e8075d56a7..f9a6751e6134 100644 --- a/app/reactions/server/setReaction.js +++ b/app/reactions/server/setReaction.js @@ -31,7 +31,7 @@ export function setReaction(room, user, message, reaction, shouldReact) { } if (Array.isArray(room.muted) && room.muted.indexOf(user.username) !== -1) { - Notifications.notifyUserInThisInstance(Meteor.userId(), 'message', { + Notifications.notifyUser(Meteor.userId(), 'message', { _id: Random.id(), rid: room._id, ts: new Date(), diff --git a/app/sms/server/services/twilio.js b/app/sms/server/services/twilio.js index a6883d2b696a..c928ed8a447f 100644 --- a/app/sms/server/services/twilio.js +++ b/app/sms/server/services/twilio.js @@ -11,7 +11,7 @@ import { fileUploadIsValidContentType } from '../../../utils/lib/fileUploadRestr const MAX_FILE_SIZE = 5242880; -const notifyAgent = (userId, rid, msg) => Notifications.notifyUserInThisInstance(userId, 'message', { +const notifyAgent = (userId, rid, msg) => Notifications.notifyUser(userId, 'message', { _id: Random.id(), rid, ts: new Date(),