From a68e2fbba9c37e2ba64f44d5447e52c1c54e7f66 Mon Sep 17 00:00:00 2001 From: Abhinav Kumar Date: Sat, 17 Aug 2024 06:16:04 +0530 Subject: [PATCH] chore!: removed checkUsernameAvailability method (#32488) --- apps/meteor/app/lib/server/index.ts | 1 - .../methods/checkUsernameAvailability.ts | 34 ------------------- 2 files changed, 35 deletions(-) delete mode 100644 apps/meteor/app/lib/server/methods/checkUsernameAvailability.ts diff --git a/apps/meteor/app/lib/server/index.ts b/apps/meteor/app/lib/server/index.ts index 49fad2002c753..ecfdb2ed81cd1 100644 --- a/apps/meteor/app/lib/server/index.ts +++ b/apps/meteor/app/lib/server/index.ts @@ -13,7 +13,6 @@ import './methods/addUserToRoom'; import './methods/archiveRoom'; import './methods/blockUser'; import './methods/checkRegistrationSecretURL'; -import './methods/checkUsernameAvailability'; import './methods/cleanRoomHistory'; import './methods/createChannel'; import './methods/createPrivateGroup'; diff --git a/apps/meteor/app/lib/server/methods/checkUsernameAvailability.ts b/apps/meteor/app/lib/server/methods/checkUsernameAvailability.ts deleted file mode 100644 index 4df2706bb4796..0000000000000 --- a/apps/meteor/app/lib/server/methods/checkUsernameAvailability.ts +++ /dev/null @@ -1,34 +0,0 @@ -import type { ServerMethods } from '@rocket.chat/ddp-client'; -import { check } from 'meteor/check'; -import { Meteor } from 'meteor/meteor'; - -import { checkUsernameAvailabilityWithValidation } from '../functions/checkUsernameAvailability'; -import { RateLimiter } from '../lib'; -import { methodDeprecationLogger } from '../lib/deprecationWarningLogger'; - -declare module '@rocket.chat/ddp-client' { - // eslint-disable-next-line @typescript-eslint/naming-convention - interface ServerMethods { - checkUsernameAvailability(username: string): boolean; - } -} - -Meteor.methods({ - async checkUsernameAvailability(username) { - methodDeprecationLogger.method('checkUsernameAvailability', '7.0.0'); - - check(username, String); - const userId = Meteor.userId(); - if (!userId) { - throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'checkUsernameAvailability' }); - } - - return checkUsernameAvailabilityWithValidation(userId, username); - }, -}); - -RateLimiter.limitMethod('checkUsernameAvailability', 1, 1000, { - userId() { - return true; - }, -});