mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-24 04:59:26 +01:00
34 lines
691 B
Dart
34 lines
691 B
Dart
//@dart=2.12
|
|
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
import 'resize_image.dart';
|
|
|
|
extension RoomSendFileExtension on Room {
|
|
Future<Uri> sendFileEventWithThumbnail(
|
|
MatrixFile file, {
|
|
String? txid,
|
|
Event? inReplyTo,
|
|
String? editEventId,
|
|
bool? waitUntilSent,
|
|
}) async {
|
|
MatrixImageFile? thumbnail;
|
|
if (file is MatrixImageFile) {
|
|
thumbnail = await file.resizeImage();
|
|
|
|
if (thumbnail.size > file.size ~/ 2) {
|
|
thumbnail = null;
|
|
}
|
|
}
|
|
|
|
return sendFileEvent(
|
|
file,
|
|
txid: txid,
|
|
inReplyTo: inReplyTo,
|
|
editEventId: editEventId,
|
|
waitUntilSent: waitUntilSent ?? false,
|
|
thumbnail: thumbnail,
|
|
);
|
|
}
|
|
}
|