Detect the file message type

This commit is contained in:
Christian Pauly 2020-08-01 13:04:03 +00:00 committed by Marcel
parent 050222cede
commit 938540eca5
1 changed files with 13 additions and 1 deletions

View File

@ -1,6 +1,7 @@
/// Workaround until [File] in dart:io and dart:html is unified
import 'dart:typed_data';
import 'package:famedlysdk/matrix_api/model/message_types.dart';
import 'package:matrix_file_e2ee/matrix_file_e2ee.dart';
import 'package:mime/mime.dart';
@ -22,7 +23,18 @@ class MatrixFile {
int get size => bytes.length;
String get msgType => 'm.file';
String get msgType {
if (mimeType.toLowerCase().startsWith('image/')) {
return MessageTypes.Image;
}
if (mimeType.toLowerCase().startsWith('video/')) {
return MessageTypes.Video;
}
if (mimeType.toLowerCase().startsWith('audio/')) {
return MessageTypes.Audio;
}
return MessageTypes.File;
}
Map<String, dynamic> get info => ({
'mimetype': mimeType,