Skip to content

Commit

Permalink
chore: Hide discussions created for Video Conference Calls (#34128)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-a-pelegrino authored Dec 16, 2024
1 parent 430b6a2 commit a4ef5ab
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
6 changes: 4 additions & 2 deletions apps/meteor/app/lib/server/functions/addUserToRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ export const addUserToRoom = async function (
{
skipSystemMessage,
skipAlertSound,
createAsHidden = false,
}: {
skipSystemMessage?: boolean;
skipAlertSound?: boolean;
createAsHidden?: boolean;
} = {},
): Promise<boolean | undefined> {
const now = new Date();
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions apps/meteor/app/lib/server/functions/createRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ async function createUsersSubscriptions({

memberIds.push(member._id);

const extra: Partial<ISubscriptionExtraData> = options?.subscriptionExtra || {};

extra.open = true;
const extra: Partial<ISubscriptionExtraData> = { open: true, ...options?.subscriptionExtra };

if (room.prid) {
extra.prid = room.prid;
Expand Down
5 changes: 4 additions & 1 deletion apps/meteor/server/services/video-conference/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,9 @@ export class VideoConfService extends ServiceClassInternal implements IVideoConf
},
{
creator: user._id,
subscriptionExtra: {
open: false,
},
},
);

Expand Down Expand Up @@ -1190,7 +1193,7 @@ export class VideoConfService extends ServiceClassInternal implements IVideoConf

private async addUserToDiscussion(rid: IRoom['_id'], uid: IUser['_id']): Promise<void> {
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({
Expand Down
27 changes: 27 additions & 0 deletions apps/meteor/tests/end-to-end/apps/video-conferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/core-services/src/types/IRoomService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface IRoomService {
options?: {
skipSystemMessage?: boolean;
skipAlertSound?: boolean;
createAsHidden?: boolean;
},
): Promise<boolean | undefined>;
removeUserFromRoom(roomId: string, user: IUser, options?: { byUser: Pick<IUser, '_id' | 'username'> }): Promise<void>;
Expand Down

0 comments on commit a4ef5ab

Please sign in to comment.