Merge branch 'soru/other-aggregation-order' into 'main'

fix: Prioritize specced replies over unspecced event aggregations

See merge request famedly/famedlysdk!603
This commit is contained in:
Sorunome 2021-01-05 14:44:56 +00:00
commit 33500012b2
2 changed files with 5 additions and 6 deletions

View File

@ -626,16 +626,15 @@ class Event extends MatrixEvent {
/// Get the relationship type of an event. `null` if there is none
String get relationshipType {
if (content == null || !(content['m.relates_to'] is Map)) {
if (content?.tryGet<Map<String, dynamic>>('m.relates_to') == null) {
return null;
}
if (content['m.relates_to'].containsKey('rel_type')) {
return content['m.relates_to']['rel_type'];
}
if (content['m.relates_to'].containsKey('m.in_reply_to')) {
return RelationshipTypes.Reply;
}
return null;
return content
.tryGet<Map<String, dynamic>>('m.relates_to')
.tryGet<String>('rel_type');
}
/// Get the event ID that this relationship will reference. `null` if there is none

View File

@ -174,7 +174,7 @@ void main() {
jsonObj['type'] = 'm.room.message';
jsonObj['content']['msgtype'] = 'm.text';
jsonObj['content']['m.relates_to'] = {};
jsonObj['content']['m.relates_to'] = <String, dynamic>{};
jsonObj['content']['m.relates_to']['m.in_reply_to'] = {
'event_id': '1234',
};