fix: Properly detect sicket message types

This commit is contained in:
Sorunome 2020-09-05 13:54:43 +02:00
parent 5863c8e168
commit 54a128d2c5
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C
2 changed files with 8 additions and 1 deletions

View File

@ -229,7 +229,9 @@ class Event extends MatrixEvent {
unsigned: unsigned,
room: room);
String get messageType => content['msgtype'] ?? MessageTypes.Text;
String get messageType => type == EventTypes.Sticker
? MessageTypes.Sticker
: content['msgtype'] ?? MessageTypes.Text;
void setRedactionEvent(Event redactedBecause) {
unsigned = {

View File

@ -167,6 +167,11 @@ void main() {
event = Event.fromJson(jsonObj, null);
expect(event.messageType, MessageTypes.Location);
jsonObj['type'] = 'm.sticker';
jsonObj['content']['msgtype'] = null;
event = Event.fromJson(jsonObj, null);
expect(event.messageType, MessageTypes.Sticker);
jsonObj['type'] = 'm.room.message';
jsonObj['content']['msgtype'] = 'm.text';
jsonObj['content']['m.relates_to'] = {};