fluffychat/lib/utils/room_send_file_extension.dart
2021-12-03 17:29:32 +01:00

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,
);
}
}