chore!: removes `livechat:getAnalyticsChartData` deprecated method (#36925)

pull/35380/merge
Lucas Pelegrino 2 months ago committed by Guilherme Gazzo
parent bd7b11eafa
commit 43a4ec0676
  1. 5
      .changeset/fifty-rice-smash.md
  2. 1
      apps/meteor/app/livechat/server/index.ts
  3. 39
      apps/meteor/app/livechat/server/methods/getAnalyticsChartData.ts

@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": major
---
Removes deprecated Realtime API method: `livechat:getAnalyticsChartData`

@ -14,7 +14,6 @@ import './hooks/saveLastMessageToInquiry';
import './hooks/afterUserActions';
import './hooks/afterAgentRemoved';
import './hooks/afterSaveOmnichannelMessage';
import './methods/getAnalyticsChartData';
import './methods/removeCustomField';
import './methods/removeRoom';
import './methods/saveAgentInfo';

@ -1,39 +0,0 @@
import type { ChartDataResult } from '@rocket.chat/core-services';
import { OmnichannelAnalytics } from '@rocket.chat/core-services';
import type { ServerMethods } from '@rocket.chat/ddp-client';
import { Users } from '@rocket.chat/models';
import { Meteor } from 'meteor/meteor';
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:getAnalyticsChartData'(options: { chartOptions: { name: string } }): ChartDataResult | void;
}
}
Meteor.methods<ServerMethods>({
async 'livechat:getAnalyticsChartData'(options) {
methodDeprecationLogger.method('livechat:getAnalyticsChartData', '8.0.0', '/v1/livechat/analytics/dashboards/charts-data');
const userId = Meteor.userId();
if (!userId || !(await hasPermissionAsync(userId, 'view-livechat-manager'))) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', {
method: 'livechat:getAnalyticsChartData',
});
}
if (!options.chartOptions?.name) {
return;
}
const user = await Users.findOneById(userId, { projection: { _id: 1, utcOffset: 1 } });
if (!user) {
return;
}
return OmnichannelAnalytics.getAnalyticsChartData({ ...options, utcOffset: user?.utcOffset, executedBy: userId });
},
});
Loading…
Cancel
Save