归档聊天后App states regular_low/regular_high不同步及LTHash匹配失败
归档聊天功能后续操作失败问题排查
问题背景
我们正在为应用添加单条消息归档聊天功能:首次归档可正常运行,但后续发送消息的归档操作全部失败,报错如下。
核心代码片段
消息发送并归档的关键实现代码:
userJID := types.NewJID(phoneNumber, types.DefaultUserServer) message := &waProto.Message{ Conversation: proto.String(messageContent), } ctx := context.Background() resp, err := client.SendMessage(ctx, userJID, message) chatID := resp.ID messageTimeStamp := resp.Timestamp lastMessageKey := &waProto.MessageKey{ RemoteJid: proto.String(userJID.String()), FromMe: proto.Bool(true), Id: proto.String(chatID), } archiveChat := true archivePatch := appstate.BuildArchive(userJID, *proto.Bool(archiveChat), messageTimeStamp, lastMessageKey) err = client.SendAppState(archivePatch)
首次报错日志
执行client.SendAppState(archivePatch)时返回的XML格式错误信息:
<?xml version="1.0"?> <collection has_more_patches="true" name="regular_low" type="error"> <error code="409" text="conflict"/> <patches> <patch><!-- 867 bytes --></patch> <patch><!-- 1175 bytes --></patch> <patch><!-- 1021 bytes --></patch> <patch><!-- 1313 bytes --></patch> <patch><!-- 1329 bytes --></patch> <patch><!-- 1021 bytes --></patch> <patch><!-- 1021 bytes --></patch> <patch><!-- 1021 bytes --></patch> ... </patches> </collection>
尝试的修复操作及新错误
为同步补丁状态,我在归档前加入了以下代码:
for _, name := range appstate.AllPatchNames { err := client.FetchAppState(name, true, false) if err != nil { client.Log.Errorf("Failed to do initial fetch of app state %s: %v", name, err) } }
但执行后出现两个补丁验证错误:
[Client ERROR] Failed to do initial fetch of app state regular_high: failed to decode app state regular_high patches: failed to verify patch v897: mismatching LTHash
[Client ERROR] Failed to do initial fetch of app state regular_low: failed to decode app state regular_low patches: failed to verify patch v712: mismatching LTHash
问题
请问这是什么原因?是否需要重新计算LTHash?如果是,该如何操作?
内容的提问来源于stack exchange,提问作者Miguel Gomez
相关产品推荐
相关产品推荐

