Chore: Unsupported system messages (#4047)
* chore: unsupported system messages * add: Livechat's ignored system messages * add: `IGNORED_LIVECHAT_SYSTEM_MESSAGES` * add: support for Livechat's system messages * remove: `console.log`
This commit is contained in:
parent
06a0c4f730
commit
edfeeb80d3
|
@ -5,7 +5,7 @@ import { Subscription } from 'rxjs';
|
|||
import Message from './Message';
|
||||
import MessageContext from './Context';
|
||||
import debounce from '../../utils/debounce';
|
||||
import { SYSTEM_MESSAGES, getMessageTranslation } from './utils';
|
||||
import { getMessageTranslation } from './utils';
|
||||
import { TSupportedThemes, withTheme } from '../../theme';
|
||||
import openLink from '../../utils/openLink';
|
||||
import { TGetCustomEmoji } from '../../definitions/IEmoji';
|
||||
|
@ -31,6 +31,7 @@ interface IMessageContainerProps {
|
|||
Message_GroupingPeriod?: number;
|
||||
isReadReceiptEnabled?: boolean;
|
||||
isThreadRoom: boolean;
|
||||
isSystemMessage?: boolean;
|
||||
useRealName?: boolean;
|
||||
autoTranslateRoom?: boolean;
|
||||
autoTranslateLanguage?: string;
|
||||
|
@ -254,9 +255,12 @@ class MessageContainer extends React.Component<IMessageContainerProps, IMessageC
|
|||
return t === E2E_MESSAGE_TYPE && e2e !== E2E_STATUS.DONE;
|
||||
}
|
||||
|
||||
get isInfo(): boolean {
|
||||
get isInfo(): string | boolean {
|
||||
const { item } = this.props;
|
||||
return (item.t && SYSTEM_MESSAGES.includes(item.t)) ?? false;
|
||||
if (['e2e', 'discussion-created'].includes(item.t)) {
|
||||
return false;
|
||||
}
|
||||
return item.t;
|
||||
}
|
||||
|
||||
get isTemp(): boolean {
|
||||
|
|
|
@ -45,7 +45,7 @@ export interface IMessageCallButton {
|
|||
export interface IMessageContent {
|
||||
_id: string;
|
||||
isTemp: boolean;
|
||||
isInfo: boolean;
|
||||
isInfo: string | boolean;
|
||||
tmid?: string;
|
||||
isThreadRoom: boolean;
|
||||
msg?: string;
|
||||
|
@ -76,7 +76,7 @@ export interface IMessageThread extends Pick<IThread, 'msg' | 'tcount' | 'tlm' |
|
|||
|
||||
export interface IMessageTouchable {
|
||||
hasError: boolean;
|
||||
isInfo: boolean;
|
||||
isInfo: string | boolean;
|
||||
isThreadReply: boolean;
|
||||
isTemp: boolean;
|
||||
archived?: boolean;
|
||||
|
@ -110,7 +110,7 @@ export interface IMessageInner
|
|||
export interface IMessage extends IMessageRepliedThread, IMessageInner, IMessageAvatar {
|
||||
isThreadReply: boolean;
|
||||
isThreadSequential: boolean;
|
||||
isInfo: boolean;
|
||||
isInfo: string | boolean;
|
||||
isTemp: boolean;
|
||||
isHeader: boolean;
|
||||
hasError: boolean;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable complexity */
|
||||
import { TMessageModel } from '../../definitions/IMessage';
|
||||
import I18n from '../../i18n';
|
||||
import { DISCUSSION } from './constants';
|
||||
|
@ -56,10 +57,25 @@ export const SYSTEM_MESSAGES = [
|
|||
'user-converted-to-channel',
|
||||
'user-deleted-room-from-team',
|
||||
'user-removed-room-from-team',
|
||||
'room-disallowed-reacting',
|
||||
'room-allowed-reacting',
|
||||
'room-set-read-only',
|
||||
'room-removed-read-only',
|
||||
'omnichannel_placed_chat_on_hold',
|
||||
'omnichannel_on_hold_chat_resumed'
|
||||
];
|
||||
|
||||
export const IGNORED_LIVECHAT_SYSTEM_MESSAGES = [
|
||||
'livechat_navigation_history',
|
||||
'livechat_transcript_history',
|
||||
'livechat_transfer_history',
|
||||
'command',
|
||||
'livechat-close',
|
||||
'livechat-started',
|
||||
'livechat_video_call',
|
||||
'livechat_webrtc_video_call'
|
||||
];
|
||||
|
||||
export const SYSTEM_MESSAGE_TYPES = {
|
||||
MESSAGE_REMOVED: 'rm',
|
||||
MESSAGE_PINNED: 'message_pinned',
|
||||
|
@ -77,7 +93,15 @@ export const SYSTEM_MESSAGE_TYPES = {
|
|||
DELETED_ROOM_FROM_TEAM: 'user-deleted-room-from-team',
|
||||
REMOVED_ROOM_FROM_TEAM: 'user-removed-room-from-team',
|
||||
OMNICHANNEL_PLACED_CHAT_ON_HOLD: 'omnichannel_placed_chat_on_hold',
|
||||
OMNICHANNEL_ON_HOLD_CHAT_RESUMED: 'omnichannel_on_hold_chat_resumed'
|
||||
OMNICHANNEL_ON_HOLD_CHAT_RESUMED: 'omnichannel_on_hold_chat_resumed',
|
||||
LIVECHAT_NAVIGATION_HISTORY: 'livechat_navigation_history',
|
||||
LIVECHAT_TRANSCRIPT_HISTORY: 'livechat_transcript_history',
|
||||
COMMAND: 'command',
|
||||
LIVECHAT_STARTED: 'livechat-started',
|
||||
LIVECHAT_CLOSE: 'livechat-close',
|
||||
LIVECHAT_VIDEO_CALL: 'livechat_video_call',
|
||||
LIVECHAT_WEBRTC_VIDEO_CALL: 'livechat_webrtc_video_call',
|
||||
LIVECHAT_TRANSFER_HISTORY: 'livechat_transfer_history'
|
||||
};
|
||||
|
||||
export const SYSTEM_MESSAGE_TYPES_WITH_AUTHOR_NAME = [
|
||||
|
@ -95,7 +119,15 @@ export const SYSTEM_MESSAGE_TYPES_WITH_AUTHOR_NAME = [
|
|||
SYSTEM_MESSAGE_TYPES.CONVERTED_TO_TEAM,
|
||||
SYSTEM_MESSAGE_TYPES.CONVERTED_TO_CHANNEL,
|
||||
SYSTEM_MESSAGE_TYPES.DELETED_ROOM_FROM_TEAM,
|
||||
SYSTEM_MESSAGE_TYPES.REMOVED_ROOM_FROM_TEAM
|
||||
SYSTEM_MESSAGE_TYPES.REMOVED_ROOM_FROM_TEAM,
|
||||
SYSTEM_MESSAGE_TYPES.LIVECHAT_NAVIGATION_HISTORY,
|
||||
SYSTEM_MESSAGE_TYPES.LIVECHAT_TRANSCRIPT_HISTORY,
|
||||
SYSTEM_MESSAGE_TYPES.COMMAND,
|
||||
SYSTEM_MESSAGE_TYPES.LIVECHAT_STARTED,
|
||||
SYSTEM_MESSAGE_TYPES.LIVECHAT_CLOSE,
|
||||
SYSTEM_MESSAGE_TYPES.LIVECHAT_VIDEO_CALL,
|
||||
SYSTEM_MESSAGE_TYPES.LIVECHAT_WEBRTC_VIDEO_CALL,
|
||||
SYSTEM_MESSAGE_TYPES.LIVECHAT_TRANSFER_HISTORY
|
||||
];
|
||||
|
||||
type TInfoMessage = {
|
||||
|
@ -108,6 +140,7 @@ type TInfoMessage = {
|
|||
|
||||
export const getInfoMessage = ({ type, role, msg, author, comment }: TInfoMessage): string => {
|
||||
const { username } = author;
|
||||
|
||||
if (type === 'rm') {
|
||||
return I18n.t('Message_removed');
|
||||
}
|
||||
|
@ -198,13 +231,37 @@ export const getInfoMessage = ({ type, role, msg, author, comment }: TInfoMessag
|
|||
if (type === 'user-removed-room-from-team') {
|
||||
return I18n.t('Removed__roomName__from_this_team', { roomName: msg });
|
||||
}
|
||||
if (type === 'room-disallowed-reacting') {
|
||||
return I18n.t('Room_disallowed_reacting', { userBy: username });
|
||||
}
|
||||
if (type === 'room-allowed-reacting') {
|
||||
return I18n.t('Room_allowed_reacting', { userBy: username });
|
||||
}
|
||||
if (type === 'room-set-read-only') {
|
||||
return I18n.t('Room_set_read_only', { userBy: username });
|
||||
}
|
||||
if (type === 'room-removed-read-only') {
|
||||
return I18n.t('Room_removed_read_only', { userBy: username });
|
||||
}
|
||||
if (type === 'omnichannel_placed_chat_on_hold') {
|
||||
return I18n.t('Omnichannel_placed_chat_on_hold', { comment });
|
||||
}
|
||||
if (type === 'omnichannel_on_hold_chat_resumed') {
|
||||
return I18n.t('Omnichannel_on_hold_chat_resumed', { comment });
|
||||
}
|
||||
return '';
|
||||
if (type === 'command') {
|
||||
return I18n.t('Livechat_transfer_return_to_the_queue');
|
||||
}
|
||||
if (type === 'livechat-started') {
|
||||
return I18n.t('Chat_started');
|
||||
}
|
||||
if (type === 'livechat-close') {
|
||||
return I18n.t('Conversation_closed');
|
||||
}
|
||||
if (type === 'livechat_transfer_history') {
|
||||
return I18n.t('New_chat_transfer', { agent: username });
|
||||
}
|
||||
return I18n.t('Unsupported_system_message');
|
||||
};
|
||||
|
||||
export const getMessageTranslation = (message: TMessageModel, autoTranslateLanguage: string) => {
|
||||
|
|
|
@ -132,6 +132,7 @@
|
|||
"Channel_Name": "Channel Name",
|
||||
"Channels": "Channels",
|
||||
"Chats": "Chats",
|
||||
"Chat_started": "Chat started",
|
||||
"Call_already_ended": "Call already ended!",
|
||||
"Clear_cookies_alert": "Do you want to clear all cookies?",
|
||||
"Clear_cookies_desc": "This action will clear all login cookies, allowing you to login into other accounts.",
|
||||
|
@ -149,6 +150,7 @@
|
|||
"Choose_where_you_want_links_be_opened": "Choose where you want links be opened",
|
||||
"Code": "Code",
|
||||
"Code_or_password_invalid": "Code or password invalid",
|
||||
"Conversation_closed": "Conversation closed",
|
||||
"Collaborative": "Collaborative",
|
||||
"Confirm": "Confirm",
|
||||
"Connect": "Connect",
|
||||
|
@ -301,6 +303,7 @@
|
|||
"License": "License",
|
||||
"Livechat": "Livechat",
|
||||
"Livechat_edit": "Livechat edit",
|
||||
"Livechat_transfer_return_to_the_queue": "returned the chat to the queue",
|
||||
"Login": "Login",
|
||||
"Login_error": "Your credentials were rejected! Please try again.",
|
||||
"Login_with": "Login with",
|
||||
|
@ -334,6 +337,7 @@
|
|||
"N_channels": "{{n}} channels",
|
||||
"Name": "Name",
|
||||
"Never": "Never",
|
||||
"New_chat_transfer": "New Chat Transfer: {{agent}} returned the chat to the queue",
|
||||
"New_Message": "New Message",
|
||||
"New_Password": "New Password",
|
||||
"New_Server": "New Server",
|
||||
|
@ -449,6 +453,10 @@
|
|||
"Room_Info": "Room Info",
|
||||
"Room_Members": "Room Members",
|
||||
"Room_name_changed": "Room name changed to: {{name}} by {{userBy}}",
|
||||
"Room_disallowed_reacting": "Room disallowed reacting by {{userBy}}",
|
||||
"Room_allowed_reacting": "Room allowed reacting by {{userBy}}",
|
||||
"Room_set_read_only": "Room set read only by {{userBy}}",
|
||||
"Room_removed_read_only": "Room removed read only by {{userBy}}",
|
||||
"SAVE": "SAVE",
|
||||
"Save_Changes": "Save Changes",
|
||||
"Save": "Save",
|
||||
|
@ -547,6 +555,7 @@
|
|||
"Unread": "Unread",
|
||||
"Unread_on_top": "Unread on top",
|
||||
"Unstar": "Unstar",
|
||||
"Unsupported_system_message": "Unsupported system message",
|
||||
"Updating": "Updating...",
|
||||
"Uploading": "Uploading",
|
||||
"Upload_file_question_mark": "Upload file?",
|
||||
|
|
|
@ -161,7 +161,9 @@ interface IRoomViewProps extends IBaseScreen<ChatsStackParamList, 'RoomView'> {
|
|||
interface IRoomViewState {
|
||||
[key: string]: any;
|
||||
joined: boolean;
|
||||
room: TSubscriptionModel | { rid: string; t: string; name?: string; fname?: string; prid?: string; joinCodeRequired?: boolean };
|
||||
room:
|
||||
| TSubscriptionModel
|
||||
| { rid: string; t: string; name?: string; fname?: string; prid?: string; joinCodeRequired?: boolean; sysMes?: boolean };
|
||||
roomUpdate: {
|
||||
[K in TRoomUpdate]?: any;
|
||||
};
|
||||
|
@ -1231,6 +1233,7 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
|
|||
reactionInit={this.onReactionInit}
|
||||
replyBroadcast={this.replyBroadcast}
|
||||
errorActionsShow={this.errorActionsShow}
|
||||
isSystemMessage={room.sysMes as boolean}
|
||||
baseUrl={baseUrl}
|
||||
Message_GroupingPeriod={Message_GroupingPeriod}
|
||||
timeFormat={Message_TimeFormat}
|
||||
|
|
Loading…
Reference in New Issue