Skip to content

Commit

Permalink
Validate room type before dismissing notification
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-lehnen-rc committed Dec 8, 2023
1 parent bead724 commit 9bb47f4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions apps/meteor/app/lib/server/functions/notifications/mobile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Subscriptions } from '@rocket.chat/models';

import { i18n } from '../../../../../server/lib/i18n';
import { isRoomCompatibleWithVideoConfRinging } from '../../../../../server/lib/isRoomCompatibleWithVideoConfRinging';
import { roomCoordinator } from '../../../../../server/lib/rooms/roomCoordinator';
import { settings } from '../../../../settings/server';

Expand Down Expand Up @@ -75,6 +76,7 @@ export function shouldNotifyMobile({
isThread,
isVideoConf,
userPreferences,
roomUids,
}) {
if (settings.get('Push_enable') !== true) {
return false;
Expand All @@ -92,6 +94,7 @@ export function shouldNotifyMobile({
if (
isVideoConf &&
settings.get('VideoConf_Mobile_Ringing') &&
isRoomCompatibleWithVideoConfRinging(roomType, roomUids) &&
(userPreferences?.enableMobileRinging ?? settings.get(`Accounts_Default_User_Preferences_enableMobileRinging`))
) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export const sendNotification = async ({
isThread,
isVideoConf,
userPreferences: receiver.settings?.preferences,
roomUids: room.uids,
})
) {
queueItems.push({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { IRoom } from '@rocket.chat/core-typings';

export const isRoomCompatibleWithVideoConfRinging = (roomType: IRoom['t'], roomUids: IRoom['uids']): boolean =>
Boolean(roomType === 'd' && roomUids && roomUids.length <= 2);
3 changes: 2 additions & 1 deletion apps/meteor/server/services/video-conference/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { callbacks } from '../../../lib/callbacks';
import { availabilityErrors } from '../../../lib/videoConference/constants';
import { readSecondaryPreferred } from '../../database/readSecondaryPreferred';
import { i18n } from '../../lib/i18n';
import { isRoomCompatibleWithVideoConfRinging } from '../../lib/isRoomCompatibleWithVideoConfRinging';
import { videoConfProviders } from '../../lib/videoConfProviders';
import { videoConfTypes } from '../../lib/videoConfTypes';

Expand Down Expand Up @@ -73,7 +74,7 @@ export class VideoConfService extends ServiceClassInternal implements IVideoConf
}

if (type === 'direct') {
if (room.t !== 'd' || !room.uids || room.uids.length > 2) {
if (!isRoomCompatibleWithVideoConfRinging(room.t, room.uids)) {
throw new Error('type-and-room-not-compatible');
}

Expand Down

0 comments on commit 9bb47f4

Please sign in to comment.