Skip to content

Commit

Permalink
Merge pull request #1989 from famedly/krille/follow-up-store-utd-events
Browse files Browse the repository at this point in the history
chore: Follow up store unable to decrypt information correctly
  • Loading branch information
krille-chan authored Dec 31, 2024
2 parents d89c8a3 + 632ecbe commit 0caec7c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
6 changes: 2 additions & 4 deletions lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2755,14 +2755,12 @@ class Client extends MatrixApi {
if (event is MatrixEvent &&
event.type == EventTypes.Encrypted &&
encryptionEnabled) {
final decrypted = await encryption!.decryptRoomEvent(
event = await encryption!.decryptRoomEvent(
Event.fromMatrixEvent(event, room),
updateType: type,
);

if (decrypted.type != EventTypes.Encrypted) {
event = decrypted;
} else {
if (event.type == EventTypes.Encrypted) {
// if the event failed to decrypt, add it to the queue
_eventsPendingDecryption.add(
_EventPendingDecryption(Event.fromMatrixEvent(event, room)),
Expand Down
33 changes: 20 additions & 13 deletions lib/src/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,27 @@ class Event extends MatrixEvent {
factory Event.fromMatrixEvent(
MatrixEvent matrixEvent,
Room room, {
EventStatus status = defaultStatus,
EventStatus? status,
}) =>
Event(
status: status,
content: matrixEvent.content,
type: matrixEvent.type,
eventId: matrixEvent.eventId,
senderId: matrixEvent.senderId,
originServerTs: matrixEvent.originServerTs,
unsigned: matrixEvent.unsigned,
prevContent: matrixEvent.prevContent,
stateKey: matrixEvent.stateKey,
room: room,
);
matrixEvent is Event
? matrixEvent
: Event(
status: status ??
eventStatusFromInt(
matrixEvent.unsigned
?.tryGet<int>('messageSendingStatusKey') ??
defaultStatus.intValue,
),
content: matrixEvent.content,
type: matrixEvent.type,
eventId: matrixEvent.eventId,
senderId: matrixEvent.senderId,
originServerTs: matrixEvent.originServerTs,
unsigned: matrixEvent.unsigned,
prevContent: matrixEvent.prevContent,
stateKey: matrixEvent.stateKey,
room: room,
);

/// Get a State event from a table row or from the event stream.
factory Event.fromJson(
Expand Down

0 comments on commit 0caec7c

Please sign in to comment.