TF-106 Fix display inlined image CIDs of emails
This commit is contained in:
@@ -27,6 +27,8 @@ class Attachment with EquatableMixin {
|
||||
this.disposition,
|
||||
});
|
||||
|
||||
bool cidNotEmpty() => cid != null && cid!.isNotEmpty;
|
||||
|
||||
String getDownloadUrl(String baseDownloadUrl, AccountId accountId) {
|
||||
final downloadUriTemplate = UriTemplate('$baseDownloadUrl');
|
||||
final downloadUri = downloadUriTemplate.expand({
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:model/email/email_content_type.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
@@ -11,19 +10,6 @@ class EmailContent with EquatableMixin {
|
||||
|
||||
EmailContent(this.type, this.content);
|
||||
|
||||
bool hasImageInlineWithCid() => content.contains('cid:');
|
||||
|
||||
String getContentHasInlineAttachment(String baseDownloadUrl, AccountId accountId, List<Attachment> attachments) {
|
||||
var contentValid = content;
|
||||
attachments.forEach((attachment) {
|
||||
if(attachment.cid != null) {
|
||||
final urlDownloadImage = attachment.getDownloadUrl(baseDownloadUrl, accountId);
|
||||
contentValid = content.replaceAll('cid:${attachment.cid}', '$urlDownloadImage');
|
||||
}
|
||||
});
|
||||
return contentValid;
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [type, content];
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:model/model.dart';
|
||||
|
||||
extension ListAttachmentExtension on List<Attachment> {
|
||||
|
||||
num totalSize() {
|
||||
num totalSize = 0;
|
||||
forEach((attachment) {
|
||||
if (attachment.size != null) {
|
||||
totalSize += attachment.size!.value;
|
||||
}
|
||||
});
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
List<Attachment> get attachmentsWithDispositionAttachment {
|
||||
return where((attachment) => attachment.disposition == ContentDisposition.attachment).toList();
|
||||
}
|
||||
|
||||
List<Attachment> get attachmentWithDispositionInlines {
|
||||
return where((attachment) => attachment.disposition == ContentDisposition.inline && attachment.cidNotEmpty())
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,7 @@ export 'extensions/list_mailbox_extension.dart';
|
||||
export 'extensions/list_extension.dart';
|
||||
export 'extensions/list_email_extension.dart';
|
||||
export 'extensions/media_type_extension.dart';
|
||||
export 'extensions/list_attachment_extension.dart';
|
||||
|
||||
// Download
|
||||
export 'download/download_task_id.dart';
|
||||
|
||||
Reference in New Issue
Block a user