feat: Check if event type is known

This commit is contained in:
Sorunome 2020-11-08 13:06:25 +01:00
parent 5aec7aab32
commit 66572bd032
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C
4 changed files with 271 additions and 207 deletions

View File

@ -31,7 +31,7 @@ abstract class EventTypes {
static const String RoomPinnedEvents = 'm.room.pinned_events';
static const String RoomTopic = 'm.room.topic';
static const String RoomAvatar = 'm.room.avatar';
static const String RoomTombstone = 'm.room.tombsone';
static const String RoomTombstone = 'm.room.tombstone';
static const String GuestAccess = 'm.room.guest_access';
static const String HistoryVisibility = 'm.room.history_visibility';
static const String Encryption = 'm.room.encryption';

View File

@ -22,13 +22,13 @@ import 'dart:typed_data';
import 'package:http/http.dart' as http;
import 'package:matrix_file_e2ee/matrix_file_e2ee.dart';
import '../encryption.dart';
import '../famedlysdk.dart';
import '../matrix_api.dart';
import 'database/database.dart' show DbRoomState, DbEvent;
import 'room.dart';
import 'utils/matrix_localizations.dart';
import 'utils/receipt.dart';
import 'utils/event_localizations.dart';
abstract class RelationshipTypes {
static const String Reply = 'm.in_reply_to';
@ -46,6 +46,8 @@ class Event extends MatrixEvent {
@Deprecated('Use [type] instead')
String get typeKey => type;
String get senderName => sender.calcDisplayname();
/// The room this event belongs to. May be null.
final Room room;
@ -450,6 +452,10 @@ class Event extends MatrixEvent {
return MatrixFile(bytes: uint8list, name: body);
}
/// Returns if this is a known event type.
bool get isEventTypeKnown =>
EventLocalizations.localizationsMap.containsKey(type);
/// Returns a localized String representation of this event. For a
/// room list you may find [withSenderNamePrefix] useful. Set [hideReply] to
/// crop all lines starting with '>'.
@ -458,210 +464,10 @@ class Event extends MatrixEvent {
if (redacted) {
return i18n.removedBy(redactedBecause.sender.calcDisplayname());
}
var localizedBody = body;
final senderName = sender.calcDisplayname();
switch (type) {
case EventTypes.Sticker:
localizedBody = i18n.sentASticker(senderName);
break;
case EventTypes.Redaction:
localizedBody = i18n.redactedAnEvent(senderName);
break;
case EventTypes.RoomAliases:
localizedBody = i18n.changedTheRoomAliases(senderName);
break;
case EventTypes.RoomCanonicalAlias:
localizedBody = i18n.changedTheRoomInvitationLink(senderName);
break;
case EventTypes.RoomCreate:
localizedBody = i18n.createdTheChat(senderName);
break;
case EventTypes.RoomTombstone:
localizedBody = i18n.roomHasBeenUpgraded;
break;
case EventTypes.RoomJoinRules:
var joinRules = JoinRules.values.firstWhere(
(r) =>
r.toString().replaceAll('JoinRules.', '') ==
content['join_rule'],
orElse: () => null);
if (joinRules == null) {
localizedBody = i18n.changedTheJoinRules(senderName);
} else {
localizedBody = i18n.changedTheJoinRulesTo(
senderName, joinRules.getLocalizedString(i18n));
}
break;
case EventTypes.RoomMember:
var text = 'Failed to parse member event';
final targetName = stateKeyUser.calcDisplayname();
// Has the membership changed?
final newMembership = content['membership'] ?? '';
final oldMembership =
prevContent != null ? prevContent['membership'] ?? '' : '';
if (newMembership != oldMembership) {
if (oldMembership == 'invite' && newMembership == 'join') {
text = i18n.acceptedTheInvitation(targetName);
} else if (oldMembership == 'invite' && newMembership == 'leave') {
if (stateKey == senderId) {
text = i18n.rejectedTheInvitation(targetName);
} else {
text = i18n.hasWithdrawnTheInvitationFor(senderName, targetName);
}
} else if (oldMembership == 'leave' && newMembership == 'join') {
text = i18n.joinedTheChat(targetName);
} else if (oldMembership == 'join' && newMembership == 'ban') {
text = i18n.kickedAndBanned(senderName, targetName);
} else if (oldMembership == 'join' &&
newMembership == 'leave' &&
stateKey != senderId) {
text = i18n.kicked(senderName, targetName);
} else if (oldMembership == 'join' &&
newMembership == 'leave' &&
stateKey == senderId) {
text = i18n.userLeftTheChat(targetName);
} else if (oldMembership == 'invite' && newMembership == 'ban') {
text = i18n.bannedUser(senderName, targetName);
} else if (oldMembership == 'leave' && newMembership == 'ban') {
text = i18n.bannedUser(senderName, targetName);
} else if (oldMembership == 'ban' && newMembership == 'leave') {
text = i18n.unbannedUser(senderName, targetName);
} else if (newMembership == 'invite') {
text = i18n.invitedUser(senderName, targetName);
} else if (newMembership == 'join') {
text = i18n.joinedTheChat(targetName);
}
} else if (newMembership == 'join') {
final newAvatar = content['avatar_url'] ?? '';
final oldAvatar =
prevContent != null ? prevContent['avatar_url'] ?? '' : '';
final newDisplayname = content['displayname'] ?? '';
final oldDisplayname =
prevContent != null ? prevContent['displayname'] ?? '' : '';
// Has the user avatar changed?
if (newAvatar != oldAvatar) {
text = i18n.changedTheProfileAvatar(targetName);
}
// Has the user avatar changed?
else if (newDisplayname != oldDisplayname) {
text = i18n.changedTheDisplaynameTo(targetName, newDisplayname);
}
}
localizedBody = text;
break;
case EventTypes.RoomPowerLevels:
localizedBody = i18n.changedTheChatPermissions(senderName);
break;
case EventTypes.RoomName:
localizedBody = i18n.changedTheChatNameTo(senderName, content['name']);
break;
case EventTypes.RoomTopic:
localizedBody =
i18n.changedTheChatDescriptionTo(senderName, content['topic']);
break;
case EventTypes.RoomAvatar:
localizedBody = i18n.changedTheChatAvatar(senderName);
break;
case EventTypes.GuestAccess:
var guestAccess = GuestAccess.values.firstWhere(
(r) =>
r.toString().replaceAll('GuestAccess.', '') ==
content['guest_access'],
orElse: () => null);
if (guestAccess == null) {
localizedBody = i18n.changedTheGuestAccessRules(senderName);
} else {
localizedBody = i18n.changedTheGuestAccessRulesTo(
senderName, guestAccess.getLocalizedString(i18n));
}
break;
case EventTypes.HistoryVisibility:
var historyVisibility = HistoryVisibility.values.firstWhere(
(r) =>
r.toString().replaceAll('HistoryVisibility.', '') ==
content['history_visibility'],
orElse: () => null);
if (historyVisibility == null) {
localizedBody = i18n.changedTheHistoryVisibility(senderName);
} else {
localizedBody = i18n.changedTheHistoryVisibilityTo(
senderName, historyVisibility.getLocalizedString(i18n));
}
break;
case EventTypes.Encryption:
localizedBody = i18n.activatedEndToEndEncryption(senderName);
if (!room.client.encryptionEnabled) {
localizedBody += '. ' + i18n.needPantalaimonWarning;
}
break;
case EventTypes.CallAnswer:
localizedBody = i18n.answeredTheCall(senderName);
break;
case EventTypes.CallHangup:
localizedBody = i18n.endedTheCall(senderName);
break;
case EventTypes.CallInvite:
localizedBody = i18n.startedACall(senderName);
break;
case EventTypes.CallCandidates:
localizedBody = i18n.sentCallInformations(senderName);
break;
case EventTypes.Encrypted:
case EventTypes.Message:
switch (messageType) {
case MessageTypes.Image:
localizedBody = i18n.sentAPicture(senderName);
break;
case MessageTypes.File:
localizedBody = i18n.sentAFile(senderName);
break;
case MessageTypes.Audio:
localizedBody = i18n.sentAnAudio(senderName);
break;
case MessageTypes.Video:
localizedBody = i18n.sentAVideo(senderName);
break;
case MessageTypes.Location:
localizedBody = i18n.sharedTheLocation(senderName);
break;
case MessageTypes.Sticker:
localizedBody = i18n.sentASticker(senderName);
break;
case MessageTypes.Emote:
localizedBody = '* $body';
break;
case MessageTypes.BadEncrypted:
String errorText;
switch (body) {
case DecryptError.CHANNEL_CORRUPTED:
errorText = i18n.channelCorruptedDecryptError + '.';
break;
case DecryptError.NOT_ENABLED:
errorText = i18n.encryptionNotEnabled + '.';
break;
case DecryptError.UNKNOWN_ALGORITHM:
errorText = i18n.unknownEncryptionAlgorithm + '.';
break;
case DecryptError.UNKNOWN_SESSION:
errorText = i18n.noPermission + '.';
break;
default:
errorText = body;
break;
}
localizedBody = i18n.couldNotDecryptMessage(errorText);
break;
case MessageTypes.Text:
case MessageTypes.Notice:
case MessageTypes.None:
localizedBody = body;
break;
}
break;
default:
localizedBody = i18n.unknownEvent(type);
final callback = EventLocalizations.localizationsMap[type];
var localizedBody = i18n.unknownEvent(type);
if (callback != null) {
localizedBody = callback(this, i18n);
}
// Hide reply fallback

View File

@ -0,0 +1,215 @@
/*
* Famedly Matrix SDK
* Copyright (C) 2019, 2020 Famedly GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import '../../matrix_api.dart';
import '../../encryption.dart';
import '../event.dart';
import '../room.dart';
import 'matrix_localizations.dart';
abstract class EventLocalizations {
static String _localizedBodyNormalMessage(
Event event, MatrixLocalizations i18n) {
switch (event.messageType) {
case MessageTypes.Image:
return i18n.sentAPicture(event.senderName);
case MessageTypes.File:
return i18n.sentAFile(event.senderName);
case MessageTypes.Audio:
return i18n.sentAnAudio(event.senderName);
case MessageTypes.Video:
return i18n.sentAVideo(event.senderName);
case MessageTypes.Location:
return i18n.sharedTheLocation(event.senderName);
case MessageTypes.Sticker:
return i18n.sentASticker(event.senderName);
case MessageTypes.Emote:
return '* ${event.body}';
case MessageTypes.BadEncrypted:
String errorText;
switch (event.body) {
case DecryptError.CHANNEL_CORRUPTED:
errorText = i18n.channelCorruptedDecryptError + '.';
break;
case DecryptError.NOT_ENABLED:
errorText = i18n.encryptionNotEnabled + '.';
break;
case DecryptError.UNKNOWN_ALGORITHM:
errorText = i18n.unknownEncryptionAlgorithm + '.';
break;
case DecryptError.UNKNOWN_SESSION:
errorText = i18n.noPermission + '.';
break;
default:
errorText = event.body;
break;
}
return i18n.couldNotDecryptMessage(errorText);
case MessageTypes.Text:
case MessageTypes.Notice:
case MessageTypes.None:
default:
return event.body;
}
}
// This map holds how to localize event types, and thus which event types exist.
// If an event exists but it does not have a localized body, set its callback to null
static final Map<String,
String Function(Event event, MatrixLocalizations i18n)>
localizationsMap = {
EventTypes.Sticker: (event, i18n) => i18n.sentASticker(event.senderName),
EventTypes.Redaction: (event, i18n) =>
i18n.redactedAnEvent(event.senderName),
EventTypes.RoomAliases: (event, i18n) =>
i18n.changedTheRoomAliases(event.senderName),
EventTypes.RoomCanonicalAlias: (event, i18n) =>
i18n.changedTheRoomInvitationLink(event.senderName),
EventTypes.RoomCreate: (event, i18n) =>
i18n.createdTheChat(event.senderName),
EventTypes.RoomTombstone: (event, i18n) => i18n.roomHasBeenUpgraded,
EventTypes.RoomJoinRules: (event, i18n) {
var joinRules = JoinRules.values.firstWhere(
(r) =>
r.toString().replaceAll('JoinRules.', '') ==
event.content['join_rule'],
orElse: () => null);
if (joinRules == null) {
return i18n.changedTheJoinRules(event.senderName);
} else {
return i18n.changedTheJoinRulesTo(
event.senderName, joinRules.getLocalizedString(i18n));
}
},
EventTypes.RoomMember: (event, i18n) {
var text = 'Failed to parse member event';
final targetName = event.stateKeyUser.calcDisplayname();
// Has the membership changed?
final newMembership = event.content['membership'] ?? '';
final oldMembership = event.prevContent != null
? event.prevContent['membership'] ?? ''
: '';
if (newMembership != oldMembership) {
if (oldMembership == 'invite' && newMembership == 'join') {
text = i18n.acceptedTheInvitation(targetName);
} else if (oldMembership == 'invite' && newMembership == 'leave') {
if (event.stateKey == event.senderId) {
text = i18n.rejectedTheInvitation(targetName);
} else {
text =
i18n.hasWithdrawnTheInvitationFor(event.senderName, targetName);
}
} else if (oldMembership == 'leave' && newMembership == 'join') {
text = i18n.joinedTheChat(targetName);
} else if (oldMembership == 'join' && newMembership == 'ban') {
text = i18n.kickedAndBanned(event.senderName, targetName);
} else if (oldMembership == 'join' &&
newMembership == 'leave' &&
event.stateKey != event.senderId) {
text = i18n.kicked(event.senderName, targetName);
} else if (oldMembership == 'join' &&
newMembership == 'leave' &&
event.stateKey == event.senderId) {
text = i18n.userLeftTheChat(targetName);
} else if (oldMembership == 'invite' && newMembership == 'ban') {
text = i18n.bannedUser(event.senderName, targetName);
} else if (oldMembership == 'leave' && newMembership == 'ban') {
text = i18n.bannedUser(event.senderName, targetName);
} else if (oldMembership == 'ban' && newMembership == 'leave') {
text = i18n.unbannedUser(event.senderName, targetName);
} else if (newMembership == 'invite') {
text = i18n.invitedUser(event.senderName, targetName);
} else if (newMembership == 'join') {
text = i18n.joinedTheChat(targetName);
}
} else if (newMembership == 'join') {
final newAvatar = event.content['avatar_url'] ?? '';
final oldAvatar = event.prevContent != null
? event.prevContent['avatar_url'] ?? ''
: '';
final newDisplayname = event.content['displayname'] ?? '';
final oldDisplayname = event.prevContent != null
? event.prevContent['displayname'] ?? ''
: '';
// Has the user avatar changed?
if (newAvatar != oldAvatar) {
text = i18n.changedTheProfileAvatar(targetName);
}
// Has the user avatar changed?
else if (newDisplayname != oldDisplayname) {
text = i18n.changedTheDisplaynameTo(targetName, newDisplayname);
}
}
return text;
},
EventTypes.RoomPowerLevels: (event, i18n) =>
i18n.changedTheChatPermissions(event.senderName),
EventTypes.RoomName: (event, i18n) =>
i18n.changedTheChatNameTo(event.senderName, event.content['name']),
EventTypes.RoomTopic: (event, i18n) => i18n.changedTheChatDescriptionTo(
event.senderName, event.content['topic']),
EventTypes.RoomAvatar: (event, i18n) =>
i18n.changedTheChatAvatar(event.senderName),
EventTypes.GuestAccess: (event, i18n) {
var guestAccess = GuestAccess.values.firstWhere(
(r) =>
r.toString().replaceAll('GuestAccess.', '') ==
event.content['guest_access'],
orElse: () => null);
if (guestAccess == null) {
return i18n.changedTheGuestAccessRules(event.senderName);
} else {
return i18n.changedTheGuestAccessRulesTo(
event.senderName, guestAccess.getLocalizedString(i18n));
}
},
EventTypes.HistoryVisibility: (event, i18n) {
var historyVisibility = HistoryVisibility.values.firstWhere(
(r) =>
r.toString().replaceAll('HistoryVisibility.', '') ==
event.content['history_visibility'],
orElse: () => null);
if (historyVisibility == null) {
return i18n.changedTheHistoryVisibility(event.senderName);
} else {
return i18n.changedTheHistoryVisibilityTo(
event.senderName, historyVisibility.getLocalizedString(i18n));
}
},
EventTypes.Encryption: (event, i18n) {
var localizedBody = i18n.activatedEndToEndEncryption(event.senderName);
if (!event.room.client.encryptionEnabled) {
localizedBody += '. ' + i18n.needPantalaimonWarning;
}
return localizedBody;
},
EventTypes.CallAnswer: (event, i18n) =>
i18n.answeredTheCall(event.senderName),
EventTypes.CallHangup: (event, i18n) => i18n.endedTheCall(event.senderName),
EventTypes.CallInvite: (event, i18n) => i18n.startedACall(event.senderName),
EventTypes.CallCandidates: (event, i18n) =>
i18n.sentCallInformations(event.senderName),
EventTypes.Encrypted: (event, i18n) =>
_localizedBodyNormalMessage(event, i18n),
EventTypes.Message: (event, i18n) =>
_localizedBodyNormalMessage(event, i18n),
EventTypes.Reaction: null,
};
}

View File

@ -325,7 +325,7 @@ void main() {
test('canRedact', () async {
expect(event.canRedact, true);
});
test('getLocalizedBody', () async {
test('getLocalizedBody, isEventKnown', () async {
final matrix = Client('testclient', httpClient: FakeMatrixApi());
final room = Room(id: '!1234:example.com', client: matrix);
var event = Event.fromJson({
@ -355,6 +355,7 @@ void main() {
}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {
@ -382,6 +383,7 @@ void main() {
'unsigned': {'age': 1234}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {'reason': 'Spamming'},
@ -394,6 +396,7 @@ void main() {
'unsigned': {'age': 1234}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {
@ -408,6 +411,7 @@ void main() {
'unsigned': {'age': 1234}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {
@ -422,6 +426,7 @@ void main() {
'unsigned': {'age': 1234}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {'alias': '#somewhere:localhost'},
@ -434,6 +439,7 @@ void main() {
'unsigned': {'age': 1234}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {
@ -454,6 +460,7 @@ void main() {
'unsigned': {'age': 1234}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {
@ -469,6 +476,7 @@ void main() {
'unsigned': {'age': 1234}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {'join_rule': 'public'},
@ -481,6 +489,7 @@ void main() {
'unsigned': {'age': 1234}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {
@ -497,6 +506,7 @@ void main() {
'unsigned': {'age': 1234}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {'membership': 'invite'},
@ -508,6 +518,7 @@ void main() {
'type': 'm.room.member'
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {'membership': 'leave'},
@ -522,6 +533,7 @@ void main() {
}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {'membership': 'ban'},
@ -536,6 +548,7 @@ void main() {
}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {'membership': 'join'},
@ -550,6 +563,7 @@ void main() {
}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {'membership': 'invite'},
@ -564,6 +578,7 @@ void main() {
}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {'membership': 'leave'},
@ -578,6 +593,7 @@ void main() {
}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {'membership': 'leave'},
@ -592,6 +608,7 @@ void main() {
}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {
@ -615,6 +632,7 @@ void main() {
'unsigned': {'age': 1234}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {'name': 'The room name'},
@ -627,6 +645,7 @@ void main() {
'unsigned': {'age': 1234}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {'topic': 'A room topic'},
@ -639,6 +658,7 @@ void main() {
'unsigned': {'age': 1234}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {
@ -654,6 +674,7 @@ void main() {
'unsigned': {'age': 1234}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {'history_visibility': 'shared'},
@ -666,6 +687,7 @@ void main() {
'unsigned': {'age': 1234}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {
@ -683,6 +705,7 @@ void main() {
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()),
'Example activatedEndToEndEncryption. needPantalaimonWarning');
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {
@ -700,6 +723,7 @@ void main() {
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()),
'This is an example text message');
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {
@ -717,6 +741,7 @@ void main() {
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()),
'* thinks this is an example emote');
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {
@ -734,6 +759,7 @@ void main() {
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()),
'This is an example notice');
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {
@ -750,6 +776,7 @@ void main() {
'unsigned': {'age': 1234}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {
@ -767,6 +794,7 @@ void main() {
'unsigned': {'age': 1234}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {
@ -787,6 +815,7 @@ void main() {
'unsigned': {'age': 1234}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {
@ -811,6 +840,7 @@ void main() {
'unsigned': {'age': 1234}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {
@ -840,6 +870,19 @@ void main() {
'unsigned': {'age': 1234}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, true);
event = Event.fromJson({
'content': {'beep': 'boop'},
'event_id': '\$143273582443PhrSn:example.org',
'origin_server_ts': 1432735824653,
'room_id': '!jEsUZKDJdhlrceRyVU:example.org',
'sender': '@example:example.org',
'type': 'unknown.event.type',
'unsigned': {'age': 1234}
}, room);
expect(event.getLocalizedBody(FakeMatrixLocalizations()), null);
expect(event.isEventTypeKnown, false);
});
test('aggregations', () {