Skip to content

Commit

Permalink
[fix]:热登录重启后再次消费历史消息问题 (#245)
Browse files Browse the repository at this point in the history
Co-authored-by: minQpple <[email protected]>
  • Loading branch information
minQpple and minQpple authored Feb 7, 2023
1 parent d1fee1a commit 1320a31
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ func (b *Bot) WebInit() error {
b.self.formatEmoji()
b.self.self = b.self
resp.ContactList.init(b.self)
// 读取和装载SyncKey
if b.Storage.Response != nil {
resp.SyncKey = b.Storage.Response.SyncKey
}
b.Storage.Response = resp

// 通知手机客户端已经登录
Expand Down Expand Up @@ -321,6 +325,7 @@ func (b *Bot) DumpTo(writer io.Writer) error {
Jar: fromCookieJar(jar),
LoginInfo: b.Storage.LoginInfo,
WechatDomain: b.Caller.Client.Domain,
SyncKey: &b.Storage.Response.SyncKey,
UUID: b.uuid,
}
return b.Serializer.Encode(writer, item)
Expand Down Expand Up @@ -363,6 +368,12 @@ func (b *Bot) reload() error {
b.Storage.Request = item.BaseRequest
b.Caller.Client.Domain = item.WechatDomain
b.uuid = item.UUID
if item.SyncKey != nil {
if b.Storage.Response == nil {
b.Storage.Response = &WebInitResponse{}
}
b.Storage.Response.SyncKey = *item.SyncKey
}
return nil
}

Expand Down
1 change: 1 addition & 0 deletions stroage.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type HotReloadStorageItem struct {
BaseRequest *BaseRequest
LoginInfo *LoginInfo
WechatDomain WechatDomain
SyncKey *SyncKey
UUID string
}

Expand Down

0 comments on commit 1320a31

Please sign in to comment.