fix:修复处理附件消息时未将消息类型添加到消息体中

This commit is contained in:
SL 2025-04-10 11:18:58 +08:00
parent 3904ad553a
commit 789faba683
5 changed files with 42 additions and 9 deletions

6
.idea/AndroidProjectSystem.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidProjectSystem">
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
</component>
</project>

View File

@ -343,7 +343,7 @@ public class ConversationDbManager {
} }
wkConversationMsg.channelID = msg.channelID; wkConversationMsg.channelID = msg.channelID;
wkConversationMsg.channelType = msg.channelType; wkConversationMsg.channelType = msg.channelType;
wkConversationMsg.localExtraMap = msg.localExtraMap; // wkConversationMsg.localExtraMap = msg.localExtraMap;
wkConversationMsg.lastMsgTimestamp = msg.timestamp; wkConversationMsg.lastMsgTimestamp = msg.timestamp;
wkConversationMsg.lastClientMsgNO = msg.clientMsgNO; wkConversationMsg.lastClientMsgNO = msg.clientMsgNO;
wkConversationMsg.lastMsgSeq = msg.messageSeq; wkConversationMsg.lastMsgSeq = msg.messageSeq;

View File

@ -202,6 +202,7 @@ public class CMDManager extends BaseManager {
} }
} }
WKCMD wkcmd = new WKCMD(cmd, jsonObject); WKCMD wkcmd = new WKCMD(cmd, jsonObject);
WKLoggerUtils.getInstance().e("处理cmd"+cmd);
pushCMDs(wkcmd); pushCMDs(wkcmd);
} }

View File

@ -755,10 +755,25 @@ public class MsgManager extends BaseManager {
} }
public boolean updateContentAndRefresh(String clientMsgNo, WKMessageContent messageContent, boolean isRefreshUI) { public boolean updateContentAndRefresh(String clientMsgNo, String content, boolean isRefreshUI) {
return MsgDbManager.getInstance().updateFieldWithClientMsgNo(clientMsgNo, WKDBColumns.WKMessageColumns.content, messageContent.encodeMsg().toString(), isRefreshUI); return MsgDbManager.getInstance().updateFieldWithClientMsgNo(clientMsgNo, WKDBColumns.WKMessageColumns.content, content, isRefreshUI);
} }
public boolean updateContentAndRefresh(String clientMsgNo, WKMessageContent model, boolean isRefreshUI) {
JSONObject jsonObject = model.encodeMsg();
try {
if (jsonObject == null) {
jsonObject = new JSONObject();
}
jsonObject.put("type", model.type);
} catch (JSONException e) {
throw new RuntimeException(e);
}
return updateContentAndRefresh(clientMsgNo, jsonObject.toString(), isRefreshUI);
}
public void updateViewedAt(int viewed, long viewedAt, String clientMsgNo) { public void updateViewedAt(int viewed, long viewedAt, String clientMsgNo) {
MsgDbManager.getInstance().updateViewedAt(viewed, viewedAt, clientMsgNo); MsgDbManager.getInstance().updateViewedAt(viewed, viewedAt, clientMsgNo);
} }

View File

@ -458,8 +458,13 @@ public class WKConnection {
} }
} }
if (hasAttached) { if (hasAttached) {
JSONObject jsonObject = WKProto.getInstance().getSendPayload(msg);
if (jsonObject != null) {
msg.content = jsonObject.toString();
} else {
msg.content = msg.baseContentMsgModel.encodeMsg().toString(); msg.content = msg.baseContentMsgModel.encodeMsg().toString();
WKIM.getInstance().getMsgManager().updateContentAndRefresh(msg.clientMsgNO, msg.baseContentMsgModel, false); }
WKIM.getInstance().getMsgManager().updateContentAndRefresh(msg.clientMsgNO, msg.content, false);
} }
} }
//获取发送者信息 //获取发送者信息
@ -476,7 +481,13 @@ public class WKConnection {
WKIM.getInstance().getMsgManager().setUploadAttachment(msg, (isSuccess, messageContent) -> { WKIM.getInstance().getMsgManager().setUploadAttachment(msg, (isSuccess, messageContent) -> {
if (isSuccess) { if (isSuccess) {
msg.baseContentMsgModel = messageContent; msg.baseContentMsgModel = messageContent;
WKIM.getInstance().getMsgManager().updateContentAndRefresh(msg.clientMsgNO, msg.baseContentMsgModel, false); JSONObject jsonObject = WKProto.getInstance().getSendPayload(msg);
if (jsonObject != null) {
msg.content = jsonObject.toString();
} else {
msg.content = msg.baseContentMsgModel.encodeMsg().toString();
}
WKIM.getInstance().getMsgManager().updateContentAndRefresh(msg.clientMsgNO, msg.content, false);
if (!sendingMsgHashMap.containsKey((int) msg.clientSeq)) { if (!sendingMsgHashMap.containsKey((int) msg.clientSeq)) {
WKSendMsg base1 = WKProto.getInstance().getSendBaseMsg(msg); WKSendMsg base1 = WKProto.getInstance().getSendBaseMsg(msg);
addSendingMsg(base1); addSendingMsg(base1);