feat: Implement room tombstones

This commit is contained in:
Christian Pauly 2020-11-21 15:28:05 +01:00
parent 0697d47cc2
commit 411d29cc89
2 changed files with 26 additions and 0 deletions

View File

@ -18,6 +18,7 @@
import 'dart:async';
import 'package:famedlysdk/src/utils/tombstone_content.dart';
import 'package:html_unescape/html_unescape.dart';
import 'package:matrix_file_e2ee/matrix_file_e2ee.dart';
@ -1665,4 +1666,14 @@ class Room {
await client.handleSync(syncUpdate, sortAtTheEnd: sortAtTheEnd);
}
}
/// Whether this is an extinct room which has been archived in favor of a new
/// room which replaces this. Use [getLegacyRoomInformations] to get more
/// informations about it if this is true.
bool get isExtinct => getState(EventTypes.RoomTombstone) != null;
/// Returns informations about how this room is
TombstoneContent get extinctInformations => isExtinct
? TombstoneContent.fromJson(getState(EventTypes.RoomTombstone).content)
: null;
}

View File

@ -0,0 +1,15 @@
class TombstoneContent {
String body;
String replacementRoom;
TombstoneContent.fromJson(Map<String, dynamic> json)
: body = json['body'],
replacementRoom = json['replacement_room'];
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['body'] = body;
data['replacement_room'] = replacementRoom;
return data;
}
}