Skip to content

Commit

Permalink
fix: 🐛 修复无重启登录后发送消息失败问题got more than 2 contacts close:#60
Browse files Browse the repository at this point in the history
  • Loading branch information
danni-cool committed Jan 13, 2024
1 parent f45d42d commit 9d90ec1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM node:18-alpine
WORKDIR /app

# 非依赖变更缓存改层
COPY package.json pnpm-lock.yaml .npmrc ./
COPY package.json pnpm-lock.yaml patches .npmrc ./

# 安装应用程序依赖项
RUN npm install -g pnpm && pnpm install --production&& pnpm store prune && npm uninstall pnpm -g
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,10 @@
"tsc-files": "^1.1.4",
"typescript": "^5.3.3",
"wechaty-puppet-mock": "^1.18.2"
},
"pnpm": {
"patchedDependencies": {
"wechat4u@0.7.14": "patches/wechat4u@0.7.14.patch"
}
}
}
15 changes: 15 additions & 0 deletions patches/wechat4u@0.7.14.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/lib/wechat.js b/lib/wechat.js
index b00a1b4e21e1b8216689096618da08e911cfc79d..d64c450843a83af6e5b1962912e4eb94269f0494 100644
--- a/lib/wechat.js
+++ b/lib/wechat.js
@@ -180,7 +180,9 @@ var Wechat = function (_WechatCore) {
key: '_init',
value: function _init() {
var _this5 = this;
-
+
+ //HOTFIX: 每次初始化,必定要清空历史数据,不然在重新登录场景会出现多个id对应一个人
+ _this5.contacts = {}
return this.init().then(function (data) {
// this.getContact() 这个接口返回通讯录中的联系人(包括已保存的群聊)
// 临时的群聊会话在初始化的接口中可以获取,因此这里也需要更新一遍 contacts
10 changes: 8 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9d90ec1

Please sign in to comment.