Skip to content
Snippets Groups Projects
Commit 2511b8b3 authored by Abhinav Kumar's avatar Abhinav Kumar Committed by Guilherme Gazzo
Browse files

chore!: removed removeWebdavAccount method (#33355)

parent 7eb29051
No related branches found
No related tags found
No related merge requests found
---
'@rocket.chat/meteor': patch
---
This adjustment removes the deprecated `removeWebdavAccount` method. Moving forward, use the `webdav.removeWebdavAccount` endpoint to remove WebDAV accounts.
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 });
},
},
);
import './methods/addWebdavAccount';
import './methods/removeWebdavAccount';
import './methods/getWebdavFileList';
import './methods/getWebdavFilePreview';
import './methods/getFileFromWebdav';
......
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<ServerMethods>({
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;
},
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment