Skip to content

Commit

Permalink
support 'file' attachment for stickers
Browse files Browse the repository at this point in the history
  • Loading branch information
Airyzz committed Jan 11, 2025
1 parent 8c676cf commit 4ce9f97
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 4 additions & 3 deletions commet/lib/client/matrix/matrix_room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,10 @@ class MatrixRoom extends Room {
}

final result = switch (event.type) {
matrix.EventTypes.Sticker => event.content['url'] is String
? MatrixTimelineEventSticker(event, client: c)
: null,
matrix.EventTypes.Sticker =>
event.content['url'] is String || event.content.containsKey('file')
? MatrixTimelineEventSticker(event, client: c)
: null,
matrix.EventTypes.Encrypted =>
MatrixTimelineEventEncrypted(event, client: c),
matrix.EventTypes.Reaction =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ class MatrixTimelineEventSticker extends MatrixTimelineEvent
with MatrixTimelineEventRelated, MatrixTimelineEventReactions
implements TimelineEventSticker {
MatrixTimelineEventSticker(super.event, {required super.client}) {
stickerImage = MatrixMxcImage(
Uri.parse(event.content["url"] as String), client.getMatrixClient());
String? uri;
if (event.content.containsKey('url')) {
uri = event.content['url'] as String;
} else if (event.content.containsKey('file')) {
var file = event.content['file'] as Map<String, dynamic>;
uri = file['url'];
}
stickerImage = MatrixMxcImage(Uri.parse(uri!), client.getMatrixClient(),
matrixEvent: event);

stickerName = event.body;
}
Expand Down

0 comments on commit 4ce9f97

Please sign in to comment.