From 65167f1aede7650f3c236e6244ca64a90b621115 Mon Sep 17 00:00:00 2001 From: Tasso Date: Sat, 2 Nov 2024 00:06:41 -0300 Subject: [PATCH] Remove unused exports --- apps/meteor/app/assets/server/assets.ts | 2 +- .../app/authorization/client/hasPermission.ts | 21 ------------------- apps/meteor/app/authorization/client/index.ts | 6 +++--- apps/meteor/app/authorization/server/index.ts | 4 +--- .../functions/getWorkspaceAccessToken.ts | 11 ---------- .../supportedVersionsToken.ts | 2 +- .../app/e2e/server/functions/resetRoomKey.ts | 4 ++-- .../app/e2e/server/methods/updateGroupKey.ts | 2 +- apps/meteor/app/emoji/client/helpers.ts | 2 +- 9 files changed, 10 insertions(+), 44 deletions(-) diff --git a/apps/meteor/app/assets/server/assets.ts b/apps/meteor/app/assets/server/assets.ts index ef307f00b30c..bcb8fb8f08ee 100644 --- a/apps/meteor/app/assets/server/assets.ts +++ b/apps/meteor/app/assets/server/assets.ts @@ -365,7 +365,7 @@ class RocketChatAssetsClass { export const RocketChatAssets = new RocketChatAssetsClass(); -export async function addAssetToSetting(asset: string, value: IRocketChatAsset, options?: Partial): Promise { +async function addAssetToSetting(asset: string, value: IRocketChatAsset, options?: Partial): Promise { const key = `Assets_${asset}`; await settingsRegistry.add( diff --git a/apps/meteor/app/authorization/client/hasPermission.ts b/apps/meteor/app/authorization/client/hasPermission.ts index 66171aeadd28..d679401995ae 100644 --- a/apps/meteor/app/authorization/client/hasPermission.ts +++ b/apps/meteor/app/authorization/client/hasPermission.ts @@ -92,25 +92,4 @@ export const hasAllPermission = ( export const hasAtLeastOnePermission = (permissions: IPermission['_id'] | IPermission['_id'][], scope?: string): boolean => validatePermissions(permissions, scope, atLeastOne); -export const userHasAllPermission = ( - permissions: IPermission['_id'] | IPermission['_id'][], - scope?: string, - userId?: IUser['_id'] | null, -): boolean => validatePermissions(permissions, scope, all, userId); - export const hasPermission = hasAllPermission; - -/** - * This function is used to check if the user will have the permission after something happens. - * For example, The user is creating a new channel and he wants to set read-only config to true. - * This is a problem, set-readonly is a permission related with the scoped permissions `owner` - * so the user cannot set this permission to true during the channel creation, because there is no room yet to be owned and used as scope, but is possible - * during the channel update, which is weird. - * - * @param permissions The permissions to check - * @param scopedRoles The scoped roles to check to be included in the user roles - * @returns If the user will have the permission - */ - -export const willHavePermission = (permissions: IPermission['_id'] | IPermission['_id'][], scopedRoles: IPermission['_id'][]): boolean => - validatePermissions(permissions, undefined, all, undefined, scopedRoles); diff --git a/apps/meteor/app/authorization/client/index.ts b/apps/meteor/app/authorization/client/index.ts index 7dc1a3466f49..45e73b943eba 100644 --- a/apps/meteor/app/authorization/client/index.ts +++ b/apps/meteor/app/authorization/client/index.ts @@ -1,5 +1,5 @@ -import { hasAllPermission, hasAtLeastOnePermission, hasPermission, userHasAllPermission } from './hasPermission'; -import { hasRole, hasAnyRole } from './hasRole'; +import { hasAllPermission, hasAtLeastOnePermission, hasPermission } from './hasPermission'; +import { hasRole } from './hasRole'; import './restrictedRoles'; -export { hasAllPermission, hasAtLeastOnePermission, hasRole, hasAnyRole, hasPermission, userHasAllPermission }; +export { hasAllPermission, hasAtLeastOnePermission, hasRole, hasPermission }; diff --git a/apps/meteor/app/authorization/server/index.ts b/apps/meteor/app/authorization/server/index.ts index a91e23610230..098aa50c27b9 100644 --- a/apps/meteor/app/authorization/server/index.ts +++ b/apps/meteor/app/authorization/server/index.ts @@ -1,6 +1,4 @@ import { roomAccessAttributes, canAccessRoomAsync } from './functions/canAccessRoom'; -import { getRoles } from './functions/getRoles'; -import { getUsersInRole } from './functions/getUsersInRole'; import { subscriptionHasRole } from './functions/hasRole'; import './methods/addPermissionToRole'; import './methods/addUserToRole'; @@ -9,4 +7,4 @@ import './methods/removeRoleFromPermission'; import './methods/removeUserFromRole'; import './streamer/permissions'; -export { getRoles, getUsersInRole, subscriptionHasRole, canAccessRoomAsync, roomAccessAttributes }; +export { subscriptionHasRole, canAccessRoomAsync, roomAccessAttributes }; diff --git a/apps/meteor/app/cloud/server/functions/getWorkspaceAccessToken.ts b/apps/meteor/app/cloud/server/functions/getWorkspaceAccessToken.ts index 6595c8e90fc4..e882cf2d504f 100644 --- a/apps/meteor/app/cloud/server/functions/getWorkspaceAccessToken.ts +++ b/apps/meteor/app/cloud/server/functions/getWorkspaceAccessToken.ts @@ -85,17 +85,6 @@ export async function getWorkspaceAccessTokenOrThrow(forceNew = false, scope = ' return token; } -export const generateWorkspaceBearerHttpHeaderOrThrow = async ( - forceNew = false, - scope = '', - save = true, -): Promise<{ Authorization: string }> => { - const token = await getWorkspaceAccessTokenOrThrow(forceNew, scope, save); - return { - Authorization: `Bearer ${token}`, - }; -}; - export const generateWorkspaceBearerHttpHeader = async ( forceNew = false, scope = '', diff --git a/apps/meteor/app/cloud/server/functions/supportedVersionsToken/supportedVersionsToken.ts b/apps/meteor/app/cloud/server/functions/supportedVersionsToken/supportedVersionsToken.ts index 68e38baf5cc2..dfd9031eae20 100644 --- a/apps/meteor/app/cloud/server/functions/supportedVersionsToken/supportedVersionsToken.ts +++ b/apps/meteor/app/cloud/server/functions/supportedVersionsToken/supportedVersionsToken.ts @@ -40,7 +40,7 @@ export const wrapPromise = ( error, })); -export const handleResponse = async (promise: Promise) => { +const handleResponse = async (promise: Promise) => { return wrapPromise( (async () => { const request = await promise; diff --git a/apps/meteor/app/e2e/server/functions/resetRoomKey.ts b/apps/meteor/app/e2e/server/functions/resetRoomKey.ts index 89a0058e48ae..65d7137a63a0 100644 --- a/apps/meteor/app/e2e/server/functions/resetRoomKey.ts +++ b/apps/meteor/app/e2e/server/functions/resetRoomKey.ts @@ -88,7 +88,7 @@ export async function resetRoomKey(roomId: string, userId: string, newRoomKey: s } } -export function pushToLimit( +function pushToLimit( arr: NonNullable, item: NonNullable[number], limit = 50, @@ -107,7 +107,7 @@ async function writeAndNotify(updateOps: AnyBulkWriteOperation[], updateOps.length = 0; } -export function replicateMongoSlice(keyId: string, sub: ISubscription) { +function replicateMongoSlice(keyId: string, sub: ISubscription) { if (!sub.E2EKey) { return; } diff --git a/apps/meteor/app/e2e/server/methods/updateGroupKey.ts b/apps/meteor/app/e2e/server/methods/updateGroupKey.ts index 5f7860107bd9..8561bb675524 100644 --- a/apps/meteor/app/e2e/server/methods/updateGroupKey.ts +++ b/apps/meteor/app/e2e/server/methods/updateGroupKey.ts @@ -16,7 +16,7 @@ declare module '@rocket.chat/ddp-client' { } } -export async function updateGroupKey(rid: string, uid: string, key: string, callerUserId: string) { +async function updateGroupKey(rid: string, uid: string, key: string, callerUserId: string) { // I have a subscription to this room const mySub = await Subscriptions.findOneByRoomIdAndUserId(rid, callerUserId); diff --git a/apps/meteor/app/emoji/client/helpers.ts b/apps/meteor/app/emoji/client/helpers.ts index 35badda26a73..10e1ce8ccb21 100644 --- a/apps/meteor/app/emoji/client/helpers.ts +++ b/apps/meteor/app/emoji/client/helpers.ts @@ -138,7 +138,7 @@ export const getEmojisBySearchTerm = ( return emojis; }; -export const removeFromRecent = (emoji: string, recentEmojis: string[], setRecentEmojis: (emojis: string[]) => void) => { +const removeFromRecent = (emoji: string, recentEmojis: string[], setRecentEmojis: (emojis: string[]) => void) => { const _emoji = emoji.replace(/(^:|:$)/g, ''); const pos = recentEmojis.indexOf(_emoji as never);