Skip to content

Commit 95518eb

Browse files
mrsimpsonruKurz
authored andcommitted
Fixes RocketChat#180 - copy notifications only for experts from topic (RocketChat#182)
1 parent 95e9700 commit 95518eb

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

packages/assistify-help-request/server/methods/createRequest.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
Meteor.methods({
32
createRequest(name, expertise = '', openingQuestion, members = [], environment) {
43
const requestTitle = name;
@@ -47,10 +46,12 @@ Meteor.methods({
4746

4847
if (expertise) {
4948
const expertiseSubscription = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(expertise._id, user._id);
50-
RocketChat.models.Subscriptions.updateDesktopNotificationsById(subscription._id, expertiseSubscription.desktopNotifications);
51-
RocketChat.models.Subscriptions.updateMobilePushNotificationsById(subscription._id, expertiseSubscription.mobilePushNotifications);
52-
RocketChat.models.Subscriptions.updateEmailNotificationsById(subscription._id, expertiseSubscription.emailNotifications);
53-
RocketChat.models.Subscriptions.updateAudioNotificationsById(subscription._id, expertiseSubscription.audioNotifications);
49+
if (expertiseSubscription) {
50+
RocketChat.models.Subscriptions.updateDesktopNotificationsById(subscription._id, expertiseSubscription.desktopNotifications);
51+
RocketChat.models.Subscriptions.updateMobilePushNotificationsById(subscription._id, expertiseSubscription.mobilePushNotifications);
52+
RocketChat.models.Subscriptions.updateEmailNotificationsById(subscription._id, expertiseSubscription.emailNotifications);
53+
RocketChat.models.Subscriptions.updateAudioNotificationsById(subscription._id, expertiseSubscription.audioNotifications);
54+
}
5455
} else {
5556
// Fallback: notify everything
5657
RocketChat.models.Subscriptions.updateDesktopNotificationsById(subscription._id, 'all');
@@ -81,13 +82,13 @@ Meteor.methods({
8182
}
8283
const roomCreateResult = RocketChat.createRoom('r', name, Meteor.user() && Meteor.user().username, members, false, {expertise});
8384
if (requestTitle) {
84-
RocketChat.saveRoomTopic (roomCreateResult.rid, expertise, Meteor.user());
85+
RocketChat.saveRoomTopic(roomCreateResult.rid, expertise, Meteor.user());
8586
}
8687
createNotifications(roomCreateResult.rid, members.concat([Meteor.user().username]));
8788
const room = RocketChat.models.Rooms.findOneById(roomCreateResult.rid);
8889
if (openingQuestion) {
8990
const msg = openingQuestion;
90-
const msgObject = { _id: Random.id(), rid:roomCreateResult.rid, msg};
91+
const msgObject = {_id: Random.id(), rid: roomCreateResult.rid, msg};
9192
RocketChat.sendMessage(Meteor.user(), msgObject, room);
9293
}
9394

0 commit comments

Comments
 (0)