Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Hide discussions created for Video Conference Calls #34128

Merged
merged 8 commits into from
Dec 16, 2024
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, { skipAlertSound: true, skipSystemMessage: true, createAsHidden: true });
lucas-a-pelegrino marked this conversation as resolved.
Show resolved Hide resolved
} 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 the discussion room with hidden subscription flag', async function () {
lucas-a-pelegrino marked this conversation as resolved.
Show resolved Hide resolved
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
Loading