Skip to content

Commit

Permalink
fix: Remove ls & lr from subscription creation on Omni rooms (Roc…
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman authored Dec 21, 2023
1 parent b42aa49 commit d6a8360
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
6 changes: 6 additions & 0 deletions .changeset/sharp-rings-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": patch
---

Fixed a problem with the subscription creation on Omnichannel rooms.
Rooms were being created as seen, causing sound notifications to not work
16 changes: 9 additions & 7 deletions apps/meteor/app/livechat/client/startup/notifyUnreadRooms.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Users } from '@rocket.chat/models';
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';

import { CustomSounds } from '../../../custom-sounds/client';
import { Subscriptions } from '../../../models/client';
import { Subscriptions, Users } from '../../../models/client';
import { settings } from '../../../settings/client';
import { getUserPreference } from '../../../utils/client';

Expand All @@ -16,17 +15,20 @@ Meteor.startup(() => {
return;
}

const subs = await Subscriptions.find({ t: 'l', ls: { $exists: 0 }, open: true }).count();
const subs = await Subscriptions.find({ t: 'l', ls: { $exists: false }, open: true }).count();
if (subs === 0) {
audio && audio.pause();
return;
}

const user = await Users.findOne(Meteor.userId(), {
projection: {
'settings.preferences.newRoomNotification': 1,
const user = await Users.findOne(
{ _id: Meteor.userId() },
{
projection: {
'settings.preferences.newRoomNotification': 1,
},
},
});
);

const newRoomNotification = getUserPreference(user, 'newRoomNotification');

Expand Down
4 changes: 1 addition & 3 deletions apps/meteor/app/livechat/server/lib/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,8 @@ export const createLivechatSubscription = async (
status,
},
ts: new Date(),
lr: new Date(),
ls: new Date(),
...(department && { department }),
};
} as InsertionModel<ISubscription>;

return Subscriptions.insertOne(subscriptionData);
};
Expand Down

0 comments on commit d6a8360

Please sign in to comment.