108 lines
5.5 KiB
JavaScript
108 lines
5.5 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../../../common/vendor.js");
|
|
const TUIKit_components_common_Toast_index = require("../../common/Toast/index.js");
|
|
const TUIKit_components_TUIChat_utils_utils = require("./utils.js");
|
|
const TUIKit_utils_enableSampleTaskStatus = require("../../../utils/enableSampleTaskStatus.js");
|
|
const TUIKit_components_TUIChat_offlinePushInfoManager_index = require("../offlinePushInfoManager/index.js");
|
|
const TUIKit_components_common_Toast_type = require("../../common/Toast/type.js");
|
|
const sendMessageErrorCodeMap = /* @__PURE__ */ new Map([
|
|
[3123, "文本包含本地审核拦截词"],
|
|
[4004, "图片消息失败,无效的图片格式"],
|
|
[4005, "文件消息失败,禁止发送违规封禁的文件"],
|
|
[7004, "文件不存在,请检查文件路径是否正确"],
|
|
[7005, "文件大小超出了限制,如果上传文件,最大限制是100MB"],
|
|
[8001, "消息长度超出限制,消息长度不要超过12K"],
|
|
[80001, "消息或者资料中文本存在敏感内容,发送失败"],
|
|
[80004, "消息中图片存在敏感内容,发送失败"],
|
|
[10017, "您已被禁止聊天"]
|
|
]);
|
|
const sendMessages = async (messageList, currentConversation) => {
|
|
if (common_vendor.Jt.getData(common_vendor.o.CHAT, "messageSource")) {
|
|
common_vendor.Jt.update(common_vendor.o.CHAT, "messageSource", void 0);
|
|
}
|
|
messageList == null ? void 0 : messageList.forEach(async (content) => {
|
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
try {
|
|
const options = {
|
|
to: ((_a = currentConversation == null ? void 0 : currentConversation.groupProfile) == null ? void 0 : _a.groupID) || ((_b = currentConversation == null ? void 0 : currentConversation.userProfile) == null ? void 0 : _b.userID),
|
|
conversationType: currentConversation == null ? void 0 : currentConversation.type,
|
|
payload: {},
|
|
needReadReceipt: TUIKit_components_TUIChat_utils_utils.isEnabledMessageReadReceiptGlobal()
|
|
};
|
|
let textMessageContent;
|
|
const sendMessageOptions = {
|
|
offlinePushInfo: {}
|
|
};
|
|
const offlinePushInfoCreateParams = {
|
|
conversation: currentConversation,
|
|
payload: content.payload,
|
|
messageType: ""
|
|
};
|
|
switch (content == null ? void 0 : content.type) {
|
|
case "text":
|
|
textMessageContent = JSON.parse(JSON.stringify((_c = content.payload) == null ? void 0 : _c.text));
|
|
if (!textMessageContent) {
|
|
break;
|
|
}
|
|
options.payload = {
|
|
text: textMessageContent
|
|
};
|
|
offlinePushInfoCreateParams.messageType = common_vendor.qt.TYPES.MSG_TEXT;
|
|
sendMessageOptions.offlinePushInfo = TUIKit_components_TUIChat_offlinePushInfoManager_index.OfflinePushInfoManager.create(offlinePushInfoCreateParams);
|
|
if ((_d = content.payload) == null ? void 0 : _d.atUserList) {
|
|
options.payload.atUserList = content.payload.atUserList;
|
|
await common_vendor.Qt.sendTextAtMessage(options, sendMessageOptions);
|
|
} else {
|
|
await common_vendor.Qt.sendTextMessage(options, sendMessageOptions);
|
|
}
|
|
break;
|
|
case "image":
|
|
options.payload = {
|
|
file: (_e = content.payload) == null ? void 0 : _e.file
|
|
};
|
|
offlinePushInfoCreateParams.messageType = common_vendor.qt.TYPES.MSG_IMAGE;
|
|
sendMessageOptions.offlinePushInfo = TUIKit_components_TUIChat_offlinePushInfoManager_index.OfflinePushInfoManager.create(offlinePushInfoCreateParams);
|
|
await common_vendor.Qt.sendImageMessage(options, sendMessageOptions);
|
|
break;
|
|
case "video":
|
|
options.payload = {
|
|
file: (_f = content.payload) == null ? void 0 : _f.file
|
|
};
|
|
offlinePushInfoCreateParams.messageType = common_vendor.qt.TYPES.MSG_VIDEO;
|
|
sendMessageOptions.offlinePushInfo = TUIKit_components_TUIChat_offlinePushInfoManager_index.OfflinePushInfoManager.create(offlinePushInfoCreateParams);
|
|
await common_vendor.Qt.sendVideoMessage(options, sendMessageOptions);
|
|
break;
|
|
case "file":
|
|
options.payload = {
|
|
file: (_g = content.payload) == null ? void 0 : _g.file
|
|
};
|
|
offlinePushInfoCreateParams.messageType = common_vendor.qt.TYPES.MSG_FILE;
|
|
sendMessageOptions.offlinePushInfo = TUIKit_components_TUIChat_offlinePushInfoManager_index.OfflinePushInfoManager.create(offlinePushInfoCreateParams);
|
|
await common_vendor.Qt.sendFileMessage(options, sendMessageOptions);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
TUIKit_utils_enableSampleTaskStatus.enableSampleTaskStatus("sendMessage");
|
|
} catch (error) {
|
|
TUIKit_components_common_Toast_index.Toast({
|
|
message: sendMessageErrorCodeMap.get(error == null ? void 0 : error.code) ? common_vendor.Wt.t(`TUIChat.${sendMessageErrorCodeMap.get(error.code)}`) : error == null ? void 0 : error.message,
|
|
type: TUIKit_components_common_Toast_type.TOAST_TYPE.ERROR
|
|
});
|
|
if (common_vendor.Jt.getData(common_vendor.o.CHAT, "quoteMessage")) {
|
|
common_vendor.Jt.update(common_vendor.o.CHAT, "quoteMessage", {});
|
|
}
|
|
}
|
|
});
|
|
};
|
|
const sendTyping = (inputContentEmpty, inputBlur) => {
|
|
if (!inputContentEmpty && !inputBlur) {
|
|
common_vendor.Qt.enterTypingState();
|
|
} else {
|
|
common_vendor.Qt.leaveTypingState();
|
|
}
|
|
};
|
|
exports.sendMessages = sendMessages;
|
|
exports.sendTyping = sendTyping;
|
|
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/TUIKit/components/TUIChat/utils/sendMessage.js.map
|