diff --git a/apps/meteor/app/lib/server/functions/addUserToRoom.ts b/apps/meteor/app/lib/server/functions/addUserToRoom.ts index 2e74bf66cf4a..2997acaf5924 100644 --- a/apps/meteor/app/lib/server/functions/addUserToRoom.ts +++ b/apps/meteor/app/lib/server/functions/addUserToRoom.ts @@ -20,9 +20,11 @@ export const addUserToRoom = async function ( { skipSystemMessage, skipAlertSound, + createAsHidden = false, }: { skipSystemMessage?: boolean; skipAlertSound?: boolean; + createAsHidden?: boolean; } = {}, ): Promise { const now = new Date(); @@ -84,8 +86,8 @@ export const addUserToRoom = async function ( const { insertedId } = await Subscriptions.createWithRoomAndUser(room, userToBeAdded as IUser, { ts: now, - open: true, - alert: !skipAlertSound, + open: !createAsHidden, + alert: createAsHidden ? false : !skipAlertSound, unread: 1, userMentions: 1, groupMentions: 0, diff --git a/apps/meteor/app/lib/server/functions/createRoom.ts b/apps/meteor/app/lib/server/functions/createRoom.ts index fda2314d3f2e..bb099af8cee7 100644 --- a/apps/meteor/app/lib/server/functions/createRoom.ts +++ b/apps/meteor/app/lib/server/functions/createRoom.ts @@ -74,9 +74,7 @@ async function createUsersSubscriptions({ memberIds.push(member._id); - const extra: Partial = options?.subscriptionExtra || {}; - - extra.open = true; + const extra: Partial = { open: true, ...options?.subscriptionExtra }; if (room.prid) { extra.prid = room.prid; diff --git a/apps/meteor/server/services/video-conference/service.ts b/apps/meteor/server/services/video-conference/service.ts index 4b1456f37774..1675029ef03b 100644 --- a/apps/meteor/server/services/video-conference/service.ts +++ b/apps/meteor/server/services/video-conference/service.ts @@ -1159,6 +1159,9 @@ export class VideoConfService extends ServiceClassInternal implements IVideoConf }, { creator: user._id, + subscriptionExtra: { + open: false, + }, }, ); @@ -1190,7 +1193,7 @@ export class VideoConfService extends ServiceClassInternal implements IVideoConf private async addUserToDiscussion(rid: IRoom['_id'], uid: IUser['_id']): Promise { try { - await Room.addUserToRoom(rid, { _id: uid }, undefined, { skipAlertSound: true }); + await Room.addUserToRoom(rid, { _id: uid }, undefined, { skipSystemMessage: true, createAsHidden: true }); } catch (error) { // Ignore any errors here so that the subscription doesn't block the user from participating in the conference. logger.error({ diff --git a/apps/meteor/tests/end-to-end/apps/video-conferences.ts b/apps/meteor/tests/end-to-end/apps/video-conferences.ts index 230ee8e9f80c..0f54c05bdc89 100644 --- a/apps/meteor/tests/end-to-end/apps/video-conferences.ts +++ b/apps/meteor/tests/end-to-end/apps/video-conferences.ts @@ -581,6 +581,33 @@ describe('Apps - Video Conferences', () => { .that.satisfies((msg: string) => msg.includes('Chat History')); }); }); + + it('should have created a subscription with open = false', async function () { + if (!process.env.IS_EE) { + this.skip(); + return; + } + + await request + .get(api('subscriptions.getOne')) + .set(credentials) + .query({ + roomId: discussionRid, + }) + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + expect(res.body).to.have.property('subscription').and.to.be.an('object'); + expect(res.body.subscription).to.have.a.property('rid').equal(discussionRid); + expect(res.body.subscription) + .to.have.a.property('fname') + .that.is.a('string') + .that.satisfies((msg: string) => !msg.startsWith('Chat History')) + .that.satisfies((msg: string) => msg.includes('Chat History')); + expect(res.body.subscription).to.have.a.property('open', false); + expect(res.body.subscription).to.have.a.property('alert', false); + }); + }); }); describe('[Persistent Chat provider with the persistent chat feature enabled and custom discussion names]', () => { diff --git a/packages/core-services/src/types/IRoomService.ts b/packages/core-services/src/types/IRoomService.ts index 36bf5dff2564..1334bfce4041 100644 --- a/packages/core-services/src/types/IRoomService.ts +++ b/packages/core-services/src/types/IRoomService.ts @@ -38,6 +38,7 @@ export interface IRoomService { options?: { skipSystemMessage?: boolean; skipAlertSound?: boolean; + createAsHidden?: boolean; }, ): Promise; removeUserFromRoom(roomId: string, user: IUser, options?: { byUser: Pick }): Promise;