refactor: Make room in Event class not nullable
This commit is contained in:
parent
938d58da96
commit
9be87918f1
|
|
@ -270,7 +270,6 @@ class Encryption {
|
||||||
type: decryptedPayload['type'],
|
type: decryptedPayload['type'],
|
||||||
senderId: event.senderId,
|
senderId: event.senderId,
|
||||||
eventId: event.eventId,
|
eventId: event.eventId,
|
||||||
roomId: event.roomId,
|
|
||||||
room: event.room,
|
room: event.room,
|
||||||
originServerTs: event.originServerTs,
|
originServerTs: event.originServerTs,
|
||||||
unsigned: event.unsigned,
|
unsigned: event.unsigned,
|
||||||
|
|
@ -304,7 +303,7 @@ class Encryption {
|
||||||
}
|
}
|
||||||
if (event.type != EventTypes.Encrypted && store) {
|
if (event.type != EventTypes.Encrypted && store) {
|
||||||
if (updateType != EventUpdateType.history) {
|
if (updateType != EventUpdateType.history) {
|
||||||
event.room?.setState(event);
|
event.room.setState(event);
|
||||||
}
|
}
|
||||||
await client.database?.storeEventUpdate(
|
await client.database?.storeEventUpdate(
|
||||||
EventUpdate(
|
EventUpdate(
|
||||||
|
|
|
||||||
|
|
@ -886,13 +886,18 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
|
||||||
.contains(eventUpdate.type)) {
|
.contains(eventUpdate.type)) {
|
||||||
final eventId = eventUpdate.content['event_id'];
|
final eventId = eventUpdate.content['event_id'];
|
||||||
// Is this ID already in the store?
|
// Is this ID already in the store?
|
||||||
final prevEvent = _eventsBox
|
final Map? prevEvent = await _eventsBox
|
||||||
.containsKey(MultiKey(eventUpdate.roomID, eventId).toString())
|
.get(MultiKey(eventUpdate.roomID, eventId).toString());
|
||||||
? Event.fromJson(
|
final prevStatus = prevEvent == null
|
||||||
convertToJson(await _eventsBox
|
? null
|
||||||
.get(MultiKey(eventUpdate.roomID, eventId).toString())),
|
: () {
|
||||||
null)
|
final json = convertToJson(prevEvent);
|
||||||
: null;
|
final statusInt = json.tryGet<int>('status') ??
|
||||||
|
json
|
||||||
|
.tryGetMap<String, dynamic>('unsigned')
|
||||||
|
?.tryGet<int>(messageSendingStatusKey);
|
||||||
|
return statusInt == null ? null : eventStatusFromInt(statusInt);
|
||||||
|
}();
|
||||||
|
|
||||||
// calculate the status
|
// calculate the status
|
||||||
final newStatus = eventStatusFromInt(
|
final newStatus = eventStatusFromInt(
|
||||||
|
|
@ -905,16 +910,14 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
|
||||||
|
|
||||||
// Is this the response to a sending event which is already synced? Then
|
// Is this the response to a sending event which is already synced? Then
|
||||||
// there is nothing to do here.
|
// there is nothing to do here.
|
||||||
if (!newStatus.isSynced &&
|
if (!newStatus.isSynced && prevStatus != null && prevStatus.isSynced) {
|
||||||
prevEvent != null &&
|
|
||||||
prevEvent.status.isSynced) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final status = newStatus.isError || prevEvent == null
|
final status = newStatus.isError || prevEvent == null
|
||||||
? newStatus
|
? newStatus
|
||||||
: latestEventStatus(
|
: latestEventStatus(
|
||||||
prevEvent.status,
|
prevStatus!,
|
||||||
newStatus,
|
newStatus,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -945,8 +948,8 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
|
||||||
}
|
}
|
||||||
await _timelineFragmentsBox.put(key, eventIds);
|
await _timelineFragmentsBox.put(key, eventIds);
|
||||||
} else if (status.isSynced &&
|
} else if (status.isSynced &&
|
||||||
prevEvent != null &&
|
prevStatus != null &&
|
||||||
prevEvent.status.isSent &&
|
prevStatus.isSent &&
|
||||||
eventUpdate.type != EventUpdateType.history) {
|
eventUpdate.type != EventUpdateType.history) {
|
||||||
// Status changes from 1 -> 2? Make sure event is correctly sorted.
|
// Status changes from 1 -> 2? Make sure event is correctly sorted.
|
||||||
eventIds.remove(eventId);
|
eventIds.remove(eventId);
|
||||||
|
|
|
||||||
|
|
@ -38,13 +38,7 @@ abstract class RelationshipTypes {
|
||||||
|
|
||||||
/// All data exchanged over Matrix is expressed as an "event". Typically each client action (e.g. sending a message) correlates with exactly one event.
|
/// All data exchanged over Matrix is expressed as an "event". Typically each client action (e.g. sending a message) correlates with exactly one event.
|
||||||
class Event extends MatrixEvent {
|
class Event extends MatrixEvent {
|
||||||
User get sender =>
|
User get sender => room.getUserByMXIDSync(senderId);
|
||||||
room?.getUserByMXIDSync(senderId) ??
|
|
||||||
User.fromState(
|
|
||||||
stateKey: senderId,
|
|
||||||
typeKey: EventTypes.RoomMember,
|
|
||||||
originServerTs: DateTime.now(),
|
|
||||||
);
|
|
||||||
|
|
||||||
@Deprecated('Use [originServerTs] instead')
|
@Deprecated('Use [originServerTs] instead')
|
||||||
DateTime get time => originServerTs;
|
DateTime get time => originServerTs;
|
||||||
|
|
@ -56,7 +50,7 @@ class Event extends MatrixEvent {
|
||||||
String? get senderName => sender.calcDisplayname();
|
String? get senderName => sender.calcDisplayname();
|
||||||
|
|
||||||
/// The room this event belongs to. May be null.
|
/// The room this event belongs to. May be null.
|
||||||
final Room? room;
|
final Room room;
|
||||||
|
|
||||||
/// The status of this event.
|
/// The status of this event.
|
||||||
EventStatus status;
|
EventStatus status;
|
||||||
|
|
@ -74,27 +68,26 @@ class Event extends MatrixEvent {
|
||||||
|
|
||||||
bool get redacted => redactedBecause != null;
|
bool get redacted => redactedBecause != null;
|
||||||
|
|
||||||
User? get stateKeyUser => room?.getUserByMXIDSync(stateKey!);
|
User? get stateKeyUser => room.getUserByMXIDSync(stateKey!);
|
||||||
|
|
||||||
Event({
|
Event({
|
||||||
this.status = defaultStatus,
|
this.status = defaultStatus,
|
||||||
required Map<String, dynamic> content,
|
required Map<String, dynamic> content,
|
||||||
required String type,
|
required String type,
|
||||||
required String eventId,
|
required String eventId,
|
||||||
String? roomId,
|
|
||||||
required String senderId,
|
required String senderId,
|
||||||
required DateTime originServerTs,
|
required DateTime originServerTs,
|
||||||
Map<String, dynamic>? unsigned,
|
Map<String, dynamic>? unsigned,
|
||||||
Map<String, dynamic>? prevContent,
|
Map<String, dynamic>? prevContent,
|
||||||
String? stateKey,
|
String? stateKey,
|
||||||
this.room,
|
required this.room,
|
||||||
}) : super(
|
}) : super(
|
||||||
content: content,
|
content: content,
|
||||||
type: type,
|
type: type,
|
||||||
eventId: eventId,
|
eventId: eventId,
|
||||||
senderId: senderId,
|
senderId: senderId,
|
||||||
originServerTs: originServerTs,
|
originServerTs: originServerTs,
|
||||||
roomId: roomId ?? room?.id,
|
roomId: room.id,
|
||||||
) {
|
) {
|
||||||
this.eventId = eventId;
|
this.eventId = eventId;
|
||||||
this.unsigned = unsigned;
|
this.unsigned = unsigned;
|
||||||
|
|
@ -118,13 +111,13 @@ class Event extends MatrixEvent {
|
||||||
// Mark event as failed to send if status is `sending` and event is older
|
// Mark event as failed to send if status is `sending` and event is older
|
||||||
// than the timeout. This should not happen with the deprecated Moor
|
// than the timeout. This should not happen with the deprecated Moor
|
||||||
// database!
|
// database!
|
||||||
if (status.isSending && room?.client.database != null) {
|
if (status.isSending && room.client.database != null) {
|
||||||
// Age of this event in milliseconds
|
// Age of this event in milliseconds
|
||||||
final age = DateTime.now().millisecondsSinceEpoch -
|
final age = DateTime.now().millisecondsSinceEpoch -
|
||||||
originServerTs.millisecondsSinceEpoch;
|
originServerTs.millisecondsSinceEpoch;
|
||||||
|
|
||||||
final room = this.room;
|
final room = this.room;
|
||||||
if (room != null && age > room.client.sendMessageTimeoutSeconds * 1000) {
|
if (age > room.client.sendMessageTimeoutSeconds * 1000) {
|
||||||
// Update this event in database and open timelines
|
// Update this event in database and open timelines
|
||||||
final json = toJson();
|
final json = toJson();
|
||||||
json['unsigned'] ??= <String, dynamic>{};
|
json['unsigned'] ??= <String, dynamic>{};
|
||||||
|
|
@ -161,7 +154,6 @@ class Event extends MatrixEvent {
|
||||||
content: matrixEvent.content,
|
content: matrixEvent.content,
|
||||||
type: matrixEvent.type,
|
type: matrixEvent.type,
|
||||||
eventId: matrixEvent.eventId,
|
eventId: matrixEvent.eventId,
|
||||||
roomId: room.id,
|
|
||||||
senderId: matrixEvent.senderId,
|
senderId: matrixEvent.senderId,
|
||||||
originServerTs: matrixEvent.originServerTs,
|
originServerTs: matrixEvent.originServerTs,
|
||||||
unsigned: matrixEvent.unsigned,
|
unsigned: matrixEvent.unsigned,
|
||||||
|
|
@ -173,7 +165,7 @@ class Event extends MatrixEvent {
|
||||||
/// 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(
|
factory Event.fromJson(
|
||||||
Map<String, dynamic> jsonPayload,
|
Map<String, dynamic> jsonPayload,
|
||||||
Room? room,
|
Room room,
|
||||||
) {
|
) {
|
||||||
final content = Event.getMapFromPayload(jsonPayload['content']);
|
final content = Event.getMapFromPayload(jsonPayload['content']);
|
||||||
final unsigned = Event.getMapFromPayload(jsonPayload['unsigned']);
|
final unsigned = Event.getMapFromPayload(jsonPayload['unsigned']);
|
||||||
|
|
@ -187,7 +179,6 @@ class Event extends MatrixEvent {
|
||||||
content: content,
|
content: content,
|
||||||
type: jsonPayload['type'],
|
type: jsonPayload['type'],
|
||||||
eventId: jsonPayload['event_id'] ?? '',
|
eventId: jsonPayload['event_id'] ?? '',
|
||||||
roomId: jsonPayload['room_id'],
|
|
||||||
senderId: jsonPayload['sender'],
|
senderId: jsonPayload['sender'],
|
||||||
originServerTs: jsonPayload.containsKey('origin_server_ts')
|
originServerTs: jsonPayload.containsKey('origin_server_ts')
|
||||||
? DateTime.fromMillisecondsSinceEpoch(jsonPayload['origin_server_ts'])
|
? DateTime.fromMillisecondsSinceEpoch(jsonPayload['origin_server_ts'])
|
||||||
|
|
@ -295,8 +286,8 @@ class Event extends MatrixEvent {
|
||||||
/// Returns a list of [Receipt] instances for this event.
|
/// Returns a list of [Receipt] instances for this event.
|
||||||
List<Receipt> get receipts {
|
List<Receipt> get receipts {
|
||||||
final room = this.room;
|
final room = this.room;
|
||||||
final receipt = room?.roomAccountData['m.receipt'];
|
final receipt = room.roomAccountData['m.receipt'];
|
||||||
if (receipt == null || room == null) return [];
|
if (receipt == null) return [];
|
||||||
return receipt.content.entries
|
return receipt.content.entries
|
||||||
.where((entry) => entry.value['event_id'] == eventId)
|
.where((entry) => entry.value['event_id'] == eventId)
|
||||||
.map((entry) => Receipt(room.getUserByMXIDSync(entry.key),
|
.map((entry) => Receipt(room.getUserByMXIDSync(entry.key),
|
||||||
|
|
@ -309,9 +300,6 @@ class Event extends MatrixEvent {
|
||||||
/// Returns [false] if not removed.
|
/// Returns [false] if not removed.
|
||||||
Future<bool> remove() async {
|
Future<bool> remove() async {
|
||||||
final room = this.room;
|
final room = this.room;
|
||||||
if (room == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!status.isSent) {
|
if (!status.isSent) {
|
||||||
await room.client.database?.removeEvent(eventId, room.id);
|
await room.client.database?.removeEvent(eventId, room.id);
|
||||||
|
|
@ -335,7 +323,7 @@ class Event extends MatrixEvent {
|
||||||
if (!status.isError) return null;
|
if (!status.isError) return null;
|
||||||
// we do not remove the event here. It will automatically be updated
|
// we do not remove the event here. It will automatically be updated
|
||||||
// in the `sendEvent` method to transition -1 -> 0 -> 1 -> 2
|
// in the `sendEvent` method to transition -1 -> 0 -> 1 -> 2
|
||||||
final newEventId = await room?.sendEvent(
|
final newEventId = await room.sendEvent(
|
||||||
content,
|
content,
|
||||||
txid: txid ?? unsigned?['transaction_id'] ?? eventId,
|
txid: txid ?? unsigned?['transaction_id'] ?? eventId,
|
||||||
);
|
);
|
||||||
|
|
@ -343,12 +331,11 @@ class Event extends MatrixEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the client is allowed to redact this event.
|
/// Whether the client is allowed to redact this event.
|
||||||
bool get canRedact =>
|
bool get canRedact => senderId == room.client.userID || room.canRedact;
|
||||||
senderId == room?.client.userID || (room?.canRedact ?? false);
|
|
||||||
|
|
||||||
/// Redacts this event. Throws `ErrorResponse` on error.
|
/// Redacts this event. Throws `ErrorResponse` on error.
|
||||||
Future<String?> redactEvent({String? reason, String? txid}) async =>
|
Future<String?> redactEvent({String? reason, String? txid}) async =>
|
||||||
await room?.redactEvent(eventId, reason: reason, txid: txid);
|
await room.redactEvent(eventId, reason: reason, txid: txid);
|
||||||
|
|
||||||
/// Searches for the reply event in the given timeline.
|
/// Searches for the reply event in the given timeline.
|
||||||
Future<Event?> getReplyEvent(Timeline timeline) async {
|
Future<Event?> getReplyEvent(Timeline timeline) async {
|
||||||
|
|
@ -369,7 +356,7 @@ class Event extends MatrixEvent {
|
||||||
content['can_request_session'] != true) {
|
content['can_request_session'] != true) {
|
||||||
throw ('Session key not requestable');
|
throw ('Session key not requestable');
|
||||||
}
|
}
|
||||||
await room?.requestSessionKey(content['session_id'], content['sender_key']);
|
await room.requestSessionKey(content['session_id'], content['sender_key']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -456,10 +443,6 @@ class Event extends MatrixEvent {
|
||||||
ThumbnailMethod method = ThumbnailMethod.scale,
|
ThumbnailMethod method = ThumbnailMethod.scale,
|
||||||
int minNoThumbSize = _minNoThumbSize,
|
int minNoThumbSize = _minNoThumbSize,
|
||||||
bool animated = false}) {
|
bool animated = false}) {
|
||||||
final client = room?.client;
|
|
||||||
if (client == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (![EventTypes.Message, EventTypes.Sticker].contains(type) ||
|
if (![EventTypes.Message, EventTypes.Sticker].contains(type) ||
|
||||||
!hasAttachment ||
|
!hasAttachment ||
|
||||||
isAttachmentEncrypted) {
|
isAttachmentEncrypted) {
|
||||||
|
|
@ -481,14 +464,14 @@ class Event extends MatrixEvent {
|
||||||
// now generate the actual URLs
|
// now generate the actual URLs
|
||||||
if (getThumbnail) {
|
if (getThumbnail) {
|
||||||
return Uri.parse(thisMxcUrl).getThumbnail(
|
return Uri.parse(thisMxcUrl).getThumbnail(
|
||||||
client,
|
room.client,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
method: method,
|
method: method,
|
||||||
animated: animated,
|
animated: animated,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return Uri.parse(thisMxcUrl).getDownloadLink(client);
|
return Uri.parse(thisMxcUrl).getDownloadLink(room.client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -504,7 +487,7 @@ class Event extends MatrixEvent {
|
||||||
getThumbnail = mxcUrl != attachmentMxcUrl;
|
getThumbnail = mxcUrl != attachmentMxcUrl;
|
||||||
// Is this file storeable?
|
// Is this file storeable?
|
||||||
final thisInfoMap = getThumbnail ? thumbnailInfoMap : infoMap;
|
final thisInfoMap = getThumbnail ? thumbnailInfoMap : infoMap;
|
||||||
final database = room?.client.database;
|
final database = room.client.database;
|
||||||
if (database == null) {
|
if (database == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -529,11 +512,7 @@ class Event extends MatrixEvent {
|
||||||
if (![EventTypes.Message, EventTypes.Sticker].contains(type)) {
|
if (![EventTypes.Message, EventTypes.Sticker].contains(type)) {
|
||||||
throw ("This event has the type '$type' and so it can't contain an attachment.");
|
throw ("This event has the type '$type' and so it can't contain an attachment.");
|
||||||
}
|
}
|
||||||
final client = room?.client;
|
final database = room.client.database;
|
||||||
final database = room?.client.database;
|
|
||||||
if (client == null) {
|
|
||||||
throw 'This event has no valid client.';
|
|
||||||
}
|
|
||||||
final mxcUrl = attachmentOrThumbnailMxcUrl(getThumbnail: getThumbnail);
|
final mxcUrl = attachmentOrThumbnailMxcUrl(getThumbnail: getThumbnail);
|
||||||
if (mxcUrl == null) {
|
if (mxcUrl == null) {
|
||||||
throw "This event hasn't any attachment or thumbnail.";
|
throw "This event hasn't any attachment or thumbnail.";
|
||||||
|
|
@ -541,7 +520,7 @@ class Event extends MatrixEvent {
|
||||||
getThumbnail = mxcUrl != attachmentMxcUrl;
|
getThumbnail = mxcUrl != attachmentMxcUrl;
|
||||||
final isEncrypted =
|
final isEncrypted =
|
||||||
getThumbnail ? isThumbnailEncrypted : isAttachmentEncrypted;
|
getThumbnail ? isThumbnailEncrypted : isAttachmentEncrypted;
|
||||||
if (isEncrypted && !client.encryptionEnabled) {
|
if (isEncrypted && !room.client.encryptionEnabled) {
|
||||||
throw ('Encryption is not enabled in your Client.');
|
throw ('Encryption is not enabled in your Client.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -553,13 +532,13 @@ class Event extends MatrixEvent {
|
||||||
|
|
||||||
Uint8List? uint8list;
|
Uint8List? uint8list;
|
||||||
if (storeable) {
|
if (storeable) {
|
||||||
uint8list = await client.database?.getFile(mxcUrl);
|
uint8list = await room.client.database?.getFile(mxcUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download the file
|
// Download the file
|
||||||
if (uint8list == null) {
|
if (uint8list == null) {
|
||||||
downloadCallback ??= (Uri url) async => (await http.get(url)).bodyBytes;
|
downloadCallback ??= (Uri url) async => (await http.get(url)).bodyBytes;
|
||||||
uint8list = await downloadCallback(mxcUrl.getDownloadLink(client));
|
uint8list = await downloadCallback(mxcUrl.getDownloadLink(room.client));
|
||||||
storeable = database != null &&
|
storeable = database != null &&
|
||||||
storeable &&
|
storeable &&
|
||||||
uint8list.lengthInBytes < database.maxFileSize;
|
uint8list.lengthInBytes < database.maxFileSize;
|
||||||
|
|
@ -582,7 +561,7 @@ class Event extends MatrixEvent {
|
||||||
k: fileMap['key']['k'],
|
k: fileMap['key']['k'],
|
||||||
sha256: fileMap['hashes']['sha256'],
|
sha256: fileMap['hashes']['sha256'],
|
||||||
);
|
);
|
||||||
uint8list = await client.runInBackground<Uint8List?, EncryptedFile>(
|
uint8list = await room.client.runInBackground<Uint8List?, EncryptedFile>(
|
||||||
decryptFile, encryptedFile);
|
decryptFile, encryptedFile);
|
||||||
if (uint8list == null) {
|
if (uint8list == null) {
|
||||||
throw ('Unable to decrypt file');
|
throw ('Unable to decrypt file');
|
||||||
|
|
@ -649,7 +628,7 @@ class Event extends MatrixEvent {
|
||||||
if (withSenderNamePrefix &&
|
if (withSenderNamePrefix &&
|
||||||
type == EventTypes.Message &&
|
type == EventTypes.Message &&
|
||||||
textOnlyMessageTypes.contains(messageType)) {
|
textOnlyMessageTypes.contains(messageType)) {
|
||||||
final senderNameOrYou = senderId == room?.client.userID
|
final senderNameOrYou = senderId == room.client.userID
|
||||||
? i18n.you
|
? i18n.you
|
||||||
: (sender.calcDisplayname());
|
: (sender.calcDisplayname());
|
||||||
localizedBody = '$senderNameOrYou: $localizedBody';
|
localizedBody = '$senderNameOrYou: $localizedBody';
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class User extends Event {
|
||||||
String? membership,
|
String? membership,
|
||||||
String? displayName,
|
String? displayName,
|
||||||
String? avatarUrl,
|
String? avatarUrl,
|
||||||
Room? room,
|
required Room room,
|
||||||
}) {
|
}) {
|
||||||
return User.fromState(
|
return User.fromState(
|
||||||
stateKey: id,
|
stateKey: id,
|
||||||
|
|
@ -38,34 +38,34 @@ class User extends Event {
|
||||||
if (avatarUrl != null) 'avatar_url': avatarUrl,
|
if (avatarUrl != null) 'avatar_url': avatarUrl,
|
||||||
},
|
},
|
||||||
typeKey: EventTypes.RoomMember,
|
typeKey: EventTypes.RoomMember,
|
||||||
roomId: room?.id,
|
roomId: room.id,
|
||||||
room: room,
|
room: room,
|
||||||
originServerTs: DateTime.now(),
|
originServerTs: DateTime.now(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
User.fromState(
|
User.fromState({
|
||||||
{dynamic prevContent,
|
dynamic prevContent,
|
||||||
required String stateKey,
|
required String stateKey,
|
||||||
dynamic content,
|
dynamic content,
|
||||||
required String typeKey,
|
required String typeKey,
|
||||||
String eventId = 'fakevent',
|
String eventId = 'fakevent',
|
||||||
String? roomId,
|
String? roomId,
|
||||||
String senderId = 'fakesender',
|
String senderId = 'fakesender',
|
||||||
required DateTime originServerTs,
|
required DateTime originServerTs,
|
||||||
dynamic unsigned,
|
dynamic unsigned,
|
||||||
Room? room})
|
required Room room,
|
||||||
: super(
|
}) : super(
|
||||||
stateKey: stateKey,
|
stateKey: stateKey,
|
||||||
prevContent: prevContent,
|
prevContent: prevContent,
|
||||||
content: content,
|
content: content,
|
||||||
type: typeKey,
|
type: typeKey,
|
||||||
eventId: eventId,
|
eventId: eventId,
|
||||||
roomId: roomId,
|
senderId: senderId,
|
||||||
senderId: senderId,
|
originServerTs: originServerTs,
|
||||||
originServerTs: originServerTs,
|
unsigned: unsigned,
|
||||||
unsigned: unsigned,
|
room: room,
|
||||||
room: room);
|
);
|
||||||
|
|
||||||
/// The full qualified Matrix ID in the format @username:server.abc.
|
/// The full qualified Matrix ID in the format @username:server.abc.
|
||||||
String get id => stateKey ?? '@unknown:unknown';
|
String get id => stateKey ?? '@unknown:unknown';
|
||||||
|
|
@ -76,7 +76,7 @@ class User extends Event {
|
||||||
prevContent?.tryGet<String>('displayname');
|
prevContent?.tryGet<String>('displayname');
|
||||||
|
|
||||||
/// Returns the power level of this user.
|
/// Returns the power level of this user.
|
||||||
int get powerLevel => room?.getPowerLevelByUserId(id) ?? 0;
|
int get powerLevel => room.getPowerLevelByUserId(id);
|
||||||
|
|
||||||
/// The membership status of the user. One of:
|
/// The membership status of the user. One of:
|
||||||
/// join
|
/// join
|
||||||
|
|
@ -112,8 +112,8 @@ class User extends Event {
|
||||||
bool? formatLocalpart,
|
bool? formatLocalpart,
|
||||||
bool? mxidLocalPartFallback,
|
bool? mxidLocalPartFallback,
|
||||||
}) {
|
}) {
|
||||||
formatLocalpart ??= room?.client.formatLocalpart ?? true;
|
formatLocalpart ??= room.client.formatLocalpart;
|
||||||
mxidLocalPartFallback ??= room?.client.mxidLocalPartFallback ?? true;
|
mxidLocalPartFallback ??= room.client.mxidLocalPartFallback;
|
||||||
final displayName = this.displayName;
|
final displayName = this.displayName;
|
||||||
if (displayName != null && displayName.isNotEmpty) {
|
if (displayName != null && displayName.isNotEmpty) {
|
||||||
return displayName;
|
return displayName;
|
||||||
|
|
@ -135,40 +135,37 @@ class User extends Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Call the Matrix API to kick this user from this room.
|
/// Call the Matrix API to kick this user from this room.
|
||||||
Future<void> kick() async => await room?.kick(id);
|
Future<void> kick() async => await room.kick(id);
|
||||||
|
|
||||||
/// Call the Matrix API to ban this user from this room.
|
/// Call the Matrix API to ban this user from this room.
|
||||||
Future<void> ban() async => await room?.ban(id);
|
Future<void> ban() async => await room.ban(id);
|
||||||
|
|
||||||
/// Call the Matrix API to unban this banned user from this room.
|
/// Call the Matrix API to unban this banned user from this room.
|
||||||
Future<void> unban() async => await room?.unban(id);
|
Future<void> unban() async => await room.unban(id);
|
||||||
|
|
||||||
/// Call the Matrix API to change the power level of this user.
|
/// Call the Matrix API to change the power level of this user.
|
||||||
Future<void> setPower(int power) async => await room?.setPower(id, power);
|
Future<void> setPower(int power) async => await room.setPower(id, power);
|
||||||
|
|
||||||
/// Returns an existing direct chat ID with this user or creates a new one.
|
/// Returns an existing direct chat ID with this user or creates a new one.
|
||||||
/// Returns null on error.
|
/// Returns null on error.
|
||||||
Future<String?> startDirectChat() async => room?.client.startDirectChat(id);
|
Future<String> startDirectChat() async => room.client.startDirectChat(id);
|
||||||
|
|
||||||
/// The newest presence of this user if there is any and null if not.
|
/// The newest presence of this user if there is any and null if not.
|
||||||
Presence? get presence => room?.client.presences[id];
|
Presence? get presence => room.client.presences[id];
|
||||||
|
|
||||||
/// Whether the client is able to ban/unban this user.
|
/// Whether the client is able to ban/unban this user.
|
||||||
bool get canBan =>
|
bool get canBan => room.canBan && powerLevel < room.ownPowerLevel;
|
||||||
(room?.canBan ?? false) &&
|
|
||||||
powerLevel < (room?.ownPowerLevel ?? powerLevel);
|
|
||||||
|
|
||||||
/// Whether the client is able to kick this user.
|
/// Whether the client is able to kick this user.
|
||||||
bool get canKick =>
|
bool get canKick =>
|
||||||
[Membership.join, Membership.invite].contains(membership) &&
|
[Membership.join, Membership.invite].contains(membership) &&
|
||||||
(room?.canKick ?? false) &&
|
room.canKick &&
|
||||||
powerLevel < (room?.ownPowerLevel ?? powerLevel);
|
powerLevel < room.ownPowerLevel;
|
||||||
|
|
||||||
/// Whether the client is allowed to change the power level of this user.
|
/// Whether the client is allowed to change the power level of this user.
|
||||||
/// Please be aware that you can only set the power level to at least your own!
|
/// Please be aware that you can only set the power level to at least your own!
|
||||||
bool get canChangePowerLevel =>
|
bool get canChangePowerLevel =>
|
||||||
(room?.canChangePowerLevel ?? false) &&
|
room.canChangePowerLevel && powerLevel < room.ownPowerLevel;
|
||||||
powerLevel < (room?.ownPowerLevel ?? powerLevel);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(dynamic other) => (other is User &&
|
bool operator ==(dynamic other) => (other is User &&
|
||||||
|
|
@ -196,7 +193,7 @@ class User extends Event {
|
||||||
: '[$displayName]');
|
: '[$displayName]');
|
||||||
|
|
||||||
// get all the users with the same display name
|
// get all the users with the same display name
|
||||||
final allUsersWithSameDisplayname = room?.getParticipants() ?? [];
|
final allUsersWithSameDisplayname = room.getParticipants();
|
||||||
allUsersWithSameDisplayname.removeWhere((user) =>
|
allUsersWithSameDisplayname.removeWhere((user) =>
|
||||||
user.id == id ||
|
user.id == id ||
|
||||||
(user.displayName?.isEmpty ?? true) ||
|
(user.displayName?.isEmpty ?? true) ||
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,7 @@ abstract class EventLocalizations {
|
||||||
EventTypes.Encryption: (event, i18n, body) {
|
EventTypes.Encryption: (event, i18n, body) {
|
||||||
var localizedBody =
|
var localizedBody =
|
||||||
i18n.activatedEndToEndEncryption(event.sender.calcDisplayname());
|
i18n.activatedEndToEndEncryption(event.sender.calcDisplayname());
|
||||||
if (event.room?.client.encryptionEnabled == false) {
|
if (event.room.client.encryptionEnabled == false) {
|
||||||
localizedBody += '. ' + i18n.needPantalaimonWarning;
|
localizedBody += '. ' + i18n.needPantalaimonWarning;
|
||||||
}
|
}
|
||||||
return localizedBody;
|
return localizedBody;
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,7 @@ void main() {
|
||||||
},
|
},
|
||||||
originServerTs: DateTime.now(),
|
originServerTs: DateTime.now(),
|
||||||
senderId: client.userID!,
|
senderId: client.userID!,
|
||||||
|
room: room,
|
||||||
));
|
));
|
||||||
final sent = getLastMessagePayload('m.reaction');
|
final sent = getLastMessagePayload('m.reaction');
|
||||||
expect(sent, {
|
expect(sent, {
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,6 @@ void main() {
|
||||||
final encryptedEvent = Event(
|
final encryptedEvent = Event(
|
||||||
type: EventTypes.Encrypted,
|
type: EventTypes.Encrypted,
|
||||||
content: payload,
|
content: payload,
|
||||||
roomId: roomId,
|
|
||||||
room: room,
|
room: room,
|
||||||
originServerTs: now,
|
originServerTs: now,
|
||||||
eventId: '\$event',
|
eventId: '\$event',
|
||||||
|
|
@ -86,7 +85,6 @@ void main() {
|
||||||
final encryptedEvent = Event(
|
final encryptedEvent = Event(
|
||||||
type: EventTypes.Encrypted,
|
type: EventTypes.Encrypted,
|
||||||
content: payload,
|
content: payload,
|
||||||
roomId: roomId,
|
|
||||||
room: room,
|
room: room,
|
||||||
originServerTs: now,
|
originServerTs: now,
|
||||||
eventId: '\$event',
|
eventId: '\$event',
|
||||||
|
|
|
||||||
|
|
@ -368,7 +368,6 @@ void main() {
|
||||||
Event(
|
Event(
|
||||||
senderId: '@test:example.com',
|
senderId: '@test:example.com',
|
||||||
type: 'm.room.encrypted',
|
type: 'm.room.encrypted',
|
||||||
roomId: room.id,
|
|
||||||
room: room,
|
room: room,
|
||||||
eventId: '12345',
|
eventId: '12345',
|
||||||
originServerTs: DateTime.now(),
|
originServerTs: DateTime.now(),
|
||||||
|
|
|
||||||
|
|
@ -52,13 +52,14 @@ void main() {
|
||||||
'sender': senderID,
|
'sender': senderID,
|
||||||
'origin_server_ts': timestamp,
|
'origin_server_ts': timestamp,
|
||||||
'type': type,
|
'type': type,
|
||||||
'room_id': '1234',
|
'room_id': '!testroom:example.abc',
|
||||||
'status': EventStatus.synced.intValue,
|
'status': EventStatus.synced.intValue,
|
||||||
'content': contentJson,
|
'content': contentJson,
|
||||||
};
|
};
|
||||||
final client = Client('testclient', httpClient: FakeMatrixApi());
|
final client = Client('testclient', httpClient: FakeMatrixApi());
|
||||||
|
final room = Room(id: '!testroom:example.abc', client: client);
|
||||||
final event = Event.fromJson(
|
final event = Event.fromJson(
|
||||||
jsonObj, Room(id: '!localpart:server.abc', client: client));
|
jsonObj, Room(id: '!testroom:example.abc', client: client));
|
||||||
|
|
||||||
test('setup', () async {
|
test('setup', () async {
|
||||||
try {
|
try {
|
||||||
|
|
@ -86,7 +87,7 @@ void main() {
|
||||||
expect(event.type, EventTypes.Message);
|
expect(event.type, EventTypes.Message);
|
||||||
expect(event.relationshipType, RelationshipTypes.reply);
|
expect(event.relationshipType, RelationshipTypes.reply);
|
||||||
jsonObj['state_key'] = '';
|
jsonObj['state_key'] = '';
|
||||||
final state = Event.fromJson(jsonObj, null);
|
final state = Event.fromJson(jsonObj, room);
|
||||||
expect(state.eventId, id);
|
expect(state.eventId, id);
|
||||||
expect(state.stateKey, '');
|
expect(state.stateKey, '');
|
||||||
expect(state.status, EventStatus.synced);
|
expect(state.status, EventStatus.synced);
|
||||||
|
|
@ -95,47 +96,47 @@ void main() {
|
||||||
Event event;
|
Event event;
|
||||||
|
|
||||||
jsonObj['type'] = 'm.room.avatar';
|
jsonObj['type'] = 'm.room.avatar';
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.type, EventTypes.RoomAvatar);
|
expect(event.type, EventTypes.RoomAvatar);
|
||||||
|
|
||||||
jsonObj['type'] = 'm.room.name';
|
jsonObj['type'] = 'm.room.name';
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.type, EventTypes.RoomName);
|
expect(event.type, EventTypes.RoomName);
|
||||||
|
|
||||||
jsonObj['type'] = 'm.room.topic';
|
jsonObj['type'] = 'm.room.topic';
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.type, EventTypes.RoomTopic);
|
expect(event.type, EventTypes.RoomTopic);
|
||||||
|
|
||||||
jsonObj['type'] = 'm.room.aliases';
|
jsonObj['type'] = 'm.room.aliases';
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.type, EventTypes.RoomAliases);
|
expect(event.type, EventTypes.RoomAliases);
|
||||||
|
|
||||||
jsonObj['type'] = 'm.room.canonical_alias';
|
jsonObj['type'] = 'm.room.canonical_alias';
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.type, EventTypes.RoomCanonicalAlias);
|
expect(event.type, EventTypes.RoomCanonicalAlias);
|
||||||
|
|
||||||
jsonObj['type'] = 'm.room.create';
|
jsonObj['type'] = 'm.room.create';
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.type, EventTypes.RoomCreate);
|
expect(event.type, EventTypes.RoomCreate);
|
||||||
|
|
||||||
jsonObj['type'] = 'm.room.join_rules';
|
jsonObj['type'] = 'm.room.join_rules';
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.type, EventTypes.RoomJoinRules);
|
expect(event.type, EventTypes.RoomJoinRules);
|
||||||
|
|
||||||
jsonObj['type'] = 'm.room.member';
|
jsonObj['type'] = 'm.room.member';
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.type, EventTypes.RoomMember);
|
expect(event.type, EventTypes.RoomMember);
|
||||||
|
|
||||||
jsonObj['type'] = 'm.room.power_levels';
|
jsonObj['type'] = 'm.room.power_levels';
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.type, EventTypes.RoomPowerLevels);
|
expect(event.type, EventTypes.RoomPowerLevels);
|
||||||
|
|
||||||
jsonObj['type'] = 'm.room.guest_access';
|
jsonObj['type'] = 'm.room.guest_access';
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.type, EventTypes.GuestAccess);
|
expect(event.type, EventTypes.GuestAccess);
|
||||||
|
|
||||||
jsonObj['type'] = 'm.room.history_visibility';
|
jsonObj['type'] = 'm.room.history_visibility';
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.type, EventTypes.HistoryVisibility);
|
expect(event.type, EventTypes.HistoryVisibility);
|
||||||
|
|
||||||
jsonObj['type'] = 'm.room.message';
|
jsonObj['type'] = 'm.room.message';
|
||||||
|
|
@ -143,36 +144,36 @@ void main() {
|
||||||
|
|
||||||
jsonObj['content'].remove('m.relates_to');
|
jsonObj['content'].remove('m.relates_to');
|
||||||
jsonObj['content']['msgtype'] = 'm.notice';
|
jsonObj['content']['msgtype'] = 'm.notice';
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.messageType, MessageTypes.Notice);
|
expect(event.messageType, MessageTypes.Notice);
|
||||||
|
|
||||||
jsonObj['content']['msgtype'] = 'm.emote';
|
jsonObj['content']['msgtype'] = 'm.emote';
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.messageType, MessageTypes.Emote);
|
expect(event.messageType, MessageTypes.Emote);
|
||||||
|
|
||||||
jsonObj['content']['msgtype'] = 'm.image';
|
jsonObj['content']['msgtype'] = 'm.image';
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.messageType, MessageTypes.Image);
|
expect(event.messageType, MessageTypes.Image);
|
||||||
|
|
||||||
jsonObj['content']['msgtype'] = 'm.video';
|
jsonObj['content']['msgtype'] = 'm.video';
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.messageType, MessageTypes.Video);
|
expect(event.messageType, MessageTypes.Video);
|
||||||
|
|
||||||
jsonObj['content']['msgtype'] = 'm.audio';
|
jsonObj['content']['msgtype'] = 'm.audio';
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.messageType, MessageTypes.Audio);
|
expect(event.messageType, MessageTypes.Audio);
|
||||||
|
|
||||||
jsonObj['content']['msgtype'] = 'm.file';
|
jsonObj['content']['msgtype'] = 'm.file';
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.messageType, MessageTypes.File);
|
expect(event.messageType, MessageTypes.File);
|
||||||
|
|
||||||
jsonObj['content']['msgtype'] = 'm.location';
|
jsonObj['content']['msgtype'] = 'm.location';
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.messageType, MessageTypes.Location);
|
expect(event.messageType, MessageTypes.Location);
|
||||||
|
|
||||||
jsonObj['type'] = 'm.sticker';
|
jsonObj['type'] = 'm.sticker';
|
||||||
jsonObj['content']['msgtype'] = null;
|
jsonObj['content']['msgtype'] = null;
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.messageType, MessageTypes.Sticker);
|
expect(event.messageType, MessageTypes.Sticker);
|
||||||
|
|
||||||
jsonObj['type'] = 'm.room.message';
|
jsonObj['type'] = 'm.room.message';
|
||||||
|
|
@ -181,7 +182,7 @@ void main() {
|
||||||
jsonObj['content']['m.relates_to']['m.in_reply_to'] = {
|
jsonObj['content']['m.relates_to']['m.in_reply_to'] = {
|
||||||
'event_id': '1234',
|
'event_id': '1234',
|
||||||
};
|
};
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.messageType, MessageTypes.Text);
|
expect(event.messageType, MessageTypes.Text);
|
||||||
expect(event.relationshipType, RelationshipTypes.reply);
|
expect(event.relationshipType, RelationshipTypes.reply);
|
||||||
expect(event.relationshipEventId, '1234');
|
expect(event.relationshipEventId, '1234');
|
||||||
|
|
@ -194,7 +195,7 @@ void main() {
|
||||||
'msgtype': 'm.text',
|
'msgtype': 'm.text',
|
||||||
'text': 'beep',
|
'text': 'beep',
|
||||||
};
|
};
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.relationshipType, null);
|
expect(event.relationshipType, null);
|
||||||
expect(event.relationshipEventId, null);
|
expect(event.relationshipEventId, null);
|
||||||
|
|
||||||
|
|
@ -202,12 +203,12 @@ void main() {
|
||||||
'rel_type': 'm.replace',
|
'rel_type': 'm.replace',
|
||||||
'event_id': 'abc',
|
'event_id': 'abc',
|
||||||
};
|
};
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.relationshipType, RelationshipTypes.edit);
|
expect(event.relationshipType, RelationshipTypes.edit);
|
||||||
expect(event.relationshipEventId, 'abc');
|
expect(event.relationshipEventId, 'abc');
|
||||||
|
|
||||||
jsonObj['content']['m.relates_to']['rel_type'] = 'm.annotation';
|
jsonObj['content']['m.relates_to']['rel_type'] = 'm.annotation';
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.relationshipType, RelationshipTypes.reaction);
|
expect(event.relationshipType, RelationshipTypes.reaction);
|
||||||
expect(event.relationshipEventId, 'abc');
|
expect(event.relationshipEventId, 'abc');
|
||||||
|
|
||||||
|
|
@ -216,7 +217,7 @@ void main() {
|
||||||
'event_id': 'def',
|
'event_id': 'def',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
event = Event.fromJson(jsonObj, null);
|
event = Event.fromJson(jsonObj, room);
|
||||||
expect(event.relationshipType, RelationshipTypes.reply);
|
expect(event.relationshipType, RelationshipTypes.reply);
|
||||||
expect(event.relationshipEventId, 'def');
|
expect(event.relationshipEventId, 'def');
|
||||||
});
|
});
|
||||||
|
|
@ -1000,6 +1001,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('aggregations', () {
|
test('aggregations', () {
|
||||||
|
final room = Room(id: '!1234', client: client);
|
||||||
final event = Event.fromJson({
|
final event = Event.fromJson({
|
||||||
'content': {
|
'content': {
|
||||||
'body': 'blah',
|
'body': 'blah',
|
||||||
|
|
@ -1008,7 +1010,7 @@ void main() {
|
||||||
'type': 'm.room.message',
|
'type': 'm.room.message',
|
||||||
'sender': '@example:example.org',
|
'sender': '@example:example.org',
|
||||||
'event_id': '\$source',
|
'event_id': '\$source',
|
||||||
}, null);
|
}, room);
|
||||||
final edit1 = Event.fromJson({
|
final edit1 = Event.fromJson({
|
||||||
'content': {
|
'content': {
|
||||||
'body': 'blah',
|
'body': 'blah',
|
||||||
|
|
@ -1021,7 +1023,7 @@ void main() {
|
||||||
'type': 'm.room.message',
|
'type': 'm.room.message',
|
||||||
'sender': '@example:example.org',
|
'sender': '@example:example.org',
|
||||||
'event_id': '\$edit1',
|
'event_id': '\$edit1',
|
||||||
}, null);
|
}, room);
|
||||||
final edit2 = Event.fromJson({
|
final edit2 = Event.fromJson({
|
||||||
'content': {
|
'content': {
|
||||||
'body': 'blah',
|
'body': 'blah',
|
||||||
|
|
@ -1034,8 +1036,7 @@ void main() {
|
||||||
'type': 'm.room.message',
|
'type': 'm.room.message',
|
||||||
'sender': '@example:example.org',
|
'sender': '@example:example.org',
|
||||||
'event_id': '\$edit2',
|
'event_id': '\$edit2',
|
||||||
}, null);
|
}, room);
|
||||||
final room = Room(client: client, id: '!id:fakeserver.nonexisting');
|
|
||||||
final timeline =
|
final timeline =
|
||||||
Timeline(events: <Event>[event, edit1, edit2], room: room);
|
Timeline(events: <Event>[event, edit1, edit2], room: room);
|
||||||
expect(event.hasAggregatedEvents(timeline, RelationshipTypes.edit), true);
|
expect(event.hasAggregatedEvents(timeline, RelationshipTypes.edit), true);
|
||||||
|
|
@ -1067,10 +1068,11 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$source',
|
'event_id': '\$source',
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, room);
|
||||||
expect(event.plaintextBody, '**blah**');
|
expect(event.plaintextBody, '**blah**');
|
||||||
});
|
});
|
||||||
test('getDisplayEvent', () {
|
test('getDisplayEvent', () {
|
||||||
|
final room = Room(id: '!1234', client: client);
|
||||||
var event = Event.fromJson({
|
var event = Event.fromJson({
|
||||||
'type': EventTypes.Message,
|
'type': EventTypes.Message,
|
||||||
'content': {
|
'content': {
|
||||||
|
|
@ -1079,7 +1081,7 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$source',
|
'event_id': '\$source',
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, room);
|
||||||
final edit1 = Event.fromJson({
|
final edit1 = Event.fromJson({
|
||||||
'type': EventTypes.Message,
|
'type': EventTypes.Message,
|
||||||
'content': {
|
'content': {
|
||||||
|
|
@ -1096,7 +1098,7 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$edit1',
|
'event_id': '\$edit1',
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, room);
|
||||||
final edit2 = Event.fromJson({
|
final edit2 = Event.fromJson({
|
||||||
'type': EventTypes.Message,
|
'type': EventTypes.Message,
|
||||||
'content': {
|
'content': {
|
||||||
|
|
@ -1113,7 +1115,7 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$edit2',
|
'event_id': '\$edit2',
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, room);
|
||||||
final edit3 = Event.fromJson({
|
final edit3 = Event.fromJson({
|
||||||
'type': EventTypes.Message,
|
'type': EventTypes.Message,
|
||||||
'content': {
|
'content': {
|
||||||
|
|
@ -1130,8 +1132,7 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$edit3',
|
'event_id': '\$edit3',
|
||||||
'sender': '@bob:example.org',
|
'sender': '@bob:example.org',
|
||||||
}, null);
|
}, room);
|
||||||
final room = Room(id: '!localpart:server.abc', client: client);
|
|
||||||
// no edits
|
// no edits
|
||||||
var displayEvent =
|
var displayEvent =
|
||||||
event.getDisplayEvent(Timeline(events: <Event>[event], room: room));
|
event.getDisplayEvent(Timeline(events: <Event>[event], room: room));
|
||||||
|
|
@ -1167,7 +1168,7 @@ void main() {
|
||||||
'type': 'm.room.redaction',
|
'type': 'm.room.redaction',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, null);
|
}, room);
|
||||||
displayEvent = event.getDisplayEvent(
|
displayEvent = event.getDisplayEvent(
|
||||||
Timeline(events: <Event>[event, edit1, edit2, edit3], room: room));
|
Timeline(events: <Event>[event, edit1, edit2, edit3], room: room));
|
||||||
expect(displayEvent.body, 'Redacted');
|
expect(displayEvent.body, 'Redacted');
|
||||||
|
|
@ -1388,14 +1389,14 @@ void main() {
|
||||||
var buffer = await event.downloadAndDecryptAttachment(
|
var buffer = await event.downloadAndDecryptAttachment(
|
||||||
downloadCallback: downloadCallback);
|
downloadCallback: downloadCallback);
|
||||||
expect(await event.isAttachmentInLocalStore(),
|
expect(await event.isAttachmentInLocalStore(),
|
||||||
event.room?.client.database?.supportsFileStoring);
|
event.room.client.database?.supportsFileStoring);
|
||||||
expect(buffer.bytes, FILE_BUFF);
|
expect(buffer.bytes, FILE_BUFF);
|
||||||
expect(serverHits, 1);
|
expect(serverHits, 1);
|
||||||
buffer = await event.downloadAndDecryptAttachment(
|
buffer = await event.downloadAndDecryptAttachment(
|
||||||
downloadCallback: downloadCallback);
|
downloadCallback: downloadCallback);
|
||||||
expect(buffer.bytes, FILE_BUFF);
|
expect(buffer.bytes, FILE_BUFF);
|
||||||
expect(
|
expect(
|
||||||
serverHits, event.room!.client.database!.supportsFileStoring ? 1 : 2);
|
serverHits, event.room.client.database!.supportsFileStoring ? 1 : 2);
|
||||||
|
|
||||||
await room.client.dispose(closeDatabase: true);
|
await room.client.dispose(closeDatabase: true);
|
||||||
});
|
});
|
||||||
|
|
@ -1408,7 +1409,7 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$edit2',
|
'event_id': '\$edit2',
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, room);
|
||||||
expect(event.onlyEmotes, false);
|
expect(event.onlyEmotes, false);
|
||||||
expect(event.numberEmotes, 0);
|
expect(event.numberEmotes, 0);
|
||||||
event = Event.fromJson({
|
event = Event.fromJson({
|
||||||
|
|
@ -1419,7 +1420,7 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$edit2',
|
'event_id': '\$edit2',
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, room);
|
||||||
expect(event.onlyEmotes, false);
|
expect(event.onlyEmotes, false);
|
||||||
expect(event.numberEmotes, 0);
|
expect(event.numberEmotes, 0);
|
||||||
event = Event.fromJson({
|
event = Event.fromJson({
|
||||||
|
|
@ -1430,7 +1431,7 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$edit2',
|
'event_id': '\$edit2',
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, room);
|
||||||
expect(event.onlyEmotes, false);
|
expect(event.onlyEmotes, false);
|
||||||
expect(event.numberEmotes, 1);
|
expect(event.numberEmotes, 1);
|
||||||
event = Event.fromJson({
|
event = Event.fromJson({
|
||||||
|
|
@ -1441,7 +1442,7 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$edit2',
|
'event_id': '\$edit2',
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, room);
|
||||||
expect(event.onlyEmotes, true);
|
expect(event.onlyEmotes, true);
|
||||||
expect(event.numberEmotes, 1);
|
expect(event.numberEmotes, 1);
|
||||||
event = Event.fromJson({
|
event = Event.fromJson({
|
||||||
|
|
@ -1452,7 +1453,7 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$edit2',
|
'event_id': '\$edit2',
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, room);
|
||||||
expect(event.onlyEmotes, true);
|
expect(event.onlyEmotes, true);
|
||||||
expect(event.numberEmotes, 5);
|
expect(event.numberEmotes, 5);
|
||||||
event = Event.fromJson({
|
event = Event.fromJson({
|
||||||
|
|
@ -1465,7 +1466,7 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$edit2',
|
'event_id': '\$edit2',
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, room);
|
||||||
expect(event.onlyEmotes, false);
|
expect(event.onlyEmotes, false);
|
||||||
expect(event.numberEmotes, 0);
|
expect(event.numberEmotes, 0);
|
||||||
event = Event.fromJson({
|
event = Event.fromJson({
|
||||||
|
|
@ -1478,7 +1479,7 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$edit2',
|
'event_id': '\$edit2',
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, room);
|
||||||
expect(event.onlyEmotes, true);
|
expect(event.onlyEmotes, true);
|
||||||
expect(event.numberEmotes, 1);
|
expect(event.numberEmotes, 1);
|
||||||
event = Event.fromJson({
|
event = Event.fromJson({
|
||||||
|
|
@ -1491,7 +1492,7 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$edit2',
|
'event_id': '\$edit2',
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, room);
|
||||||
expect(event.onlyEmotes, true);
|
expect(event.onlyEmotes, true);
|
||||||
expect(event.numberEmotes, 1);
|
expect(event.numberEmotes, 1);
|
||||||
event = Event.fromJson({
|
event = Event.fromJson({
|
||||||
|
|
@ -1504,7 +1505,7 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$edit2',
|
'event_id': '\$edit2',
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, room);
|
||||||
expect(event.onlyEmotes, true);
|
expect(event.onlyEmotes, true);
|
||||||
expect(event.numberEmotes, 2);
|
expect(event.numberEmotes, 2);
|
||||||
// with variant selector
|
// with variant selector
|
||||||
|
|
@ -1516,7 +1517,7 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$edit2',
|
'event_id': '\$edit2',
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, room);
|
||||||
expect(event.onlyEmotes, true);
|
expect(event.onlyEmotes, true);
|
||||||
expect(event.numberEmotes, 1);
|
expect(event.numberEmotes, 1);
|
||||||
event = Event.fromJson({
|
event = Event.fromJson({
|
||||||
|
|
@ -1532,7 +1533,7 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$edit2',
|
'event_id': '\$edit2',
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, room);
|
||||||
expect(event.onlyEmotes, true);
|
expect(event.onlyEmotes, true);
|
||||||
expect(event.numberEmotes, 3);
|
expect(event.numberEmotes, 3);
|
||||||
event = Event.fromJson({
|
event = Event.fromJson({
|
||||||
|
|
@ -1548,7 +1549,7 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$edit2',
|
'event_id': '\$edit2',
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, room);
|
||||||
expect(event.onlyEmotes, true);
|
expect(event.onlyEmotes, true);
|
||||||
expect(event.numberEmotes, 2);
|
expect(event.numberEmotes, 2);
|
||||||
event = Event.fromJson({
|
event = Event.fromJson({
|
||||||
|
|
@ -1564,7 +1565,7 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$edit2',
|
'event_id': '\$edit2',
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, room);
|
||||||
expect(event.onlyEmotes, false);
|
expect(event.onlyEmotes, false);
|
||||||
expect(event.numberEmotes, 2);
|
expect(event.numberEmotes, 2);
|
||||||
event = Event.fromJson({
|
event = Event.fromJson({
|
||||||
|
|
@ -1580,7 +1581,7 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$edit2',
|
'event_id': '\$edit2',
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, room);
|
||||||
expect(event.onlyEmotes, false);
|
expect(event.onlyEmotes, false);
|
||||||
expect(event.numberEmotes, 2);
|
expect(event.numberEmotes, 2);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,6 @@ void main() {
|
||||||
roomAccountData: {
|
roomAccountData: {
|
||||||
'com.test.foo': BasicRoomEvent(
|
'com.test.foo': BasicRoomEvent(
|
||||||
type: 'com.test.foo',
|
type: 'com.test.foo',
|
||||||
roomId: id,
|
|
||||||
content: {'foo': 'bar'},
|
content: {'foo': 'bar'},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
@ -78,7 +77,6 @@ void main() {
|
||||||
room.setState(Event(
|
room.setState(Event(
|
||||||
room: room,
|
room: room,
|
||||||
eventId: '143273582443PhrSn:example.org',
|
eventId: '143273582443PhrSn:example.org',
|
||||||
roomId: id,
|
|
||||||
originServerTs: DateTime.fromMillisecondsSinceEpoch(1432735824653),
|
originServerTs: DateTime.fromMillisecondsSinceEpoch(1432735824653),
|
||||||
senderId: '@example:example.org',
|
senderId: '@example:example.org',
|
||||||
type: 'm.room.join_rules',
|
type: 'm.room.join_rules',
|
||||||
|
|
@ -103,7 +101,6 @@ void main() {
|
||||||
Event(
|
Event(
|
||||||
senderId: '@test:example.com',
|
senderId: '@test:example.com',
|
||||||
type: 'm.room.canonical_alias',
|
type: 'm.room.canonical_alias',
|
||||||
roomId: room.id,
|
|
||||||
room: room,
|
room: room,
|
||||||
eventId: '123',
|
eventId: '123',
|
||||||
content: {'alias': '#testalias:example.com'},
|
content: {'alias': '#testalias:example.com'},
|
||||||
|
|
@ -117,7 +114,6 @@ void main() {
|
||||||
Event(
|
Event(
|
||||||
senderId: '@test:example.com',
|
senderId: '@test:example.com',
|
||||||
type: 'm.room.name',
|
type: 'm.room.name',
|
||||||
roomId: room.id,
|
|
||||||
room: room,
|
room: room,
|
||||||
eventId: '123',
|
eventId: '123',
|
||||||
content: {'name': 'testname'},
|
content: {'name': 'testname'},
|
||||||
|
|
@ -131,7 +127,6 @@ void main() {
|
||||||
Event(
|
Event(
|
||||||
senderId: '@test:example.com',
|
senderId: '@test:example.com',
|
||||||
type: 'm.room.topic',
|
type: 'm.room.topic',
|
||||||
roomId: room.id,
|
|
||||||
room: room,
|
room: room,
|
||||||
eventId: '123',
|
eventId: '123',
|
||||||
content: {'topic': 'testtopic'},
|
content: {'topic': 'testtopic'},
|
||||||
|
|
@ -145,7 +140,6 @@ void main() {
|
||||||
Event(
|
Event(
|
||||||
senderId: '@test:example.com',
|
senderId: '@test:example.com',
|
||||||
type: 'm.room.avatar',
|
type: 'm.room.avatar',
|
||||||
roomId: room.id,
|
|
||||||
room: room,
|
room: room,
|
||||||
eventId: '123',
|
eventId: '123',
|
||||||
content: {'url': 'mxc://testurl'},
|
content: {'url': 'mxc://testurl'},
|
||||||
|
|
@ -159,7 +153,6 @@ void main() {
|
||||||
Event(
|
Event(
|
||||||
senderId: '@test:example.com',
|
senderId: '@test:example.com',
|
||||||
type: 'm.room.pinned_events',
|
type: 'm.room.pinned_events',
|
||||||
roomId: room.id,
|
|
||||||
room: room,
|
room: room,
|
||||||
eventId: '123',
|
eventId: '123',
|
||||||
content: {
|
content: {
|
||||||
|
|
@ -173,7 +166,6 @@ void main() {
|
||||||
Event(
|
Event(
|
||||||
senderId: '@test:example.com',
|
senderId: '@test:example.com',
|
||||||
type: 'm.room.message',
|
type: 'm.room.message',
|
||||||
roomId: room.id,
|
|
||||||
room: room,
|
room: room,
|
||||||
eventId: '12345',
|
eventId: '12345',
|
||||||
originServerTs: DateTime.now(),
|
originServerTs: DateTime.now(),
|
||||||
|
|
@ -191,7 +183,6 @@ void main() {
|
||||||
Event(
|
Event(
|
||||||
senderId: '@test:example.com',
|
senderId: '@test:example.com',
|
||||||
type: 'm.room.encrypted',
|
type: 'm.room.encrypted',
|
||||||
roomId: room.id,
|
|
||||||
room: room,
|
room: room,
|
||||||
eventId: '1',
|
eventId: '1',
|
||||||
originServerTs: DateTime.now(),
|
originServerTs: DateTime.now(),
|
||||||
|
|
@ -204,7 +195,6 @@ void main() {
|
||||||
Event(
|
Event(
|
||||||
senderId: '@test:example.com',
|
senderId: '@test:example.com',
|
||||||
type: 'm.room.encrypted',
|
type: 'm.room.encrypted',
|
||||||
roomId: room.id,
|
|
||||||
room: room,
|
room: room,
|
||||||
eventId: '2',
|
eventId: '2',
|
||||||
originServerTs: DateTime.now(),
|
originServerTs: DateTime.now(),
|
||||||
|
|
@ -217,7 +207,6 @@ void main() {
|
||||||
Event(
|
Event(
|
||||||
senderId: '@test:example.com',
|
senderId: '@test:example.com',
|
||||||
type: 'm.room.encrypted',
|
type: 'm.room.encrypted',
|
||||||
roomId: room.id,
|
|
||||||
room: room,
|
room: room,
|
||||||
eventId: '3',
|
eventId: '3',
|
||||||
originServerTs: DateTime.now(),
|
originServerTs: DateTime.now(),
|
||||||
|
|
@ -235,7 +224,6 @@ void main() {
|
||||||
Event(
|
Event(
|
||||||
senderId: '@test:example.com',
|
senderId: '@test:example.com',
|
||||||
type: 'm.room.encrypted',
|
type: 'm.room.encrypted',
|
||||||
roomId: room.id,
|
|
||||||
room: room,
|
room: room,
|
||||||
eventId: '4',
|
eventId: '4',
|
||||||
originServerTs: DateTime.now(),
|
originServerTs: DateTime.now(),
|
||||||
|
|
@ -255,7 +243,6 @@ void main() {
|
||||||
Event(
|
Event(
|
||||||
senderId: '@test:example.com',
|
senderId: '@test:example.com',
|
||||||
type: 'm.room.encrypted',
|
type: 'm.room.encrypted',
|
||||||
roomId: room.id,
|
|
||||||
room: room,
|
room: room,
|
||||||
eventId: '5',
|
eventId: '5',
|
||||||
originServerTs: DateTime.now(),
|
originServerTs: DateTime.now(),
|
||||||
|
|
@ -269,7 +256,6 @@ void main() {
|
||||||
Event(
|
Event(
|
||||||
senderId: '@test:example.com',
|
senderId: '@test:example.com',
|
||||||
type: 'm.room.encrypted',
|
type: 'm.room.encrypted',
|
||||||
roomId: room.id,
|
|
||||||
room: room,
|
room: room,
|
||||||
eventId: '6',
|
eventId: '6',
|
||||||
originServerTs: DateTime.now(),
|
originServerTs: DateTime.now(),
|
||||||
|
|
@ -286,7 +272,6 @@ void main() {
|
||||||
Event(
|
Event(
|
||||||
senderId: '@test:example.com',
|
senderId: '@test:example.com',
|
||||||
type: 'm.room.encrypted',
|
type: 'm.room.encrypted',
|
||||||
roomId: room.id,
|
|
||||||
room: room,
|
room: room,
|
||||||
eventId: '7',
|
eventId: '7',
|
||||||
originServerTs: DateTime.now(),
|
originServerTs: DateTime.now(),
|
||||||
|
|
@ -313,7 +298,7 @@ void main() {
|
||||||
expect(user.displayName, 'Alice Margatroid');
|
expect(user.displayName, 'Alice Margatroid');
|
||||||
expect(user.membership, Membership.join);
|
expect(user.membership, Membership.join);
|
||||||
expect(user.avatarUrl.toString(), 'mxc://example.org/SEsfnsuifSDFSSEF');
|
expect(user.avatarUrl.toString(), 'mxc://example.org/SEsfnsuifSDFSSEF');
|
||||||
expect(user.room?.id, '!localpart:server.abc');
|
expect(user.room.id, '!localpart:server.abc');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getEventByID', () async {
|
test('getEventByID', () async {
|
||||||
|
|
@ -348,7 +333,6 @@ void main() {
|
||||||
Event(
|
Event(
|
||||||
senderId: '@test:example.com',
|
senderId: '@test:example.com',
|
||||||
type: 'm.room.power_levels',
|
type: 'm.room.power_levels',
|
||||||
roomId: room.id,
|
|
||||||
room: room,
|
room: room,
|
||||||
eventId: '123',
|
eventId: '123',
|
||||||
content: {
|
content: {
|
||||||
|
|
@ -387,7 +371,6 @@ void main() {
|
||||||
Event(
|
Event(
|
||||||
senderId: '@test:example.com',
|
senderId: '@test:example.com',
|
||||||
type: 'm.room.power_levels',
|
type: 'm.room.power_levels',
|
||||||
roomId: room.id,
|
|
||||||
room: room,
|
room: room,
|
||||||
eventId: '123abc',
|
eventId: '123abc',
|
||||||
content: {
|
content: {
|
||||||
|
|
@ -433,7 +416,6 @@ void main() {
|
||||||
room.setState(Event(
|
room.setState(Event(
|
||||||
senderId: '@alice:test.abc',
|
senderId: '@alice:test.abc',
|
||||||
type: 'm.room.member',
|
type: 'm.room.member',
|
||||||
roomId: room.id,
|
|
||||||
room: room,
|
room: room,
|
||||||
eventId: '12345',
|
eventId: '12345',
|
||||||
originServerTs: DateTime.now(),
|
originServerTs: DateTime.now(),
|
||||||
|
|
@ -720,7 +702,6 @@ void main() {
|
||||||
Event(
|
Event(
|
||||||
senderId: '@alice:test.abc',
|
senderId: '@alice:test.abc',
|
||||||
type: 'm.room.encryption',
|
type: 'm.room.encryption',
|
||||||
roomId: room.id,
|
|
||||||
room: room,
|
room: room,
|
||||||
eventId: '12345',
|
eventId: '12345',
|
||||||
originServerTs: DateTime.now(),
|
originServerTs: DateTime.now(),
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ void main() {
|
||||||
'state_key': id
|
'state_key': id
|
||||||
};
|
};
|
||||||
|
|
||||||
final user = Event.fromJson(jsonObj, null).asUser;
|
final user = Event.fromJson(jsonObj, room).asUser;
|
||||||
|
|
||||||
expect(user.id, id);
|
expect(user.id, id);
|
||||||
expect(user.membership, membership);
|
expect(user.membership, membership);
|
||||||
|
|
@ -95,9 +95,9 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('calcDisplayname', () async {
|
test('calcDisplayname', () async {
|
||||||
final user1 = User('@alice:example.com');
|
final user1 = User('@alice:example.com', room: room);
|
||||||
final user2 = User('@SuperAlice:example.com');
|
final user2 = User('@SuperAlice:example.com', room: room);
|
||||||
final user3 = User('@alice_mep:example.com');
|
final user3 = User('@alice_mep:example.com', room: room);
|
||||||
expect(user1.calcDisplayname(), 'Alice');
|
expect(user1.calcDisplayname(), 'Alice');
|
||||||
expect(user2.calcDisplayname(), 'SuperAlice');
|
expect(user2.calcDisplayname(), 'SuperAlice');
|
||||||
expect(user3.calcDisplayname(), 'Alice Mep');
|
expect(user3.calcDisplayname(), 'Alice Mep');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue