TF-2331 Fix Read receipt includes weird attachments that are impossible to download
(cherry picked from commit 72ae6553ea53fa4bbba74bfdb1c9a3ec82103fc0)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
|
||||
class CacheVersion {
|
||||
static const int hiveDBVersion = 8;
|
||||
static const int hiveDBVersion = 9;
|
||||
}
|
||||
@@ -559,7 +559,7 @@ class ComposerController extends BaseController {
|
||||
void _initAttachments(List<Attachment> attachments) {
|
||||
if (attachments.isNotEmpty) {
|
||||
initialAttachments = attachments;
|
||||
uploadController.initializeUploadAttachments(attachments.listAttachmentsDisplayedOutSide);
|
||||
uploadController.initializeUploadAttachments(attachments);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:model/extensions/email_extension.dart';
|
||||
import 'package:model/extensions/list_attachment_extension.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/model/detailed_email.dart';
|
||||
|
||||
extension EmailExtension on Email {
|
||||
@@ -8,7 +9,7 @@ extension EmailExtension on Email {
|
||||
return DetailedEmail(
|
||||
emailId: id!,
|
||||
createdTime: receivedAt?.value ?? DateTime.now(),
|
||||
attachments: allAttachments,
|
||||
attachments: allAttachments.getListAttachmentsDisplayedOutside(htmlBodyAttachments),
|
||||
headers: headers,
|
||||
keywords: keywords,
|
||||
htmlEmailContent: htmlEmailContent,
|
||||
|
||||
@@ -61,13 +61,13 @@ class GetEmailContentInteractor {
|
||||
|
||||
yield Right<Failure, Success>(GetEmailContentSuccess(
|
||||
htmlEmailContent: newEmailContents.asHtmlString,
|
||||
attachments: email.allAttachments,
|
||||
attachments: email.allAttachments.getListAttachmentsDisplayedOutside(email.htmlBodyAttachments),
|
||||
emailCurrent: email
|
||||
));
|
||||
} else {
|
||||
yield Right<Failure, Success>(GetEmailContentSuccess(
|
||||
htmlEmailContent: '',
|
||||
attachments: email.allAttachments,
|
||||
attachments: email.allAttachments.getListAttachmentsDisplayedOutside(email.htmlBodyAttachments),
|
||||
emailCurrent: email
|
||||
));
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import 'package:get/get.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/calendar/calendar_event.dart';
|
||||
import 'package:model/email/email_action_type.dart';
|
||||
import 'package:model/email/presentation_email.dart';
|
||||
import 'package:model/extensions/list_attachment_extension.dart';
|
||||
import 'package:model/extensions/list_email_address_extension.dart';
|
||||
import 'package:model/extensions/presentation_email_extension.dart';
|
||||
import 'package:model/extensions/presentation_mailbox_extension.dart';
|
||||
@@ -313,11 +312,10 @@ class EmailView extends GetWidget<SingleEmailController> {
|
||||
emailUnsubscribe: controller.emailUnsubscribe.value
|
||||
)),
|
||||
Obx(() {
|
||||
final attachments = controller.attachments.listAttachmentsDisplayedOutSide;
|
||||
if (attachments.isNotEmpty) {
|
||||
if (controller.attachments.isNotEmpty) {
|
||||
return EmailAttachmentsWidget(
|
||||
responsiveUtils: controller.responsiveUtils,
|
||||
attachments: attachments,
|
||||
attachments: controller.attachments,
|
||||
imagePaths: controller.imagePaths,
|
||||
onDragStarted: controller.mailboxDashBoardController.enableDraggableApp,
|
||||
onDragEnd: (details) {
|
||||
@@ -330,7 +328,7 @@ class EmailView extends GetWidget<SingleEmailController> {
|
||||
controller.exportAttachment(context, attachment);
|
||||
}
|
||||
},
|
||||
onTapShowAllAttachmentFile: () => controller.openAttachmentList(context, attachments),
|
||||
onTapShowAllAttachmentFile: () => controller.openAttachmentList(context, controller.attachments),
|
||||
);
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
|
||||
@@ -133,6 +133,8 @@ extension EmailExtension on Email {
|
||||
return emailContents ?? [];
|
||||
}
|
||||
|
||||
List<Attachment> get htmlBodyAttachments => htmlBody?.map((item) => item.toAttachment()).toList() ?? [];
|
||||
|
||||
List<Attachment> get allAttachments => attachments?.map((item) => item.toAttachment()).toList() ?? [];
|
||||
|
||||
List<Attachment> get attachmentsWithCid => allAttachments.where((attachment) => attachment.hasCid()).toList();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:model/email/attachment.dart';
|
||||
|
||||
@@ -13,7 +14,19 @@ extension ListAttachmentExtension on List<Attachment> {
|
||||
return 0;
|
||||
}
|
||||
|
||||
List<Attachment> get listAttachmentsDisplayedOutSide => where((attachment) => attachment.noCid() || !attachment.isInlined()).toList();
|
||||
List<Attachment> getListAttachmentsDisplayedOutside(List<Attachment>? htmlBodyAttachments) {
|
||||
return where((attachment) => _validateOutsideAttachment(attachment, htmlBodyAttachments)).toList();
|
||||
}
|
||||
|
||||
bool _validateOutsideAttachment(Attachment attachment, List<Attachment>? htmlBodyAttachments) {
|
||||
final result = (attachment.noCid() || !attachment.isInlined()) && (htmlBodyAttachments == null || !htmlBodyAttachments._include(attachment));
|
||||
return result;
|
||||
}
|
||||
|
||||
bool _include(Attachment newAttachment) {
|
||||
final matchedAttachment = firstWhereOrNull((attachment) => attachment.blobId == newAttachment.blobId);
|
||||
return matchedAttachment != null;
|
||||
}
|
||||
|
||||
List<Attachment> get listAttachmentsDisplayedInContent => where((attachment) => attachment.hasCid()).toList();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user