Skip to content

Commit

Permalink
types of endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman committed Oct 6, 2023
1 parent 5891651 commit 159b0b0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
25 changes: 25 additions & 0 deletions apps/meteor/app/livechat/server/hooks/checkMAC.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Omnichannel } from '@rocket.chat/core-services';
import { isEditedMessage } from '@rocket.chat/core-typings';

import { callbacks } from '../../../../lib/callbacks';

callbacks.add('beforeSaveMessage', async (message, room) => {
if (!room || room.t !== 'l') {
return message;
}

if (isEditedMessage(message)) {
return message;
}

if (message.token) {
return message;
}

const canSendMessage = await Omnichannel.isRoomEnabled(room);
if (!canSendMessage) {
throw new Error('error-mac-limit-reached');
}

return message;
});
1 change: 1 addition & 0 deletions apps/meteor/app/livechat/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import './hooks/saveContactLastChat';
import './hooks/saveLastMessageToInquiry';
import './hooks/afterUserActions';
import './hooks/afterAgentRemoved';
import './hooks/checkMAC';
import './methods/addAgent';
import './methods/addManager';
import './methods/changeLivechatStatus';
Expand Down
3 changes: 3 additions & 0 deletions packages/rest-typings/src/v1/omnichannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3699,6 +3699,9 @@ export type OmnichannelEndpoints = {
value: string | number;
}[];
};
'/v1/omnichannel/mac/check': {
GET: () => { onLimit: boolean };
};
} & {
// EE
'/v1/livechat/analytics/agents/average-service-time': {
Expand Down

0 comments on commit 159b0b0

Please sign in to comment.