Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

企微第三方加好友回调,创建时间一样被判定为重复消息 #3311

Open
wayne-wei-q opened this issue Jun 17, 2024 · 4 comments
Labels

Comments

@wayne-wei-q
Copy link

简要描述

在企微第三方回调接口使用消息路由时发现,当加好友回调消息的创建时间一样,但外部联系人不同,企微用户也不同时会被判断为重复消息,导致没有进入到后续的handle,造成该客户的相关业务未能处理。

模块版本情况

  • WxJava 模块名: weixin-java-cp
  • WxJava 版本号: 4.6.0

详细描述

Class: me.chanjar.weixin.cp.tp.message.WxCpTpMessageRouter
Mehtod: isMsgDuplicated()
`private boolean isMsgDuplicated(WxCpTpXmlMessage wxMessage) {
StringBuilder messageId = new StringBuilder();
if (wxMessage.getInfoType() != null) {
messageId.append(wxMessage.getInfoType())
.append("-").append(StringUtils.trimToEmpty(wxMessage.getSuiteId()))
.append("-").append(wxMessage.getTimeStamp())
.append("-").append(StringUtils.trimToEmpty(wxMessage.getAuthCorpId()))
.append("-").append(StringUtils.trimToEmpty(wxMessage.getUserID()))
.append("-").append(StringUtils.trimToEmpty(wxMessage.getChangeType()))
.append("-").append(StringUtils.trimToEmpty(wxMessage.getServiceCorpId()))
.append("-").append(StringUtils.trimToEmpty(wxMessage.getExternalUserID()));
}

if (wxMessage.getMsgType() != null) {
  if (wxMessage.getMsgId() != null) {
    messageId.append(wxMessage.getMsgId())
      .append("-").append(wxMessage.getCreateTime())
      .append("-").append(wxMessage.getFromUserName());
  } else {
      messageId.append(wxMessage.getMsgType())
      .append("-").append(wxMessage.getCreateTime())
      .append("-").append(wxMessage.getFromUserName())
      .append("-").append(StringUtils.trimToEmpty(wxMessage.getEvent()))
      .append("-").append(StringUtils.trimToEmpty(wxMessage.getEventKey()));

  }
}

return this.messageDuplicateChecker.isDuplicate(messageId.toString());

}`

image
在加好友回调中,InfoType为空,MsgID为空会进入到如图所示的逻辑中,此处createTime和FromUserName是相同的,而Event必定也是相同的,eventKey为空。所以会判定为重复消息,此处的messageId应加上ExternalUserID和userID作为唯一判定的key。

@wayne-wei-q
Copy link
Author

@binarywang

@binarywang
Copy link
Member

可以加上,欢迎直接提交PR修复代码

@stale stale bot added the stale label Aug 16, 2024
@binarywang
Copy link
Member

楼主不方便贡献代码?

@stale stale bot removed the stale label Aug 21, 2024
@Wechat-Group Wechat-Group deleted a comment from stale bot Aug 21, 2024
Copy link

stale bot commented Oct 20, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants