发送失败: errorMessage

dev/chat
Lei OT 2 years ago
parent 509bc4cffd
commit d7fb0167ac

@ -147,7 +147,7 @@ const whatsappMsgMapped = {
contentObj = {
...contentObj,
type: 'error',
text: {body: `Message failed to send.` }, // contentObj.errorMessage
text: {body: `${whatsappError?.[contentObj.errorCode] || contentObj.errorMessage}` }, // contentObj.errorMessage // Message failed to send.
id: contentObj.id,
wamid: contentObj.id,
};
@ -162,7 +162,7 @@ const whatsappMsgMapped = {
id: msgcontent.wamid,
status: msgStatusRenderMapped[(msgcontent?.status || 'failed')],
sender: 'me',
dateString: msgcontent.status==='failed' ? '发送失败 ❌' : '',
dateString: msgcontent.status==='failed' ? `发送失败 ${whatsappError?.[msgcontent.errorCode] || msgcontent.errorMessage}` : '',
}),
},
};
@ -191,7 +191,7 @@ export const receivedMsgTypeMapped = {
// 发送消息的同步返回: 发送失败时
getMsg: (result) => result,
contentToRender: () => null,
contentToUpdate: (msgcontent) => ({ ...msgcontent, id: msgcontent.actionId, status: msgcontent?.status || 'failed', dateString: '发送失败 ❌', conversationid: msgcontent.actionId.split('.')[0], }),
contentToUpdate: (msgcontent) => ({ ...msgcontent, id: msgcontent.actionId, status: msgcontent?.status || 'failed', dateString: `发送失败 ${msgcontent.error.message}`, conversationid: msgcontent.actionId.split('.')[0], }),
},
};
export const whatsappMsgTypeMapped = {
@ -338,7 +338,7 @@ export const parseRenderMessageList = (messages, conversationid = null) => {
sender: 'me',
senderName: 'me',
status: msgStatusRenderMapped[msgContent?.status || 'failed'],
dateString: msgStatusRenderMapped[msgContent?.status || 'failed'] === 'failed' ? '发送失败 ❌' : '',
dateString: msgStatusRenderMapped[msgContent?.status || 'failed'] === 'failed' ? `发送失败 ${whatsappError?.[msgContent.errorCode] || msgContent.errorMessage}` : '',
}
: {}),
...(isEmpty(msg.messageorigin_AsJOSN) && isEmpty(msgContent.context)
@ -361,3 +361,10 @@ export const parseRenderMessageList = (messages, conversationid = null) => {
};
});
};
export const whatsappError = {
'131026': '消息无法投递. [未注册/使用旧版/未同意政策]',
'131047': '会话超过24小时.',
'131053': '文件上传失败.',
'131048': '账户被风控.', // 消息发送太多, 达到垃圾数量限制
'131031': '账户已锁定.',
};

@ -225,11 +225,12 @@ const messageSlice = (set, get) => ({
const { activeConversations, conversationsList, currentConversation } = get();
const targetMsgs = activeConversations[String(targetId)] || [];
const targetIndex = conversationsList.findIndex((ele) => String(ele.sn) === String(targetId));
const updateTime = message.type !== 'system' && message.sender !== 'me' ? message.date : null;
const newConversation =
targetId !== -1
? {
...conversationsList[targetIndex],
last_received_time: message.type !== 'system' && message.sender !== 'me' ? message.date : conversationsList[targetIndex].last_received_time,
last_received_time: updateTime || conversationsList[targetIndex].last_received_time,
unread_msg_count:
String(targetId) !== String(currentConversation.sn) && message.sender !== 'me'
? conversationsList[targetIndex].unread_msg_count + 1
@ -248,7 +249,7 @@ const messageSlice = (set, get) => ({
conversationsList: [...conversationsList],
currentConversation: {
...currentConversation,
last_received_time: String(targetId) === String(currentConversation.sn) ? message.date : currentConversation.last_received_time,
last_received_time: String(targetId) === String(currentConversation.sn) ? updateTime : currentConversation.last_received_time,
},
}));

Loading…
Cancel
Save