chore!: remove deprecated `removeCustomField` method (#37390)

pull/35380/merge
Júlia Jaeger Foresti 2 months ago committed by Guilherme Gazzo
parent 740de58aff
commit 83e1f76609
  1. 5
      .changeset/forty-spiders-sneeze.md
  2. 1
      apps/meteor/app/livechat/server/index.ts
  3. 38
      apps/meteor/app/livechat/server/methods/removeCustomField.ts

@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': major
---
Removes deprecated `removeCustomField` method

@ -14,7 +14,6 @@ import './hooks/saveLastMessageToInquiry';
import './hooks/afterUserActions';
import './hooks/afterAgentRemoved';
import './hooks/afterSaveOmnichannelMessage';
import './methods/removeCustomField';
import './methods/saveCustomField';
import './methods/saveDepartment';
import './methods/sendMessageLivechat';

@ -1,38 +0,0 @@
import type { ServerMethods } from '@rocket.chat/ddp-client';
import { LivechatCustomField } from '@rocket.chat/models';
import { check } from 'meteor/check';
import { Meteor } from 'meteor/meteor';
import type { DeleteResult } from 'mongodb';
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger';
declare module '@rocket.chat/ddp-client' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {
'livechat:removeCustomField'(_id: string): DeleteResult;
}
}
Meteor.methods<ServerMethods>({
async 'livechat:removeCustomField'(_id) {
methodDeprecationLogger.method('livechat:removeCustomField', '8.0.0', '/v1/livechat/custom-fields.delete');
const uid = Meteor.userId();
if (!uid || !(await hasPermissionAsync(uid, 'view-livechat-manager'))) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', {
method: 'livechat:removeCustomField',
});
}
check(_id, String);
const customField = await LivechatCustomField.findOneById(_id, { projection: { _id: 1 } });
if (!customField) {
throw new Meteor.Error('error-invalid-custom-field', 'Custom field not found', {
method: 'livechat:removeCustomField',
});
}
return LivechatCustomField.removeById(_id);
},
});
Loading…
Cancel
Save