TF-3413 Support Reply to list for email
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
|
||||
enum EmailActionType {
|
||||
reply,
|
||||
replyToList,
|
||||
forward,
|
||||
replyAll,
|
||||
compose,
|
||||
|
||||
@@ -24,4 +24,5 @@ class EmailProperty {
|
||||
static const String references = 'references';
|
||||
static const String headerUnsubscribeKey = 'List-Unsubscribe';
|
||||
static const String headerSMimeStatusKey = 'X-SMIME-Status';
|
||||
static const String headerListPostKey = 'List-Post';
|
||||
}
|
||||
@@ -36,6 +36,10 @@ extension EmailExtension on Email {
|
||||
|
||||
String get sMimeStatusHeaderParsed => sMimeStatusHeader?[IndividualHeaderIdentifier.sMimeStatusHeader]?.trim() ?? '';
|
||||
|
||||
String get listPost => headers.listPost;
|
||||
|
||||
bool get hasListPost => listPost.isNotEmpty;
|
||||
|
||||
IdentityId? get identityIdFromHeader {
|
||||
final rawIdentityId = identityHeader?[IndividualHeaderIdentifier.identityHeader];
|
||||
if (rawIdentityId == null) return null;
|
||||
|
||||
@@ -24,4 +24,9 @@ extension ListEmailHeaderExtension on Set<EmailHeader>? {
|
||||
logger.log('ListEmailHeaderExtension::sMimeStatus: $sMimeStatus');
|
||||
return sMimeStatus?.value.trim() ?? '';
|
||||
}
|
||||
|
||||
String get listPost {
|
||||
final listPost = this?.firstWhereOrNull((header) => header.name == EmailProperty.headerListPostKey);
|
||||
return listPost?.value ?? '';
|
||||
}
|
||||
}
|
||||
@@ -6,11 +6,9 @@ import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/keyword_identifier.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:model/email/email_action_type.dart';
|
||||
import 'package:model/email/eml_attachment.dart';
|
||||
import 'package:model/email/presentation_email.dart';
|
||||
import 'package:model/extensions/email_address_extension.dart';
|
||||
@@ -133,30 +131,6 @@ extension PresentationEmailExtension on PresentationEmail {
|
||||
return allEmailAddress.isNotEmpty ? allEmailAddress.join(', ') : '';
|
||||
}
|
||||
|
||||
Tuple3<List<EmailAddress>, List<EmailAddress>, List<EmailAddress>> generateRecipientsEmailAddressForComposer({
|
||||
required EmailActionType emailActionType,
|
||||
Role? mailboxRole
|
||||
}) {
|
||||
switch(emailActionType) {
|
||||
case EmailActionType.reply:
|
||||
if (mailboxRole == PresentationMailbox.roleSent) {
|
||||
return Tuple3(to.asList(), [], []);
|
||||
} else {
|
||||
final replyToAddress = replyTo.asList().isNotEmpty ? replyTo.asList() : from.asList();
|
||||
return Tuple3(replyToAddress, [], []);
|
||||
}
|
||||
case EmailActionType.replyAll:
|
||||
if (mailboxRole == PresentationMailbox.roleSent) {
|
||||
return Tuple3(to.asList(), cc.asList(), bcc.asList());
|
||||
} else {
|
||||
final senderReplyToAddress = replyTo.asList().isNotEmpty ? replyTo.asList() : from.asList();
|
||||
return Tuple3(to.asList() + senderReplyToAddress, cc.asList(), bcc.asList());
|
||||
}
|
||||
default:
|
||||
return Tuple3(to.asList(), cc.asList(), bcc.asList());
|
||||
}
|
||||
}
|
||||
|
||||
PresentationEmail toSearchPresentationEmail(Map<MailboxId, PresentationMailbox> mapMailboxes) {
|
||||
mailboxIds?.removeWhere((key, value) => !value);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user