Closed BillCarsonFr closed 6 months ago
Probably requires a fix to https://github.com/element-hq/element-web/issues/27009?
Edit: not really. The two are orthogonal.
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 https://github.com/element-hq/element-meta/issues/2314, and dealing with the race condition might have a similar solution.
As a first step, we will not hide the events altogether, but display a placeholder.
Note: we should ensure that it's also hiding historical UTDs in thread view.
Rough idea for approach here:
code
value to DecryptionError
which reflects a message that is older than the device, when we don't have backup enabled.DecryptionFailureBody
to display the failure differently to the userDecryptionFailureTracker
to report the failure differently to posthog.More detailed work:
DecryptionError
out of legacy crypto code and into crypto-api
. Replace its code
with an enum: https://github.com/matrix-org/matrix-js-sdk/pull/4126 EventDecryptor.attemptEventDecryption
so that all the logic isn't inside a catch
block. https://github.com/matrix-org/matrix-js-sdk/pull/4138PerSessionKeyBackupDownloader.isBackupConfigured()
.MissingRoomKey
or UnknownMessageIndex
, compare the timestamp on the event with the creation time of our own device (available via Device.firstTimeSeen
), and check isBackupConfigured
. If it's an old event, and backup is not configured, use different code
s on DecryptionError
. https://github.com/matrix-org/matrix-js-sdk/pull/4139DecryptionFailureBody
: use different text for new error codes. https://github.com/matrix-org/matrix-react-sdk/pull/12391DecryptionFailureTracker
: use different error code. https://github.com/matrix-org/matrix-react-sdk/pull/12389Decision tree for the text to be displayed:
flowchart TD
A{Timestamp on the message\npostdates 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])
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:Currently EIX is hiding such history until the device has access to backup:
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 eventorigin_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?
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
If an UTD has not be displayed on screen, it should not be reported to analytics.
Tasks
Known possible issues