Merge branch 'krille/minor-fixes' into 'main'
Minor fixes See merge request famedly/company/frontend/famedlysdk!872
This commit is contained in:
commit
938d58da96
|
|
@ -17,7 +17,7 @@ analyzer:
|
|||
- lib/src/database/database.g.dart
|
||||
plugins:
|
||||
# Show code metrics in IDE
|
||||
- dart_code_metrics
|
||||
# - dart_code_metrics
|
||||
|
||||
dart_code_metrics:
|
||||
metrics:
|
||||
|
|
|
|||
|
|
@ -523,7 +523,7 @@ class Event extends MatrixEvent {
|
|||
/// event and returns it as a [MatrixFile]. If this event doesn't
|
||||
/// contain an attachment, this throws an error. Set [getThumbnail] to
|
||||
/// true to download the thumbnail instead.
|
||||
Future<MatrixFile?> downloadAndDecryptAttachment(
|
||||
Future<MatrixFile> downloadAndDecryptAttachment(
|
||||
{bool getThumbnail = false,
|
||||
Future<Uint8List> Function(Uri)? downloadCallback}) async {
|
||||
if (![EventTypes.Message, EventTypes.Sticker].contains(type)) {
|
||||
|
|
@ -584,8 +584,11 @@ class Event extends MatrixEvent {
|
|||
);
|
||||
uint8list = await client.runInBackground<Uint8List?, EncryptedFile>(
|
||||
decryptFile, encryptedFile);
|
||||
if (uint8list == null) {
|
||||
throw ('Unable to decrypt file');
|
||||
}
|
||||
}
|
||||
return uint8list != null ? MatrixFile(bytes: uint8list, name: body) : null;
|
||||
return MatrixFile(bytes: uint8list, name: body);
|
||||
}
|
||||
|
||||
/// Returns if this is a known event type.
|
||||
|
|
|
|||
|
|
@ -1196,7 +1196,7 @@ void main() {
|
|||
}, room);
|
||||
var buffer = await event.downloadAndDecryptAttachment(
|
||||
downloadCallback: downloadCallback);
|
||||
expect(buffer?.bytes, FILE_BUFF);
|
||||
expect(buffer.bytes, FILE_BUFF);
|
||||
expect(event.attachmentOrThumbnailMxcUrl().toString(),
|
||||
'mxc://example.org/file');
|
||||
expect(event.attachmentOrThumbnailMxcUrl(getThumbnail: true).toString(),
|
||||
|
|
@ -1251,11 +1251,11 @@ void main() {
|
|||
|
||||
buffer = await event.downloadAndDecryptAttachment(
|
||||
downloadCallback: downloadCallback);
|
||||
expect(buffer?.bytes, FILE_BUFF);
|
||||
expect(buffer.bytes, FILE_BUFF);
|
||||
|
||||
buffer = await event.downloadAndDecryptAttachment(
|
||||
getThumbnail: true, downloadCallback: downloadCallback);
|
||||
expect(buffer?.bytes, THUMBNAIL_BUFF);
|
||||
expect(buffer.bytes, THUMBNAIL_BUFF);
|
||||
});
|
||||
test('encrypted attachments', () async {
|
||||
if (!olmEnabled) return;
|
||||
|
|
@ -1298,7 +1298,7 @@ void main() {
|
|||
}, room);
|
||||
var buffer = await event.downloadAndDecryptAttachment(
|
||||
downloadCallback: downloadCallback);
|
||||
expect(buffer?.bytes, FILE_BUFF_DEC);
|
||||
expect(buffer.bytes, FILE_BUFF_DEC);
|
||||
|
||||
event = Event.fromJson({
|
||||
'type': EventTypes.Message,
|
||||
|
|
@ -1351,11 +1351,11 @@ void main() {
|
|||
expect(event.thumbnailMxcUrl.toString(), 'mxc://example.com/thumb');
|
||||
buffer = await event.downloadAndDecryptAttachment(
|
||||
downloadCallback: downloadCallback);
|
||||
expect(buffer?.bytes, FILE_BUFF_DEC);
|
||||
expect(buffer.bytes, FILE_BUFF_DEC);
|
||||
|
||||
buffer = await event.downloadAndDecryptAttachment(
|
||||
getThumbnail: true, downloadCallback: downloadCallback);
|
||||
expect(buffer?.bytes, THUMB_BUFF_DEC);
|
||||
expect(buffer.bytes, THUMB_BUFF_DEC);
|
||||
|
||||
await room.client.dispose(closeDatabase: true);
|
||||
});
|
||||
|
|
@ -1389,11 +1389,11 @@ void main() {
|
|||
downloadCallback: downloadCallback);
|
||||
expect(await event.isAttachmentInLocalStore(),
|
||||
event.room?.client.database?.supportsFileStoring);
|
||||
expect(buffer?.bytes, FILE_BUFF);
|
||||
expect(buffer.bytes, FILE_BUFF);
|
||||
expect(serverHits, 1);
|
||||
buffer = await event.downloadAndDecryptAttachment(
|
||||
downloadCallback: downloadCallback);
|
||||
expect(buffer?.bytes, FILE_BUFF);
|
||||
expect(buffer.bytes, FILE_BUFF);
|
||||
expect(
|
||||
serverHits, event.room!.client.database!.supportsFileStoring ? 1 : 2);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue