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

掉线的时候消息丢失,不可控 #208

Open
su-chang opened this issue Feb 15, 2022 · 4 comments
Open

掉线的时候消息丢失,不可控 #208

su-chang opened this issue Feb 15, 2022 · 4 comments
Assignees
Labels
discuss help wanted Extra attention is needed

Comments

@su-chang
Copy link
Member

测试结果文档链接(待补充):https://k0auuqcihb.feishu.cn/wiki/wikcnVwzIb24hmiW6upptq6Sfsw

解决方案

目前观察发现 WhatsApp Web 端在手机离线的情况下接收到的消息都会同步成功。

whatsapp-web.js 的 SDK 中提供接口 fetchMessage(),参见:https://docs.wwebjs.dev/Chat.html#fetchMessages

考虑在 puppet-whatsapp 中触发 READY 事件前,针对当前所有会话拉取近期的消息:

  • 该消息已经存在缓存中

    忽略该消息

  • 该消息不存在缓存中

    推送该消息至 Wechaty

@su-chang su-chang added discuss help wanted Extra attention is needed labels Feb 15, 2022
@su-chang su-chang self-assigned this Feb 15, 2022
@su-chang
Copy link
Member Author

目前仅在触发ready事件之前才会同步消息。

可能还需要加一个定时任务来定时拉取近期的消息,以便及时同步丢失的消息。

@su-chang
Copy link
Member Author

whatsapp-web.js 的 SDK 中提供接口 fetchMessage(),参见:https://docs.wwebjs.dev/Chat.html#fetchMessages

待优化

接口 fetchMessage()只支持 limit 参数,导致每次同步消息时都会拉取所有会话的所有消息。

目前的优化方案只是根据 timestamp 属性来判断是否进行执行 onMessage 函数。

最好是 whatsapp-web.js 能支持以 timestamp 为参数来调用 fetchMessage() 接口。

@su-chang
Copy link
Member Author

su-chang commented Feb 17, 2022

针对历史消息需要增加最小时长,来控制向 Wechaty emit 消息的数量,暂定 3 天。

@lijiarui
Copy link
Member

We should always put the public link in the issue, or this issue will be meaningless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants