index.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import TUIChatEngine, { IMessageModel } from '@tencentcloud/chat-uikit-engine';
  2. import { isCustomerServicePluginMessage } from './message-customer/index';
  3. import { JSONToObject } from '../../utils/type-check';
  4. export function isCallMessage(message: IMessageModel): boolean {
  5. const payloadData = JSONToObject(message?.payload?.data);
  6. if (payloadData?.businessID === 1 && payloadData?.data) {
  7. const payloadDataData = JSONToObject(payloadData.data);
  8. if (payloadDataData.businessID === 'av_call') {
  9. return true;
  10. }
  11. }
  12. return false;
  13. }
  14. export function isRoomSignalingMessage(message: IMessageModel): boolean {
  15. const payloadData = JSONToObject(message?.payload?.data);
  16. return (
  17. payloadData?.businessID === 'ROOM_INVITE_ACTION'
  18. || payloadData?.businessID === 'tuikit_engine_room'
  19. );
  20. }
  21. export function isRoomCardMessage(message: IMessageModel): boolean {
  22. const payloadData = JSONToObject(message?.payload?.data);
  23. return payloadData?.businessID === 'group_room_message';
  24. }
  25. export function isPluginMessage(message: IMessageModel): boolean {
  26. return (
  27. message.type === TUIChatEngine.TYPES.MSG_CUSTOM
  28. && (isCallMessage(message)
  29. || isCustomerServicePluginMessage(message as any)
  30. || isRoomCardMessage(message)
  31. || isRoomSignalingMessage(message))
  32. );
  33. }