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

Expected UTDs: Hide device-relative historical UTDs #2313

Closed
3 tasks done
Tracked by #2312
BillCarsonFr opened this issue Feb 28, 2024 · 9 comments
Closed
3 tasks done
Tracked by #2312

Expected UTDs: Hide device-relative historical UTDs #2313

BillCarsonFr opened this issue Feb 28, 2024 · 9 comments
Assignees

Comments

@BillCarsonFr
Copy link
Member

BillCarsonFr commented Feb 28, 2024

A freshly logged in session will have access to event in the joined rooms, but not to the keys for the messages as the device didn't exist when the event were sent.
The new device has to go through the verification process in order to get access to the keys and properly display history.

We are talking here about Device-Relative history:
image

Currently EIX is hiding such history until the device has access to backup:

image

Technical Inputs

How to detect when an event is historical to the current device?

Currently EIX is using events origin_server_ts of events (isItemInEncryptionHistory). It's comparing the local creation date of the device ( since the unix epoch) to the event origin_server_ts (Timestamp in milliseconds since the unix epoch on originating homeserver when this event was sent.)

Some downside on this approach is that if the device local time or server local time is wrong it could messed up things.

Another approach could be to use the API end-point used to get the messages?

  • From sync: If not an initial sync it's not an historical message.
  • From sync: If an initial sync, could be a mix of it, but mainly historical? (unless a clear cache is done)
  • From /message (back pagination). Would be mostly historical to the current device (unless there was a clear cache?)
  • From /relation (threads?). Would be mostly historical?

It's anyhow hard to see if something is really device relative history, as the process of sending is inherently racy.
There might be some events that are shown were they shouldn't (sent around the same time the device is logged in but before propagated to anyone)

Proposal

  • Hide historical messages (expected UTD) until the user has access to backup
  • Hide historical messages (expected UTD) while keys are beeing downoaled.
  • Once the keys have been downloaded, show the events.

If an UTD has not be displayed on screen, it should not be reported to analytics.

Tasks

Tasks

Preview Give feedback

Known possible issues

  • If we hide the device relative historical messages, and the users manually import keys from a file, what should we do?
  • After the backup import, some messages might still be in UTDs (key was not in the used backup). That's fine, we should just display the UTD and report to analytics
@BillCarsonFr BillCarsonFr changed the title Expected UTDs: Hide & Resolve device relative historical UTDs Avoidable UTDs: Hide & Resolve device relative historical UTDs Feb 29, 2024
@BillCarsonFr BillCarsonFr changed the title Avoidable UTDs: Hide & Resolve device relative historical UTDs Expected UTDs: Hide & Resolve device relative historical UTDs Feb 29, 2024
@richvdh
Copy link
Member

richvdh commented Mar 1, 2024

Probably requires a fix to element-hq/element-web#27009?

Edit: not really. The two are orthogonal.

@richvdh
Copy link
Member

richvdh commented Mar 10, 2024

There might be some events that are shown were they shouldn't (sent around the same time the device is logged in but before propagated to anyone)

This is somewhat related to #2314, and dealing with the race condition might have a similar solution.

@richvdh richvdh changed the title Expected UTDs: Hide & Resolve device relative historical UTDs Expected UTDs: Hide device-relative historical UTDs Mar 10, 2024
@richvdh richvdh self-assigned this Mar 11, 2024
@richvdh
Copy link
Member

richvdh commented Mar 11, 2024

As a first step, we will not hide the events altogether, but display a placeholder.

@BillCarsonFr
Copy link
Member Author

Note: we should ensure that it's also hiding historical UTDs in thread view.

@richvdh
Copy link
Member

richvdh commented Mar 20, 2024

Rough idea for approach here:

  • Add a new code value to DecryptionError which reflects a message that is older than the device, when we don't have backup enabled.
  • Update DecryptionFailureBody to display the failure differently to the user
  • Update DecryptionFailureTracker to report the failure differently to posthog.

More detailed work:

@BillCarsonFr
Copy link
Member Author

@richvdh
Copy link
Member

richvdh commented Apr 3, 2024

Decision tree for the text to be displayed:

flowchart TD
A{Timestamp on the message postdates the creation of our device}
A -- Yes --> X
A -- No --> B
B{Is there a backup}
B -- No --> Y
B -- Yes --> C
C{Is the device verified}
C -- No --> Z
C -- Yes --> X

X([Normal UTD error])
Y([History is not available on this device])
Z([You need to verify this device])
Loading

@andybalaam
Copy link
Member

andybalaam commented Nov 29, 2024

Discussion today suggests the full flow diagram implemented looks like this:

flowchart TD
A{Is the message newer than the device?}
A -- No --> B
A -- Yes --> X
B{Is there a backup on the server?}
B -- No --> Y
B -- Yes --> C
C{Is backup working on this device?}
C -- No --> D
C -- Yes --> X
D{Is this device verified?}
D -- No --> Z
D -- Yes --> X

X([Normal UTD error])
Y([History is not available on this device])
Z([You need to verify this device])
Loading

In matrix-js-sdk most of this is implemented when we choose a DecryptionFailureCode and some ("Is this device verified?") when we display a message to the user.

I am looking at this as I am implementing similar logic in matrix-rust-sdk, probably in UtdCause::determine.

@andybalaam
Copy link
Member

(I am working on #2638 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants