TF-3517 Fix "Reply to *me*" field is added when save an email as draft
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -46,7 +46,10 @@ class ComposerRepositoryImpl extends ComposerRepository {
|
||||
@override
|
||||
Future<Email> generateEmail(
|
||||
CreateEmailRequest createEmailRequest,
|
||||
{bool withIdentityHeader = false}
|
||||
{
|
||||
bool withIdentityHeader = false,
|
||||
bool isDraft = false,
|
||||
}
|
||||
) async {
|
||||
String emailContent = createEmailRequest.emailContent;
|
||||
Set<EmailBodyPart> emailAttachments = Set.from(createEmailRequest.createAttachments());
|
||||
@@ -72,6 +75,7 @@ class ComposerRepositoryImpl extends ComposerRepository {
|
||||
userAgent: userAgent,
|
||||
partId: emailBodyPartId,
|
||||
withIdentityHeader: withIdentityHeader,
|
||||
isDraft: isDraft,
|
||||
);
|
||||
|
||||
return emailObject;
|
||||
|
||||
@@ -7,7 +7,10 @@ import 'package:tmail_ui_user/features/upload/domain/model/upload_attachment.dar
|
||||
abstract class ComposerRepository {
|
||||
Future<Email> generateEmail(
|
||||
CreateEmailRequest createEmailRequest,
|
||||
{bool withIdentityHeader = false});
|
||||
{
|
||||
bool withIdentityHeader = false,
|
||||
bool isDraft = false,
|
||||
});
|
||||
|
||||
Future<UploadAttachment> uploadAttachment(FileInfo fileInfo, Uri uploadUri, {CancelToken? cancelToken});
|
||||
|
||||
|
||||
+3
-1
@@ -89,7 +89,9 @@ class CreateNewAndSaveEmailToDraftsInteractor {
|
||||
try {
|
||||
final emailCreated = await _composerRepository.generateEmail(
|
||||
createEmailRequest,
|
||||
withIdentityHeader: true);
|
||||
withIdentityHeader: true,
|
||||
isDraft: true,
|
||||
);
|
||||
return emailCreated;
|
||||
} catch (e) {
|
||||
logError('CreateNewAndSaveEmailToDraftsInteractor::_createEmailObject: Exception: $e');
|
||||
|
||||
@@ -26,7 +26,9 @@ class SaveComposerCacheOnWebInteractor {
|
||||
try {
|
||||
final emailCreated = await _composerRepository.generateEmail(
|
||||
createEmailRequest,
|
||||
withIdentityHeader: true);
|
||||
withIdentityHeader: true,
|
||||
isDraft: true,
|
||||
);
|
||||
await _composerCacheRepository.saveComposerCacheOnWeb(
|
||||
accountId: accountId,
|
||||
userName: userName,
|
||||
|
||||
@@ -22,7 +22,7 @@ import 'package:tmail_ui_user/main/localizations/localization_service.dart';
|
||||
|
||||
extension CreateEmailRequestExtension on CreateEmailRequest {
|
||||
|
||||
Set<EmailAddress> createSenders() {
|
||||
Set<EmailAddress>? createSenders() {
|
||||
if (identity?.email?.isNotEmpty == true) {
|
||||
return { identity!.toEmailAddress() };
|
||||
} else {
|
||||
@@ -31,23 +31,26 @@ extension CreateEmailRequestExtension on CreateEmailRequest {
|
||||
}
|
||||
|
||||
String createMdnEmailAddress() {
|
||||
if (emailActionType == EmailActionType.editDraft && fromSender.isNotEmpty) {
|
||||
return fromSender.first.emailAddress;
|
||||
if (emailActionType == EmailActionType.editDraft && fromSender?.isNotEmpty == true) {
|
||||
return fromSender!.first.emailAddress;
|
||||
} else {
|
||||
return session.getOwnEmailAddress();
|
||||
}
|
||||
}
|
||||
|
||||
Set<EmailAddress> createReplyToRecipients() {
|
||||
if (replyToRecipients.isNotEmpty) {
|
||||
return replyToRecipients.toSet();
|
||||
} else if (identity?.replyTo?.isNotEmpty == true) {
|
||||
return identity!.replyTo!.toSet();
|
||||
} else {
|
||||
return { EmailAddress(null, session.getOwnEmailAddress()) };
|
||||
Set<EmailAddress>? createReplyToRecipients({bool isDraft = false}) {
|
||||
if (replyToRecipients?.isNotEmpty == true) {
|
||||
return replyToRecipients;
|
||||
}
|
||||
|
||||
if (isDraft) return null;
|
||||
|
||||
return identity?.replyTo?.isNotEmpty == true
|
||||
? identity!.replyTo!
|
||||
: {EmailAddress(null, session.getOwnEmailAddress())};
|
||||
}
|
||||
|
||||
|
||||
Set<EmailBodyPart> createAttachments() => attachments?.toEmailBodyPart() ?? {};
|
||||
|
||||
Map<KeyWordIdentifier, bool>? createKeywords() {
|
||||
@@ -110,6 +113,7 @@ extension CreateEmailRequestExtension on CreateEmailRequest {
|
||||
required String userAgent,
|
||||
required PartId partId,
|
||||
bool withIdentityHeader = false,
|
||||
bool isDraft = false,
|
||||
}) {
|
||||
return Email(
|
||||
mailboxIds: createMailboxIds(),
|
||||
@@ -117,7 +121,7 @@ extension CreateEmailRequestExtension on CreateEmailRequest {
|
||||
to: toRecipients,
|
||||
cc: ccRecipients,
|
||||
bcc: bccRecipients,
|
||||
replyTo: createReplyToRecipients(),
|
||||
replyTo: createReplyToRecipients(isDraft: isDraft),
|
||||
inReplyTo: createInReplyTo(),
|
||||
references: createReferences(),
|
||||
keywords: createKeywords(),
|
||||
|
||||
@@ -19,11 +19,11 @@ class CreateEmailRequest with EquatableMixin {
|
||||
final String subject;
|
||||
final String emailContent;
|
||||
final bool hasRequestReadReceipt;
|
||||
final Set<EmailAddress> fromSender;
|
||||
final Set<EmailAddress> toRecipients;
|
||||
final Set<EmailAddress> ccRecipients;
|
||||
final Set<EmailAddress> bccRecipients;
|
||||
final Set<EmailAddress> replyToRecipients;
|
||||
final Set<EmailAddress>? fromSender;
|
||||
final Set<EmailAddress>? toRecipients;
|
||||
final Set<EmailAddress>? ccRecipients;
|
||||
final Set<EmailAddress>? bccRecipients;
|
||||
final Set<EmailAddress>? replyToRecipients;
|
||||
final Identity? identity;
|
||||
final List<Attachment>? attachments;
|
||||
final Map<String, Attachment>? inlineAttachments;
|
||||
@@ -44,11 +44,11 @@ class CreateEmailRequest with EquatableMixin {
|
||||
required this.emailActionType,
|
||||
required this.subject,
|
||||
required this.emailContent,
|
||||
required this.fromSender,
|
||||
required this.toRecipients,
|
||||
required this.ccRecipients,
|
||||
required this.bccRecipients,
|
||||
required this.replyToRecipients,
|
||||
this.fromSender,
|
||||
this.toRecipients,
|
||||
this.ccRecipients,
|
||||
this.bccRecipients,
|
||||
this.replyToRecipients,
|
||||
this.hasRequestReadReceipt = true,
|
||||
this.identity,
|
||||
this.attachments,
|
||||
|
||||
Reference in New Issue
Block a user