Skip to content

Added 'profile_updated' to contact_info & member to version profile info #54

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

Merged
7 commits merged into from
Jul 28, 2025

Conversation

mpretty-cyro
Copy link
Collaborator

@mpretty-cyro mpretty-cyro commented Jul 11, 2025

There is currently a bug in Session where profile information can be overwritten with stale information, this is due to profile information contained within a message not containing any version information - a single scenario which results in this bug is:

  • Create two accounts (Alice and Bob)
  • Start a 1-to-1 conversation between them
  • Create a group with both accounts
  • Have both accounts send messages in both conversations
  • Have Alice update their profile information and send new messages into the 1-to-1 conversation
  • Have Bob restore their account on a new device

In the above scenario Bob will have downloaded and processed all 1-to-1 messages before receiving the group messages, once the group messages are processed their profile data will incorrectly overwrite the newer information that was attached to the 1-to-1 messages

The solution for this is to include a profile_updated timestamp alongside the profile information when sending a message - the client can then compare this against their cached information in order to determine whether they should update the cache

Since libSession stores profile information for contacts and group members it also needs to track this value which is the purpose of this PR

@mpretty-cyro mpretty-cyro requested a review from jagerman July 11, 2025 01:48
@mpretty-cyro mpretty-cyro self-assigned this Jul 11, 2025
@mpretty-cyro mpretty-cyro changed the title Added 'profile_seqno' to contact_info & member to version profile info Added 'profile_updated' to contact_info & member to version profile info Jul 11, 2025
@jagerman jagerman mentioned this pull request Jul 28, 2025
@jagerman
Copy link
Member

jagerman commented Jul 28, 2025

Pushed a change here to store the timestamp in a type-safe std::chrono::sys_seconds. (#58 extends this to existing timestamps, but the commits in this PR applies it first to this new value).

(Edit: also rebased on dev and resolved some minor formatting merge conflicts)

mpretty-cyro and others added 7 commits July 28, 2025 18:40
This uses std::chrono::sys_seconds for the new profile_updated timestamp
field, so that we can avoid the unfortunate bug that happened in earlier
releases where some clients violated the documented restrictions and
passed milliseconds or microseconds: sys_seconds is absolutely
unambiguous as to what it holds and makes such an error virtually
impossible.

- Adds `session::to_sys_seconds(int)` that can get a proper sys_seconds
  from a maybe-s, ms, or µs value by guessing based on the magnitude.

- Add methods for getting/setting sys_seconds timestamps from/into
  configs.
There are a lot of internal calls such as `maybe_int(c,
"key").value_or(0)` and `maybe_string(c, "key").value_or("")`.  This
makes it them slightly less cumbersome by adding `int_or_0` and
`string_or_empty` functions that handle the fallback-to-0/empty
automatically.
@jagerman jagerman force-pushed the feature/profile-seqno branch from c4c5912 to c20e012 Compare July 28, 2025 21:40
@mpretty-cyro mpretty-cyro closed this pull request by merging all changes into session-foundation:dev in 1c16029 Jul 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants