From e2edb9e1fabe8396534ccf66bc387f6a13d80b44 Mon Sep 17 00:00:00 2001 From: Abhinav Kumar Date: Tue, 1 Oct 2024 06:34:52 +0530 Subject: [PATCH] chore!: removed removeWebdavAccount method (#33355) Signed-off-by: Abhinav Kumar --- .changeset/dull-singers-move.md | 5 +++ apps/meteor/app/api/server/v1/webdav.ts | 12 +++++- apps/meteor/app/webdav/server/index.ts | 1 - .../server/methods/removeWebdavAccount.ts | 42 ------------------- 4 files changed, 15 insertions(+), 45 deletions(-) create mode 100644 .changeset/dull-singers-move.md delete mode 100644 apps/meteor/app/webdav/server/methods/removeWebdavAccount.ts diff --git a/.changeset/dull-singers-move.md b/.changeset/dull-singers-move.md new file mode 100644 index 000000000000..6d744cc94611 --- /dev/null +++ b/.changeset/dull-singers-move.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +This adjustment removes the deprecated `removeWebdavAccount` method. Moving forward, use the `webdav.removeWebdavAccount` endpoint to remove WebDAV accounts. diff --git a/apps/meteor/app/api/server/v1/webdav.ts b/apps/meteor/app/api/server/v1/webdav.ts index b282d5ed6a56..2bdd2ba8f2e4 100644 --- a/apps/meteor/app/api/server/v1/webdav.ts +++ b/apps/meteor/app/api/server/v1/webdav.ts @@ -1,3 +1,5 @@ +import { api } from '@rocket.chat/core-services'; +import { WebdavAccounts } from '@rocket.chat/models'; import Ajv from 'ajv'; import { API } from '../api'; @@ -45,9 +47,15 @@ API.v1.addRoute( async post() { const { accountId } = this.bodyParams; - const result = await Meteor.callAsync('removeWebdavAccount', accountId); + const removed = await WebdavAccounts.removeByUserAndId(accountId, this.userId); + if (removed) { + void api.broadcast('notify.webdav', this.userId, { + type: 'removed', + account: { _id: accountId }, + }); + } - return API.v1.success({ result }); + return API.v1.success({ result: removed }); }, }, ); diff --git a/apps/meteor/app/webdav/server/index.ts b/apps/meteor/app/webdav/server/index.ts index d99d96c7c800..36bdfcae9332 100644 --- a/apps/meteor/app/webdav/server/index.ts +++ b/apps/meteor/app/webdav/server/index.ts @@ -1,5 +1,4 @@ import './methods/addWebdavAccount'; -import './methods/removeWebdavAccount'; import './methods/getWebdavFileList'; import './methods/getWebdavFilePreview'; import './methods/getFileFromWebdav'; diff --git a/apps/meteor/app/webdav/server/methods/removeWebdavAccount.ts b/apps/meteor/app/webdav/server/methods/removeWebdavAccount.ts deleted file mode 100644 index a68a14e29e40..000000000000 --- a/apps/meteor/app/webdav/server/methods/removeWebdavAccount.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { api } from '@rocket.chat/core-services'; -import type { IWebdavAccount } from '@rocket.chat/core-typings'; -import type { ServerMethods } from '@rocket.chat/ddp-client'; -import { WebdavAccounts } from '@rocket.chat/models'; -import { check } from 'meteor/check'; -import { Meteor } from 'meteor/meteor'; -import type { DeleteResult } from 'mongodb'; - -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; - -declare module '@rocket.chat/ddp-client' { - // eslint-disable-next-line @typescript-eslint/naming-convention - interface ServerMethods { - removeWebdavAccount(accountId: IWebdavAccount['_id']): DeleteResult; - } -} - -Meteor.methods({ - async removeWebdavAccount(accountId) { - const userId = Meteor.userId(); - - if (!userId) { - throw new Meteor.Error('error-invalid-user', 'Invalid User', { - method: 'removeWebdavAccount', - }); - } - - check(accountId, String); - - methodDeprecationLogger.method('removeWebdavAccount', '7.0.0'); - - const removed = await WebdavAccounts.removeByUserAndId(accountId, userId); - if (removed) { - void api.broadcast('notify.webdav', userId, { - type: 'removed', - account: { _id: accountId }, - }); - } - - return removed; - }, -});