Senparc/NeuChar

开启实时同步通讯录,新增用户回调被防重拦截。

CooBeeDior opened this issue · 3 comments

开启实时同步通讯录,添加用户,回调三次;
第一次:
{"ChangeType":1,"NewUserID":null,"Name":null,"Department":"6","DepartmentIdList":[6],"Position":null,"Mobile":null,"Gender":0,"Email":null,"IsLeader":0,"Avatar":null,"Status":0,"Telephone":null,"EnglishName":null,"ExtAttr":null,"UserID":"1222","Event":17,"AgentID":0,"MsgType":7,"EventType":17,"EventName":"change_contact","MsgId":0,"Encrypt":null,"ToUserName":"ww4538e490b80c56b4","FromUserName":"sys","CreateTime":"2021-04-07T17:28:04+08:00"}

第二次:
{"ChangeType":1,"NewUserID":null,"Name":null,"Department":"6","DepartmentIdList":[6],"Position":null,"Mobile":null,"Gender":0,"Email":null,"IsLeader":0,"Avatar":null,"Status":0,"Telephone":null,"EnglishName":null,"ExtAttr":null,"UserID":"1222","Event":17,"AgentID":0,"MsgType":7,"EventType":17,"EventName":"change_contact","MsgId":0,"Encrypt":null,"ToUserName":"ww4538e490b80c56b4","FromUserName":"sys","CreateTime":"2021-04-07T17:28:04+08:00"}

第三次,
{"ChangeType":0,"Name":"111","Department":"6","DepartmentIdList":[6],"Position":null,"Mobile":"14100033111","Gender":1,"Email":null,"IsLeader":0,"Avatar":"https://rescdn.qqmail.com/node/wwmng/wwmng/style/images/independent/DefaultAvatar$73ba92b5.png\",\"Status\":4,\"Telephone\":null,\"EnglishName\":null,\"ExtAttr\":null,\"UserID\":\"1222\",\"Event\":17,\"AgentID\":0,\"MsgType\":7,\"EventType\":17,\"EventName\":\"change_contact\",\"MsgId\":0,\"Encrypt\":null,\"ToUserName\":\"ww4538e490b80c56b4\",\"FromUserName\":\"sys\",\"CreateTime\":\"2021-04-07T17:28:04+08:00\"}

第三次回调被防重拦截
image

@CooBeeDior 更新到最新的版本再看一下。

@CooBeeDior 更新到最新的版本再看一下。

1.主要问题:

  • 企业微信的事件去重规则 的确有严重的bug,我也找企业微信运营专员确认过此问题,可以改为按签名去重
    【关于重试的消息排重,有msgid的消息推荐使用msgid排重。事件类型消息推荐使用FromUserName + CreateTime排重】,此时FromUserName 统一为sys,极少概率会出现【两个事件CreateTime】相同。导致消息被去重处理掉。
  • 开放社区论坛

2.次要优化

  • 另外我发现NeuChar源码 缓存的key可以优化
    采用
    ToUserName+FromUserName 更佳,这样就可以做到 (以公众appid+用户 或者企业id+sys)以企业或以公众账号appid作为键分隔数据,以确保授权三方平台模式 key 真正唯一
    image
    image
    特别是企业微信去重key,我们会发现key全是Senparc:xxx:MessageContext:sys,只是value里面有"ToUserName": "企业id"
    image

已发布新版本,感谢! @CooBeeDior @WangDrama