diff --git a/apps/meteor/app/authorization/server/functions/canSendMessage.ts b/apps/meteor/app/authorization/server/functions/canSendMessage.ts index 3eb485e58dd4..bb879853bc2a 100644 --- a/apps/meteor/app/authorization/server/functions/canSendMessage.ts +++ b/apps/meteor/app/authorization/server/functions/canSendMessage.ts @@ -26,7 +26,7 @@ async function validateRoomMessagePermissionsAsync( throw new Error('error-not-allowed'); } - if (roomCoordinator.getRoomDirectives(room.t)?.allowMemberAction(room, RoomMemberActions.BLOCK, uid)) { + if (roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.BLOCK, uid)) { const subscription = await Subscriptions.findOneByRoomIdAndUserId(room._id, uid, subscriptionOptions); if (subscription && (subscription.blocked || subscription.blocker)) { throw new Error('room_is_blocked'); diff --git a/apps/meteor/app/channel-settings/server/functions/saveRoomName.js b/apps/meteor/app/channel-settings/server/functions/saveRoomName.js index c659ac01afac..97e50d20b09f 100644 --- a/apps/meteor/app/channel-settings/server/functions/saveRoomName.js +++ b/apps/meteor/app/channel-settings/server/functions/saveRoomName.js @@ -30,7 +30,7 @@ const updateRoomName = async (rid, displayName) => { export async function saveRoomName(rid, displayName, user, sendMessage = true) { const room = Rooms.findOneById(rid); - if (roomCoordinator.getRoomDirectives(room.t)?.preventRenaming()) { + if (roomCoordinator.getRoomDirectives(room.t).preventRenaming()) { throw new Meteor.Error('error-not-allowed', 'Not allowed', { function: 'RocketChat.saveRoomdisplayName', }); diff --git a/apps/meteor/app/channel-settings/server/functions/saveRoomType.js b/apps/meteor/app/channel-settings/server/functions/saveRoomType.js index cf76ca651930..d853abb8c93e 100644 --- a/apps/meteor/app/channel-settings/server/functions/saveRoomType.js +++ b/apps/meteor/app/channel-settings/server/functions/saveRoomType.js @@ -27,7 +27,7 @@ export const saveRoomType = function (rid, roomType, user, sendMessage = true) { }); } - if (!roomCoordinator.getRoomDirectives(room.t)?.allowRoomSettingChange(room, RoomSettingsEnum.TYPE)) { + if (!roomCoordinator.getRoomDirectives(room.t).allowRoomSettingChange(room, RoomSettingsEnum.TYPE)) { throw new Meteor.Error('error-direct-room', "Can't change type of direct rooms", { function: 'RocketChat.saveRoomType', }); diff --git a/apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts b/apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts index 6fe73a70b48f..467ead137069 100644 --- a/apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts +++ b/apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts @@ -100,7 +100,7 @@ const validators: RoomSettingsValidators = { }, async encrypted({ userId, value, room, rid }) { if (value !== room.encrypted) { - if (!roomCoordinator.getRoomDirectives(room.t)?.allowRoomSettingChange(room, RoomSettingsEnum.E2E)) { + if (!roomCoordinator.getRoomDirectives(room.t).allowRoomSettingChange(room, RoomSettingsEnum.E2E)) { throw new Meteor.Error('error-action-not-allowed', 'Only groups or direct channels can enable encryption', { method: 'saveRoomSettings', action: 'Change_Room_Encrypted', diff --git a/apps/meteor/app/discussion/server/methods/createDiscussion.ts b/apps/meteor/app/discussion/server/methods/createDiscussion.ts index 5adfb8a8c159..0149cc4e0741 100644 --- a/apps/meteor/app/discussion/server/methods/createDiscussion.ts +++ b/apps/meteor/app/discussion/server/methods/createDiscussion.ts @@ -128,7 +128,7 @@ const create = async ({ prid, pmid, t_name: discussionName, reply, users, user, // auto invite the replied message owner const invitedUsers = message ? [message.u.username, ...users] : users; - const type = await roomCoordinator.getRoomDirectives(parentRoom.t)?.getDiscussionType(parentRoom); + const type = await roomCoordinator.getRoomDirectives(parentRoom.t).getDiscussionType(parentRoom); const description = parentRoom.encrypted ? '' : message?.msg; const topic = parentRoom.name; diff --git a/apps/meteor/app/e2e/client/rocketchat.e2e.room.js b/apps/meteor/app/e2e/client/rocketchat.e2e.room.js index e7a3df723eb3..ca8b4a9afd6e 100644 --- a/apps/meteor/app/e2e/client/rocketchat.e2e.room.js +++ b/apps/meteor/app/e2e/client/rocketchat.e2e.room.js @@ -248,7 +248,7 @@ export class E2ERoom extends Emitter { } isSupportedRoomType(type) { - return roomCoordinator.getRoomDirectives(type)?.allowRoomSettingChange({}, RoomSettingsEnum.E2E); + return roomCoordinator.getRoomDirectives(type).allowRoomSettingChange({}, RoomSettingsEnum.E2E); } async importGroupKey(groupKey) { diff --git a/apps/meteor/app/file-upload/server/lib/FileUpload.js b/apps/meteor/app/file-upload/server/lib/FileUpload.js index afaa29c7aa52..4381a8806ad8 100644 --- a/apps/meteor/app/file-upload/server/lib/FileUpload.js +++ b/apps/meteor/app/file-upload/server/lib/FileUpload.js @@ -450,7 +450,7 @@ export const FileUpload = { } const isAuthorizedByRoom = () => - rc_room_type && roomCoordinator.getRoomDirectives(rc_room_type)?.canAccessUploadedFile({ rc_uid, rc_rid, rc_token }); + rc_room_type && roomCoordinator.getRoomDirectives(rc_room_type).canAccessUploadedFile({ rc_uid, rc_rid, rc_token }); const isAuthorizedByJWT = () => settings.get('FileUpload_Enable_json_web_token_for_files') && token && diff --git a/apps/meteor/app/invites/server/functions/findOrCreateInvite.js b/apps/meteor/app/invites/server/functions/findOrCreateInvite.js index 0d586ddc67da..369739d29a83 100644 --- a/apps/meteor/app/invites/server/functions/findOrCreateInvite.js +++ b/apps/meteor/app/invites/server/functions/findOrCreateInvite.js @@ -52,7 +52,7 @@ export const findOrCreateInvite = async (userId, invite) => { } const room = Rooms.findOneById(invite.rid); - if (!roomCoordinator.getRoomDirectives(room.t)?.allowMemberAction(room, RoomMemberActions.INVITE, userId)) { + if (!roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.INVITE, userId)) { throw new Meteor.Error('error-room-type-not-allowed', 'Cannot create invite links for this room type', { method: 'findOrCreateInvite', }); diff --git a/apps/meteor/app/invites/server/functions/useInviteToken.js b/apps/meteor/app/invites/server/functions/useInviteToken.js index b006c478b22a..0201b3e840f0 100644 --- a/apps/meteor/app/invites/server/functions/useInviteToken.js +++ b/apps/meteor/app/invites/server/functions/useInviteToken.js @@ -24,7 +24,7 @@ export const useInviteToken = async (userId, token) => { const { inviteData, room } = await validateInviteToken(token); - if (!roomCoordinator.getRoomDirectives(room.t)?.allowMemberAction(room, RoomMemberActions.INVITE, userId)) { + if (!roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.INVITE, userId)) { throw new Meteor.Error('error-room-type-not-allowed', "Can't join room of this type via invite", { method: 'useInviteToken', field: 'token', diff --git a/apps/meteor/app/lib/server/functions/notifications/desktop.js b/apps/meteor/app/lib/server/functions/notifications/desktop.js index b1962ac1321a..72223b17f924 100644 --- a/apps/meteor/app/lib/server/functions/notifications/desktop.js +++ b/apps/meteor/app/lib/server/functions/notifications/desktop.js @@ -15,7 +15,7 @@ import { settings } from '../../../../settings/server'; * @param {string} notificationMessage The message text to send on notification body */ export function notifyDesktopUser({ userId, user, message, room, duration, notificationMessage }) { - const { title, text } = roomCoordinator.getRoomDirectives(room.t)?.getNotificationDetails(room, user, notificationMessage, userId); + const { title, text } = roomCoordinator.getRoomDirectives(room.t).getNotificationDetails(room, user, notificationMessage, userId); const payload = { title, diff --git a/apps/meteor/app/lib/server/functions/notifications/email.js b/apps/meteor/app/lib/server/functions/notifications/email.js index e296997fe62c..5c0a4c44c75a 100644 --- a/apps/meteor/app/lib/server/functions/notifications/email.js +++ b/apps/meteor/app/lib/server/functions/notifications/email.js @@ -121,7 +121,7 @@ export function getEmailData({ message, receiver, sender, subscription, room, em const username = settings.get('UI_Use_Real_Name') ? message.u.name || message.u.username : message.u.username; let subjectKey = 'Offline_Mention_All_Email'; - if (!roomCoordinator.getRoomDirectives(room.t)?.isGroupChat(room)) { + if (!roomCoordinator.getRoomDirectives(room.t).isGroupChat(room)) { subjectKey = 'Offline_DM_Email'; } else if (hasMentionToUser) { subjectKey = 'Offline_Mention_Email'; diff --git a/apps/meteor/app/lib/server/functions/notifications/mobile.js b/apps/meteor/app/lib/server/functions/notifications/mobile.js index 88d125473639..5aa3a1793410 100644 --- a/apps/meteor/app/lib/server/functions/notifications/mobile.js +++ b/apps/meteor/app/lib/server/functions/notifications/mobile.js @@ -54,7 +54,7 @@ export async function getPushData({ ...(message.t === 'e2e' && { msg: message.msg }), }, roomName: - settings.get('Push_show_username_room') && roomCoordinator.getRoomDirectives(room.t)?.isGroupChat(room) + settings.get('Push_show_username_room') && roomCoordinator.getRoomDirectives(room.t).isGroupChat(room) ? `#${roomCoordinator.getRoomName(room.t, room, userId)}` : '', username, diff --git a/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.js b/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.js index bad95861f46d..b9813a5b9e35 100644 --- a/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.js +++ b/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.js @@ -217,7 +217,7 @@ export async function sendMessageNotifications(message, room, usersInThread = [] return; } - const sender = roomCoordinator.getRoomDirectives(room.t)?.getMsgSender(message.u._id); + const sender = roomCoordinator.getRoomDirectives(room.t).getMsgSender(message.u._id); if (!sender) { return message; } diff --git a/apps/meteor/app/lib/server/methods/archiveRoom.ts b/apps/meteor/app/lib/server/methods/archiveRoom.ts index 37de8d08e8f4..9b6b9e78e364 100644 --- a/apps/meteor/app/lib/server/methods/archiveRoom.ts +++ b/apps/meteor/app/lib/server/methods/archiveRoom.ts @@ -31,7 +31,7 @@ Meteor.methods({ throw new Meteor.Error('error-invalid-room', 'Invalid room', { method: 'archiveRoom' }); } - if (!roomCoordinator.getRoomDirectives(room.t)?.allowMemberAction(room, RoomMemberActions.ARCHIVE, userId)) { + if (!roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.ARCHIVE, userId)) { throw new Meteor.Error('error-direct-message-room', `rooms type: ${room.t} can not be archived`, { method: 'archiveRoom' }); } diff --git a/apps/meteor/app/lib/server/methods/blockUser.ts b/apps/meteor/app/lib/server/methods/blockUser.ts index 4275da6274cb..747ce7b6e4f7 100644 --- a/apps/meteor/app/lib/server/methods/blockUser.ts +++ b/apps/meteor/app/lib/server/methods/blockUser.ts @@ -25,7 +25,7 @@ Meteor.methods({ const room = Rooms.findOne({ _id: rid }); - if (!roomCoordinator.getRoomDirectives(room.t)?.allowMemberAction(room, RoomMemberActions.BLOCK, userId)) { + if (!roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.BLOCK, userId)) { throw new Meteor.Error('error-invalid-room', 'Invalid room', { method: 'blockUser' }); } diff --git a/apps/meteor/app/lib/server/methods/joinRoom.ts b/apps/meteor/app/lib/server/methods/joinRoom.ts index 4b748d2158e1..1fede2375f66 100644 --- a/apps/meteor/app/lib/server/methods/joinRoom.ts +++ b/apps/meteor/app/lib/server/methods/joinRoom.ts @@ -33,7 +33,7 @@ Meteor.methods({ throw new Meteor.Error('error-invalid-room', 'Invalid room', { method: 'joinRoom' }); } - if (!roomCoordinator.getRoomDirectives(room.t)?.allowMemberAction(room, RoomMemberActions.JOIN, user._id)) { + if (!roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.JOIN, user._id)) { throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'joinRoom' }); } diff --git a/apps/meteor/app/lib/server/methods/leaveRoom.ts b/apps/meteor/app/lib/server/methods/leaveRoom.ts index dde67e5b3438..d90fe5ca0217 100644 --- a/apps/meteor/app/lib/server/methods/leaveRoom.ts +++ b/apps/meteor/app/lib/server/methods/leaveRoom.ts @@ -29,7 +29,7 @@ Meteor.methods({ const room = Rooms.findOneById(rid); const user = Meteor.user() as unknown as IUser; - if (!user || !roomCoordinator.getRoomDirectives(room.t)?.allowMemberAction(room, RoomMemberActions.LEAVE, user._id)) { + if (!user || !roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.LEAVE, user._id)) { throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'leaveRoom' }); } diff --git a/apps/meteor/app/slashcommands-unarchiveroom/server/server.ts b/apps/meteor/app/slashcommands-unarchiveroom/server/server.ts index abed0da38631..a7fd6f76e97d 100644 --- a/apps/meteor/app/slashcommands-unarchiveroom/server/server.ts +++ b/apps/meteor/app/slashcommands-unarchiveroom/server/server.ts @@ -36,7 +36,7 @@ slashCommands.add({ } // You can not archive direct messages. - if (!roomCoordinator.getRoomDirectives(room.t)?.allowMemberAction(room, RoomMemberActions.ARCHIVE, userId)) { + if (!roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.ARCHIVE, userId)) { return; } diff --git a/apps/meteor/app/ui-utils/client/lib/LegacyRoomManager.ts b/apps/meteor/app/ui-utils/client/lib/LegacyRoomManager.ts index 5081fa08aa93..ed947b06ca9f 100644 --- a/apps/meteor/app/ui-utils/client/lib/LegacyRoomManager.ts +++ b/apps/meteor/app/ui-utils/client/lib/LegacyRoomManager.ts @@ -169,7 +169,7 @@ const computation = Tracker.autorun(() => { const type = typeName.slice(0, 1); const name = typeName.slice(1); - const room = roomCoordinator.getRoomDirectives(type)?.findRoom(name); + const room = roomCoordinator.getRoomDirectives(type).findRoom(name); void RoomHistoryManager.getMoreIfIsEmpty(record.rid); diff --git a/apps/meteor/app/ui-utils/client/lib/openRoom.tsx b/apps/meteor/app/ui-utils/client/lib/openRoom.tsx index fa145d5d0b46..3e293f94b120 100644 --- a/apps/meteor/app/ui-utils/client/lib/openRoom.tsx +++ b/apps/meteor/app/ui-utils/client/lib/openRoom.tsx @@ -31,7 +31,7 @@ export async function openRoom(type: RoomType, name: string, render = true) { } try { - const room = roomCoordinator.getRoomDirectives(type)?.findRoom(name) || (await call('getRoomByTypeAndName', type, name)); + const room = roomCoordinator.getRoomDirectives(type).findRoom(name) || (await call('getRoomByTypeAndName', type, name)); if (!room._id) { return; } diff --git a/apps/meteor/client/lib/rooms/roomCoordinator.ts b/apps/meteor/client/lib/rooms/roomCoordinator.ts index bf68d9f0d0fb..c303356c5e19 100644 --- a/apps/meteor/client/lib/rooms/roomCoordinator.ts +++ b/apps/meteor/client/lib/rooms/roomCoordinator.ts @@ -71,8 +71,8 @@ class RoomCoordinatorClient extends RoomCoordinator { super.addRoute(path, { ...routeConfig, triggersExit: [roomExit] }); } - getRoomDirectives(roomType: string): IRoomTypeClientDirectives | undefined { - return this.roomTypes[roomType]?.directives as IRoomTypeClientDirectives; + getRoomDirectives(roomType: string): IRoomTypeClientDirectives { + return this.roomTypes[roomType].directives as IRoomTypeClientDirectives; } getRoomTypeById(rid: string): RoomType | undefined { @@ -99,7 +99,7 @@ class RoomCoordinatorClient extends RoomCoordinator { } getIcon(room: Partial): IRoomTypeConfig['icon'] { - return room?.t && this.getRoomDirectives(room.t)?.getIcon(room); + return room?.t && this.getRoomDirectives(room.t).getIcon(room); } openRouteLink(roomType: RoomType, subData: RoomIdentification, queryParams?: Record): void { @@ -123,11 +123,11 @@ class RoomCoordinatorClient extends RoomCoordinator { } isLivechatRoom(roomType: string): boolean { - return Boolean(this.getRoomDirectives(roomType)?.isLivechatRoom()); + return Boolean(this.getRoomDirectives(roomType).isLivechatRoom()); } getRoomName(roomType: string, roomData: AtLeast): string { - return this.getRoomDirectives(roomType)?.roomName(roomData) ?? ''; + return this.getRoomDirectives(roomType).roomName(roomData) ?? ''; } readOnly(rid: string, user: AtLeast): boolean { @@ -184,7 +184,7 @@ class RoomCoordinatorClient extends RoomCoordinator { if (!room?.t) { return false; } - if (!this.getRoomDirectives(room.t)?.canSendMessage(rid)) { + if (!this.getRoomDirectives(room.t).canSendMessage(rid)) { return false; } if (isRoomFederated(room)) { diff --git a/apps/meteor/client/providers/AvatarUrlProvider.tsx b/apps/meteor/client/providers/AvatarUrlProvider.tsx index dd6b0ccc2366..18ad6b2e5f1e 100644 --- a/apps/meteor/client/providers/AvatarUrlProvider.tsx +++ b/apps/meteor/client/providers/AvatarUrlProvider.tsx @@ -20,7 +20,7 @@ const AvatarUrlProvider: FC = ({ children }) => { return (uid: string, etag?: string): string => getURL(`/avatar/${uid}${etag ? `?etag=${etag}` : ''}`); })(), getRoomPathAvatar: ({ type, ...room }: any): string => - roomCoordinator.getRoomDirectives(type || room.t)?.getAvatarPath({ username: room._id, ...room }) || '', + roomCoordinator.getRoomDirectives(type || room.t).getAvatarPath({ username: room._id, ...room }) || '', }), [externalProviderUrl, cdnAvatarUrl], ); diff --git a/apps/meteor/client/sidebar/RoomMenu.tsx b/apps/meteor/client/sidebar/RoomMenu.tsx index ae89918a9d1a..09903e66b59e 100644 --- a/apps/meteor/client/sidebar/RoomMenu.tsx +++ b/apps/meteor/client/sidebar/RoomMenu.tsx @@ -124,7 +124,7 @@ const RoomMenu = ({ closeModal(); }; - const warnText = roomCoordinator.getRoomDirectives(type)?.getUiText(UiTextContext.LEAVE_WARNING); + const warnText = roomCoordinator.getRoomDirectives(type).getUiText(UiTextContext.LEAVE_WARNING); setModal( const [canViewName, canViewTopic, canViewAnnouncement, canViewArchived, canViewDescription, canViewType, canViewReadOnly] = useMemo(() => { - const isAllowed = roomCoordinator.getRoomDirectives(room.t)?.allowRoomSettingChange; + const isAllowed = roomCoordinator.getRoomDirectives(room.t).allowRoomSettingChange; return [ isAllowed?.(room, RoomSettingsEnum.NAME), isAllowed?.(room, RoomSettingsEnum.TOPIC), diff --git a/apps/meteor/client/views/directory/tabs/channels/ChannelsTable/ChannelsTableRow.tsx b/apps/meteor/client/views/directory/tabs/channels/ChannelsTable/ChannelsTableRow.tsx index f5000e3d8428..df70a8040133 100644 --- a/apps/meteor/client/views/directory/tabs/channels/ChannelsTable/ChannelsTableRow.tsx +++ b/apps/meteor/client/views/directory/tabs/channels/ChannelsTable/ChannelsTableRow.tsx @@ -17,7 +17,7 @@ type ChannelsTableRowProps = { const ChannelsTableRow = ({ onClick, room, mediaQuery }: ChannelsTableRowProps) => { const formatDate = useFormatDate(); const { _id, ts, t, name, fname, usersCount, lastMessage, topic, belongsTo } = room; - const avatarUrl = roomCoordinator.getRoomDirectives(t)?.getAvatarPath(room); + const avatarUrl = roomCoordinator.getRoomDirectives(t).getAvatarPath(room); return ( diff --git a/apps/meteor/client/views/directory/tabs/teams/TeamsTable/TeamsTableRow.tsx b/apps/meteor/client/views/directory/tabs/teams/TeamsTable/TeamsTableRow.tsx index 1428feee4b0a..9c1abb18e69b 100644 --- a/apps/meteor/client/views/directory/tabs/teams/TeamsTable/TeamsTableRow.tsx +++ b/apps/meteor/client/views/directory/tabs/teams/TeamsTable/TeamsTableRow.tsx @@ -17,7 +17,7 @@ type TeamsTableRowProps = { const TeamsTableRow = ({ onClick, team, mediaQuery }: TeamsTableRowProps) => { const formatDate = useFormatDate(); const { _id, ts, t, name, fname, topic, roomsCount } = team; - const avatarUrl = roomCoordinator.getRoomDirectives(t)?.getAvatarPath(team); + const avatarUrl = roomCoordinator.getRoomDirectives(t).getAvatarPath(team); return ( diff --git a/apps/meteor/client/views/omnichannel/directory/components/ContactField.tsx b/apps/meteor/client/views/omnichannel/directory/components/ContactField.tsx index 456c7fd027ad..89e1404066c3 100644 --- a/apps/meteor/client/views/omnichannel/directory/components/ContactField.tsx +++ b/apps/meteor/client/views/omnichannel/directory/components/ContactField.tsx @@ -21,7 +21,7 @@ const ContactField = ({ contact, room }: ContactFieldProps) => { const t = useTranslation(); const { status } = contact; const { fname, t: type } = room; - const avatarUrl = roomCoordinator.getRoomDirectives(type)?.getAvatarPath(room) || ''; + const avatarUrl = roomCoordinator.getRoomDirectives(type).getAvatarPath(room) || ''; const getVisitorInfo = useEndpoint('GET', '/v1/livechat/visitors.info'); const { data, isLoading, isError } = useQuery(['/v1/livechat/visitors.info', contact._id], () => diff --git a/apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditChannel.js b/apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditChannel.js index 18c416b1cd40..b40f16712e89 100644 --- a/apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditChannel.js +++ b/apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditChannel.js @@ -205,7 +205,7 @@ function EditChannel({ room, onClickClose, onClickBack }) { canViewJoinCode, canViewEncrypted, ] = useMemo(() => { - const isAllowed = roomCoordinator.getRoomDirectives(room.t)?.allowRoomSettingChange || (() => {}); + const isAllowed = roomCoordinator.getRoomDirectives(room.t).allowRoomSettingChange || (() => {}); return [ isAllowed(room, RoomSettingsEnum.NAME), isAllowed(room, RoomSettingsEnum.TOPIC), diff --git a/apps/meteor/client/views/room/contextualBar/Info/hooks/actions/useRoomHide.tsx b/apps/meteor/client/views/room/contextualBar/Info/hooks/actions/useRoomHide.tsx index 8654fd4d43c7..5047e785c8e3 100644 --- a/apps/meteor/client/views/room/contextualBar/Info/hooks/actions/useRoomHide.tsx +++ b/apps/meteor/client/views/room/contextualBar/Info/hooks/actions/useRoomHide.tsx @@ -26,7 +26,7 @@ export const useRoomHide = (room: IRoom) => { setModal(null); }; - const warnText = roomCoordinator.getRoomDirectives(room.t)?.getUiText(UiTextContext.HIDE_WARNING); + const warnText = roomCoordinator.getRoomDirectives(room.t).getUiText(UiTextContext.HIDE_WARNING); setModal( { setModal(null); }; - const warnText = roomCoordinator.getRoomDirectives(room.t)?.getUiText(UiTextContext.LEAVE_WARNING); + const warnText = roomCoordinator.getRoomDirectives(room.t).getUiText(UiTextContext.LEAVE_WARNING); setModal( { } }; - const warnText = roomCoordinator.getRoomDirectives(room.t)?.getUiText(UiTextContext.HIDE_WARNING); + const warnText = roomCoordinator.getRoomDirectives(room.t).getUiText(UiTextContext.HIDE_WARNING); if (dontAskHideRoom) { return hide(); diff --git a/apps/meteor/ee/server/lib/message-read-receipt/ReadReceipt.js b/apps/meteor/ee/server/lib/message-read-receipt/ReadReceipt.js index 71b423d49b23..31b16a85f7b6 100644 --- a/apps/meteor/ee/server/lib/message-read-receipt/ReadReceipt.js +++ b/apps/meteor/ee/server/lib/message-read-receipt/ReadReceipt.js @@ -67,7 +67,7 @@ export const ReadReceipt = { await MessagesRaw.setAsReadById(message._id); } - const extraData = roomCoordinator.getRoomDirectives(t)?.getReadReceiptsExtraData(message); + const extraData = roomCoordinator.getRoomDirectives(t).getReadReceiptsExtraData(message); this.storeReadReceipts([{ _id: message._id }], roomId, userId, extraData); }, diff --git a/apps/meteor/server/lib/rooms/roomCoordinator.ts b/apps/meteor/server/lib/rooms/roomCoordinator.ts index 5a370de36c92..a4f6fcadf604 100644 --- a/apps/meteor/server/lib/rooms/roomCoordinator.ts +++ b/apps/meteor/server/lib/rooms/roomCoordinator.ts @@ -66,8 +66,8 @@ class RoomCoordinatorServer extends RoomCoordinator { }); } - getRoomDirectives(roomType: string): IRoomTypeServerDirectives | undefined { - return this.roomTypes[roomType]?.directives as IRoomTypeServerDirectives; + getRoomDirectives(roomType: string): IRoomTypeServerDirectives { + return this.roomTypes[roomType].directives as IRoomTypeServerDirectives; } openRoom(_type: string, _name: string, _render = true): void { @@ -79,7 +79,7 @@ class RoomCoordinatorServer extends RoomCoordinator { } getRoomName(roomType: string, roomData: IRoom, userId?: string): string { - return this.getRoomDirectives(roomType)?.roomName(roomData, userId) ?? ''; + return this.getRoomDirectives(roomType).roomName(roomData, userId) ?? ''; } setRoomFind(roomType: string, roomFind: Required>['roomFind']): void { @@ -96,7 +96,7 @@ class RoomCoordinatorServer extends RoomCoordinator { } getRoomFind(roomType: string): Required>['roomFind'] | undefined { - return this.getRoomDirectives(roomType)?.roomFind; + return this.getRoomDirectives(roomType).roomFind; } searchableRoomTypes(): Array { diff --git a/apps/meteor/server/methods/muteUserInRoom.ts b/apps/meteor/server/methods/muteUserInRoom.ts index fc37edd19915..e76429fc66ef 100644 --- a/apps/meteor/server/methods/muteUserInRoom.ts +++ b/apps/meteor/server/methods/muteUserInRoom.ts @@ -48,7 +48,7 @@ Meteor.methods({ }); } - if (!roomCoordinator.getRoomDirectives(room.t)?.allowMemberAction(room, RoomMemberActions.MUTE, fromId)) { + if (!roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.MUTE, fromId)) { throw new Meteor.Error('error-invalid-room-type', `${room.t} is not a valid room type`, { method: 'muteUserInRoom', type: room.t, diff --git a/apps/meteor/server/methods/removeUserFromRoom.ts b/apps/meteor/server/methods/removeUserFromRoom.ts index 5b883e2ac0df..69878f3e144e 100644 --- a/apps/meteor/server/methods/removeUserFromRoom.ts +++ b/apps/meteor/server/methods/removeUserFromRoom.ts @@ -44,7 +44,7 @@ Meteor.methods({ const room = Rooms.findOneById(data.rid); - if (!room || !roomCoordinator.getRoomDirectives(room.t)?.allowMemberAction(room, RoomMemberActions.REMOVE_USER, fromId)) { + if (!room || !roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.REMOVE_USER, fromId)) { throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'removeUserFromRoom', }); diff --git a/apps/meteor/server/methods/unmuteUserInRoom.ts b/apps/meteor/server/methods/unmuteUserInRoom.ts index 59137299f342..ed19cc3daa78 100644 --- a/apps/meteor/server/methods/unmuteUserInRoom.ts +++ b/apps/meteor/server/methods/unmuteUserInRoom.ts @@ -42,7 +42,7 @@ Meteor.methods({ }); } - if (!roomCoordinator.getRoomDirectives(room.t)?.allowMemberAction(room, RoomMemberActions.MUTE, fromId)) { + if (!roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.MUTE, fromId)) { throw new Meteor.Error('error-invalid-room-type', `${room.t} is not a valid room type`, { method: 'unmuteUserInRoom', type: room.t,