The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/app/api/server/v1/webdav.ts

53 lines
1.1 KiB

import Ajv from 'ajv';
import { API } from '../api';
import { findWebdavAccountsByUserId } from '../lib/webdav';
// TO-DO: remove this AJV instance and import one from the core-typings
const ajv = new Ajv({ coerceTypes: true });
type POSTRemoveWebdavAccount = {
accountId: string;
};
const POSTRemoveWebdavAccountSchema = {
type: 'object',
properties: {
accountId: {
type: 'string',
},
},
required: ['accountId'],
additionalProperties: false,
};
const isPOSTRemoveWebdavAccount = ajv.compile<POSTRemoveWebdavAccount>(POSTRemoveWebdavAccountSchema);
API.v1.addRoute(
'webdav.getMyAccounts',
{ authRequired: true },
{
async get() {
return API.v1.success({
accounts: await findWebdavAccountsByUserId({ uid: this.userId }),
});
},
},
);
API.v1.addRoute(
'webdav.removeWebdavAccount',
{
authRequired: true,
validateParams: isPOSTRemoveWebdavAccount,
},
{
async post() {
const { accountId } = this.bodyParams;
const result = await Meteor.callAsync('removeWebdavAccount', accountId);
return API.v1.success({ result });
},
},
);