Fix resending messages reusing an existing transaction id

This commit is contained in:
Sorunome 2020-08-05 13:24:57 +02:00 committed by Christian Pauly
parent bbd5749aec
commit 2796ca613a
2 changed files with 7 additions and 6 deletions

View file

@ -319,11 +319,11 @@ class Event extends MatrixEvent {
if (status != -1) return null;
// we do not remove the event here. It will automatically be updated
// in the `sendEvent` method to transition -1 -> 0 -> 1 -> 2
final eventID = await room.sendEvent(
final newEventId = await room.sendEvent(
content,
txid: txid ?? unsigned['transaction_id'],
txid: txid ?? unsigned['transaction_id'] ?? eventId,
);
return eventID;
return newEventId;
}
/// Whether the client is allowed to redact this event.

View file

@ -691,7 +691,10 @@ class Room {
..eventId = messageID
..senderId = client.userID
..originServerTs = DateTime.now()
..unsigned = {MessageSendingStatusKey: 0},
..unsigned = {
MessageSendingStatusKey: 0,
'transaction_id': messageID,
},
]))));
await client.handleSync(syncUpdate);
@ -709,8 +712,6 @@ class Room {
);
syncUpdate.rooms.join.values.first.timeline.events.first
.unsigned[MessageSendingStatusKey] = 1;
syncUpdate.rooms.join.values.first.timeline.events.first
.unsigned['transaction_id'] = messageID;
syncUpdate.rooms.join.values.first.timeline.events.first.eventId = res;
await client.handleSync(syncUpdate);
return res;