Add tombstone enum

This commit is contained in:
Christian Pauly 2020-05-16 09:47:19 +02:00
parent 7c0d84b27f
commit e66a904ee0
2 changed files with 14 additions and 4 deletions

View file

@ -126,7 +126,8 @@ class Event {
} }
/// Get a State event from a table row or from the event stream. /// Get a State event from a table row or from the event stream.
factory Event.fromJson(Map<String, dynamic> jsonPayload, Room room, [double sortOrder]) { factory Event.fromJson(Map<String, dynamic> jsonPayload, Room room,
[double sortOrder]) {
final content = Event.getMapFromPayload(jsonPayload['content']); final content = Event.getMapFromPayload(jsonPayload['content']);
final unsigned = Event.getMapFromPayload(jsonPayload['unsigned']); final unsigned = Event.getMapFromPayload(jsonPayload['unsigned']);
final prevContent = Event.getMapFromPayload(jsonPayload['prev_content']); final prevContent = Event.getMapFromPayload(jsonPayload['prev_content']);
@ -151,7 +152,7 @@ class Event {
/// Get an event from either DbRoomState or DbEvent /// Get an event from either DbRoomState or DbEvent
factory Event.fromDb(dynamic dbEntry, Room room) { factory Event.fromDb(dynamic dbEntry, Room room) {
if (!(dbEntry is DbRoomState || dbEntry is DbEvent)) { if (!(dbEntry is DbRoomState || dbEntry is DbEvent)) {
throw('Unknown db type'); throw ('Unknown db type');
} }
final content = Event.getMapFromPayload(dbEntry.content); final content = Event.getMapFromPayload(dbEntry.content);
final unsigned = Event.getMapFromPayload(dbEntry.unsigned); final unsigned = Event.getMapFromPayload(dbEntry.unsigned);
@ -242,6 +243,8 @@ class Event {
return EventTypes.Encrypted; return EventTypes.Encrypted;
case 'm.room.encryption': case 'm.room.encryption':
return EventTypes.Encryption; return EventTypes.Encryption;
case 'm.room.tombsone':
return EventTypes.RoomTombstone;
case 'm.call.invite': case 'm.call.invite':
return EventTypes.CallInvite; return EventTypes.CallInvite;
case 'm.call.answer': case 'm.call.answer':
@ -501,7 +504,7 @@ class Event {
final storeable = room.client.database != null && final storeable = room.client.database != null &&
infoMap is Map<String, dynamic> && infoMap is Map<String, dynamic> &&
infoMap['size'] is int && infoMap['size'] is int &&
infoMap['size'] <= room.client.database.maxFileSize ; infoMap['size'] <= room.client.database.maxFileSize;
if (storeable) { if (storeable) {
uint8list = await room.client.database.getFile(mxContent.toString()); uint8list = await room.client.database.getFile(mxContent.toString());
@ -512,7 +515,8 @@ class Event {
uint8list = uint8list =
(await http.get(mxContent.getDownloadLink(room.client))).bodyBytes; (await http.get(mxContent.getDownloadLink(room.client))).bodyBytes;
if (storeable) { if (storeable) {
await room.client.database.storeFile(mxContent.toString(), uint8list, DateTime.now()); await room.client.database
.storeFile(mxContent.toString(), uint8list, DateTime.now());
} }
} }
@ -559,6 +563,9 @@ class Event {
case EventTypes.RoomCreate: case EventTypes.RoomCreate:
localizedBody = i18n.createdTheChat(senderName); localizedBody = i18n.createdTheChat(senderName);
break; break;
case EventTypes.RoomTombstone:
localizedBody = i18n.roomHasBeenUpgraded;
break;
case EventTypes.RoomJoinRules: case EventTypes.RoomJoinRules:
var joinRules = JoinRules.values.firstWhere( var joinRules = JoinRules.values.firstWhere(
(r) => (r) =>
@ -792,6 +799,7 @@ enum EventTypes {
RoomName, RoomName,
RoomTopic, RoomTopic,
RoomAvatar, RoomAvatar,
RoomTombstone,
GuestAccess, GuestAccess,
HistoryVisibility, HistoryVisibility,
Encryption, Encryption,

View file

@ -31,6 +31,8 @@ abstract class MatrixLocalizations {
String get you; String get you;
String get roomHasBeenUpgraded;
String groupWith(String displayname); String groupWith(String displayname);
String removedBy(String calcDisplayname); String removedBy(String calcDisplayname);