fix: Do not assume a missing timestamp means "now"

This causes issues with state handling as we prefer the newer event. It
also has knock-on effects in other places. Instead set such events to
have an obviously invalid timestamp, which makes issues easier to
identify.

This may break invites showing a timestamp or the timestamps for just
sent events, if you rely on the timestamp getting set to "now".
This commit is contained in:
Nicolas Werner 2024-03-04 17:49:50 +01:00
parent 23bc6ef465
commit 5ffa99d994
No known key found for this signature in database
GPG Key ID: B38119FF80087618
1 changed files with 2 additions and 4 deletions

View File

@ -210,10 +210,8 @@ class Event extends MatrixEvent {
type: jsonPayload['type'],
eventId: jsonPayload['event_id'] ?? '',
senderId: jsonPayload['sender'],
originServerTs: jsonPayload['origin_server_ts'] != null
? DateTime.fromMillisecondsSinceEpoch(
jsonPayload['origin_server_ts'])
: DateTime.now(),
originServerTs: DateTime.fromMillisecondsSinceEpoch(
jsonPayload['origin_server_ts'] ?? 0),
unsigned: unsigned,
room: room,
originalSource: originalSource.isEmpty