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 Message from './Message';
|
||||||
import MessageContext from './Context';
|
import MessageContext from './Context';
|
||||||
import debounce from '../../utils/debounce';
|
import debounce from '../../utils/debounce';
|
||||||
import { SYSTEM_MESSAGES, getMessageTranslation } from './utils';
|
import { getMessageTranslation } from './utils';
|
||||||
import { TSupportedThemes, withTheme } from '../../theme';
|
import { TSupportedThemes, withTheme } from '../../theme';
|
||||||
import openLink from '../../utils/openLink';
|
import openLink from '../../utils/openLink';
|
||||||
import { TGetCustomEmoji } from '../../definitions/IEmoji';
|
import { TGetCustomEmoji } from '../../definitions/IEmoji';
|
||||||
|
@ -31,6 +31,7 @@ interface IMessageContainerProps {
|
||||||
Message_GroupingPeriod?: number;
|
Message_GroupingPeriod?: number;
|
||||||
isReadReceiptEnabled?: boolean;
|
isReadReceiptEnabled?: boolean;
|
||||||
isThreadRoom: boolean;
|
isThreadRoom: boolean;
|
||||||
|
isSystemMessage?: boolean;
|
||||||
useRealName?: boolean;
|
useRealName?: boolean;
|
||||||
autoTranslateRoom?: boolean;
|
autoTranslateRoom?: boolean;
|
||||||
autoTranslateLanguage?: string;
|
autoTranslateLanguage?: string;
|
||||||
|
@ -254,9 +255,12 @@ class MessageContainer extends React.Component<IMessageContainerProps, IMessageC
|
||||||
return t === E2E_MESSAGE_TYPE && e2e !== E2E_STATUS.DONE;
|
return t === E2E_MESSAGE_TYPE && e2e !== E2E_STATUS.DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
get isInfo(): boolean {
|
get isInfo(): string | boolean {
|
||||||
const { item } = this.props;
|
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 {
|
get isTemp(): boolean {
|
||||||
|
|
|
@ -45,7 +45,7 @@ export interface IMessageCallButton {
|
||||||
export interface IMessageContent {
|
export interface IMessageContent {
|
||||||
_id: string;
|
_id: string;
|
||||||
isTemp: boolean;
|
isTemp: boolean;
|
||||||
isInfo: boolean;
|
isInfo: string | boolean;
|
||||||
tmid?: string;
|
tmid?: string;
|
||||||
isThreadRoom: boolean;
|
isThreadRoom: boolean;
|
||||||
msg?: string;
|
msg?: string;
|
||||||
|
@ -76,7 +76,7 @@ export interface IMessageThread extends Pick<IThread, 'msg' | 'tcount' | 'tlm' |
|
||||||
|
|
||||||
export interface IMessageTouchable {
|
export interface IMessageTouchable {
|
||||||
hasError: boolean;
|
hasError: boolean;
|
||||||
isInfo: boolean;
|
isInfo: string | boolean;
|
||||||
isThreadReply: boolean;
|
isThreadReply: boolean;
|
||||||
isTemp: boolean;
|
isTemp: boolean;
|
||||||
archived?: boolean;
|
archived?: boolean;
|
||||||
|
@ -110,7 +110,7 @@ export interface IMessageInner
|
||||||
export interface IMessage extends IMessageRepliedThread, IMessageInner, IMessageAvatar {
|
export interface IMessage extends IMessageRepliedThread, IMessageInner, IMessageAvatar {
|
||||||
isThreadReply: boolean;
|
isThreadReply: boolean;
|
||||||
isThreadSequential: boolean;
|
isThreadSequential: boolean;
|
||||||
isInfo: boolean;
|
isInfo: string | boolean;
|
||||||
isTemp: boolean;
|
isTemp: boolean;
|
||||||
isHeader: boolean;
|
isHeader: boolean;
|
||||||
hasError: boolean;
|
hasError: boolean;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable complexity */
|
||||||
import { TMessageModel } from '../../definitions/IMessage';
|
import { TMessageModel } from '../../definitions/IMessage';
|
||||||
import I18n from '../../i18n';
|
import I18n from '../../i18n';
|
||||||
import { DISCUSSION } from './constants';
|
import { DISCUSSION } from './constants';
|
||||||
|
@ -56,10 +57,25 @@ export const SYSTEM_MESSAGES = [
|
||||||
'user-converted-to-channel',
|
'user-converted-to-channel',
|
||||||
'user-deleted-room-from-team',
|
'user-deleted-room-from-team',
|
||||||
'user-removed-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_placed_chat_on_hold',
|
||||||
'omnichannel_on_hold_chat_resumed'
|
'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 = {
|
export const SYSTEM_MESSAGE_TYPES = {
|
||||||
MESSAGE_REMOVED: 'rm',
|
MESSAGE_REMOVED: 'rm',
|
||||||
MESSAGE_PINNED: 'message_pinned',
|
MESSAGE_PINNED: 'message_pinned',
|
||||||
|
@ -77,7 +93,15 @@ export const SYSTEM_MESSAGE_TYPES = {
|
||||||
DELETED_ROOM_FROM_TEAM: 'user-deleted-room-from-team',
|
DELETED_ROOM_FROM_TEAM: 'user-deleted-room-from-team',
|
||||||
REMOVED_ROOM_FROM_TEAM: 'user-removed-room-from-team',
|
REMOVED_ROOM_FROM_TEAM: 'user-removed-room-from-team',
|
||||||
OMNICHANNEL_PLACED_CHAT_ON_HOLD: 'omnichannel_placed_chat_on_hold',
|
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 = [
|
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_TEAM,
|
||||||
SYSTEM_MESSAGE_TYPES.CONVERTED_TO_CHANNEL,
|
SYSTEM_MESSAGE_TYPES.CONVERTED_TO_CHANNEL,
|
||||||
SYSTEM_MESSAGE_TYPES.DELETED_ROOM_FROM_TEAM,
|
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 = {
|
type TInfoMessage = {
|
||||||
|
@ -108,6 +140,7 @@ type TInfoMessage = {
|
||||||
|
|
||||||
export const getInfoMessage = ({ type, role, msg, author, comment }: TInfoMessage): string => {
|
export const getInfoMessage = ({ type, role, msg, author, comment }: TInfoMessage): string => {
|
||||||
const { username } = author;
|
const { username } = author;
|
||||||
|
|
||||||
if (type === 'rm') {
|
if (type === 'rm') {
|
||||||
return I18n.t('Message_removed');
|
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') {
|
if (type === 'user-removed-room-from-team') {
|
||||||
return I18n.t('Removed__roomName__from_this_team', { roomName: msg });
|
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') {
|
if (type === 'omnichannel_placed_chat_on_hold') {
|
||||||
return I18n.t('Omnichannel_placed_chat_on_hold', { comment });
|
return I18n.t('Omnichannel_placed_chat_on_hold', { comment });
|
||||||
}
|
}
|
||||||
if (type === 'omnichannel_on_hold_chat_resumed') {
|
if (type === 'omnichannel_on_hold_chat_resumed') {
|
||||||
return I18n.t('Omnichannel_on_hold_chat_resumed', { comment });
|
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) => {
|
export const getMessageTranslation = (message: TMessageModel, autoTranslateLanguage: string) => {
|
||||||
|
|
|
@ -132,6 +132,7 @@
|
||||||
"Channel_Name": "Channel Name",
|
"Channel_Name": "Channel Name",
|
||||||
"Channels": "Channels",
|
"Channels": "Channels",
|
||||||
"Chats": "Chats",
|
"Chats": "Chats",
|
||||||
|
"Chat_started": "Chat started",
|
||||||
"Call_already_ended": "Call already ended!",
|
"Call_already_ended": "Call already ended!",
|
||||||
"Clear_cookies_alert": "Do you want to clear all cookies?",
|
"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.",
|
"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",
|
"Choose_where_you_want_links_be_opened": "Choose where you want links be opened",
|
||||||
"Code": "Code",
|
"Code": "Code",
|
||||||
"Code_or_password_invalid": "Code or password invalid",
|
"Code_or_password_invalid": "Code or password invalid",
|
||||||
|
"Conversation_closed": "Conversation closed",
|
||||||
"Collaborative": "Collaborative",
|
"Collaborative": "Collaborative",
|
||||||
"Confirm": "Confirm",
|
"Confirm": "Confirm",
|
||||||
"Connect": "Connect",
|
"Connect": "Connect",
|
||||||
|
@ -301,6 +303,7 @@
|
||||||
"License": "License",
|
"License": "License",
|
||||||
"Livechat": "Livechat",
|
"Livechat": "Livechat",
|
||||||
"Livechat_edit": "Livechat edit",
|
"Livechat_edit": "Livechat edit",
|
||||||
|
"Livechat_transfer_return_to_the_queue": "returned the chat to the queue",
|
||||||
"Login": "Login",
|
"Login": "Login",
|
||||||
"Login_error": "Your credentials were rejected! Please try again.",
|
"Login_error": "Your credentials were rejected! Please try again.",
|
||||||
"Login_with": "Login with",
|
"Login_with": "Login with",
|
||||||
|
@ -334,6 +337,7 @@
|
||||||
"N_channels": "{{n}} channels",
|
"N_channels": "{{n}} channels",
|
||||||
"Name": "Name",
|
"Name": "Name",
|
||||||
"Never": "Never",
|
"Never": "Never",
|
||||||
|
"New_chat_transfer": "New Chat Transfer: {{agent}} returned the chat to the queue",
|
||||||
"New_Message": "New Message",
|
"New_Message": "New Message",
|
||||||
"New_Password": "New Password",
|
"New_Password": "New Password",
|
||||||
"New_Server": "New Server",
|
"New_Server": "New Server",
|
||||||
|
@ -449,6 +453,10 @@
|
||||||
"Room_Info": "Room Info",
|
"Room_Info": "Room Info",
|
||||||
"Room_Members": "Room Members",
|
"Room_Members": "Room Members",
|
||||||
"Room_name_changed": "Room name changed to: {{name}} by {{userBy}}",
|
"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": "SAVE",
|
||||||
"Save_Changes": "Save Changes",
|
"Save_Changes": "Save Changes",
|
||||||
"Save": "Save",
|
"Save": "Save",
|
||||||
|
@ -547,6 +555,7 @@
|
||||||
"Unread": "Unread",
|
"Unread": "Unread",
|
||||||
"Unread_on_top": "Unread on top",
|
"Unread_on_top": "Unread on top",
|
||||||
"Unstar": "Unstar",
|
"Unstar": "Unstar",
|
||||||
|
"Unsupported_system_message": "Unsupported system message",
|
||||||
"Updating": "Updating...",
|
"Updating": "Updating...",
|
||||||
"Uploading": "Uploading",
|
"Uploading": "Uploading",
|
||||||
"Upload_file_question_mark": "Upload file?",
|
"Upload_file_question_mark": "Upload file?",
|
||||||
|
|
|
@ -161,7 +161,9 @@ interface IRoomViewProps extends IBaseScreen<ChatsStackParamList, 'RoomView'> {
|
||||||
interface IRoomViewState {
|
interface IRoomViewState {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
joined: boolean;
|
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: {
|
roomUpdate: {
|
||||||
[K in TRoomUpdate]?: any;
|
[K in TRoomUpdate]?: any;
|
||||||
};
|
};
|
||||||
|
@ -1231,6 +1233,7 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
|
||||||
reactionInit={this.onReactionInit}
|
reactionInit={this.onReactionInit}
|
||||||
replyBroadcast={this.replyBroadcast}
|
replyBroadcast={this.replyBroadcast}
|
||||||
errorActionsShow={this.errorActionsShow}
|
errorActionsShow={this.errorActionsShow}
|
||||||
|
isSystemMessage={room.sysMes as boolean}
|
||||||
baseUrl={baseUrl}
|
baseUrl={baseUrl}
|
||||||
Message_GroupingPeriod={Message_GroupingPeriod}
|
Message_GroupingPeriod={Message_GroupingPeriod}
|
||||||
timeFormat={Message_TimeFormat}
|
timeFormat={Message_TimeFormat}
|
||||||
|
|
Loading…
Reference in New Issue