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

Messages can appear in the wrong order in history due to low time precision #282

Open
fulalas opened this issue Aug 21, 2024 · 4 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@fulalas
Copy link

fulalas commented Aug 21, 2024

If I send 2 messages in a row really quick or forward (on mobile app) 2 messages at once, sometimes nchat show them in the wrong order. I presume this happens because nchat is using low time precision (maybe just seconds, not milliseconds?).

This is not a critical bug and this is not a regression.

nchat-5.1.29

@fulalas fulalas added the bug Something isn't working label Aug 21, 2024
@d99kris
Copy link
Owner

d99kris commented Aug 25, 2024

Hi @fulalas - thanks for reporting a bug. I can see the issue here too, if I forward two messages using WhatsApp from the phone on a different account, and receive them in nchat. I assume you also see this only for WhatsApp, right?

The WhatsApp glue layer implementation has some (likely unecessary) time stamp rounding to seconds (like you guessed), I will look into switching to millisecond timestamps (which is what nchat generally uses).

@fulalas
Copy link
Author

fulalas commented Aug 27, 2024

I just confirmed it also happens using Telegram protocol.

@d99kris
Copy link
Owner

d99kris commented Aug 31, 2024

Thanks for sharing. I checked the WhatsApp (whatsmeow) and Telegram (tdlib) API's, and the message timestamp nchat receives is only at second-resolution. Internally nchat converts the timestamp to ms-resolution and uses a message id hash for the "ms-part", this is to have a consistent sorting order (even if it's wrong at least it's not random).

Anyway, the official Telegram and WhatsApp clients manage to list messages in correct order despite the timestamp resolution, so they likely sort based on some other data. I believe Telegram might sort based on message id, and for WhatsApp perhaps the messages are just sorted based on order received by the client (just a guess).

I will need to do a bit more research to see how this can be fixed. Just wanted to share a brief update on the troubleshooting done so far.

@fulalas
Copy link
Author

fulalas commented Aug 31, 2024

Thanks a lot, man! Very kind of you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants