-
Notifications
You must be signed in to change notification settings - Fork 38
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
refactor: Use Event instead of EventUpdate for storing in db #1992
base: main
Are you sure you want to change the base?
Conversation
1bb5044
to
d4091cf
Compare
82aedbf
to
43d9254
Compare
content: event.toJson(), | ||
), | ||
); | ||
if (event is MatrixEvent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we have an onInviteStateEvent
stream too? It's the only case where the event is not MatrixEvent
but a StrippedStateEvent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No because this would be a duplication of onSync
where you can just filter. This is for events after potential decryption
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, but we use onEvent
for local notifications. If there's no onInviteStateEvent
then we would miss inviteState
updates to show local notifications.
43d9254
to
ea18f23
Compare
if (event != null) { | ||
event.setRedactionEvent(Event.fromJson(eventUpdate.content, tmpRoom)); | ||
if (redactedEvent != null) { | ||
redactedEvent.setRedactionEvent(redactionEvent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redactedEvent.setRedactionEvent(redactionEvent); | |
redactedEvent.setRedactionEvent(event); |
|
||
if (tmpRoom.lastEvent?.eventId == event.eventId) { | ||
if (client.importantStateEvents.contains(event.type)) { | ||
await _preloadRoomStateBox.put( | ||
TupleKey(eventUpdate.roomID, event.type, '').toString(), | ||
event.toJson(), | ||
); | ||
} else { | ||
await _nonPreloadRoomStateBox.put( | ||
TupleKey(eventUpdate.roomID, event.type, '').toString(), | ||
event.toJson(), | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just confirming. We removed it because it's already handled below right?
// Store a common state event
if (stateKey != null &&
// Don't store events as state updates when paginating backwards.
(eventUpdate.type == EventUpdateType.timeline ||
eventUpdate.type == EventUpdateType.state ||
eventUpdate.type == EventUpdateType.inviteState)) {
if (eventUpdate.content['type'] == EventTypes.RoomMember) {
await _roomMembersBox.put(
TupleKey(
eventUpdate.roomID,
eventUpdate.content['state_key'],
).toString(),
eventUpdate.content,
);
} else {
final type = eventUpdate.content['type'] as String;
final roomStateBox = client.importantStateEvents.contains(type)
? _preloadRoomStateBox
: _nonPreloadRoomStateBox;
final key = TupleKey(
eventUpdate.roomID,
type,
stateKey,
).toString();
await roomStateBox.put(key, eventUpdate.content);
}
}
(type == EventUpdateType.timeline || | ||
type == EventUpdateType.state || | ||
type == EventUpdateType.inviteState)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(type == EventUpdateType.timeline || | |
type == EventUpdateType.state || | |
type == EventUpdateType.inviteState)) { | |
{EventUpdateType.timeline, EventUpdateType.state, EventUpdateType.inviteState}.contains(type)) { |
? eventUpdate.content['unsigned']['transaction_id'] | ||
: null, | ||
event_id: event.eventId, | ||
unsigned_txid: event.unsigned?.tryGet<String>('transaction_id'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's enough usage of event.unsigned?.tryGet<String>('transaction_id')
to create a getter txid
in the Event
class. Should we create one? I can open a separate PR for that if you agree.
expect(eventUpdateList[0].roomID, '!726s6s6q:example.com'); | ||
expect(eventUpdateList[0].type, EventUpdateType.state); | ||
expect(eventUpdateList[0].type, 'm.room.member'); | ||
expect(eventUpdateList[0].roomId, '!726s6s6q:example.com'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could also have a event.type
check here for all these 3 cases (just like before)
Fixes https://github.com/famedly/product-management/issues/1875