TF-942 Auto generate missing Outbox mailbox before send email
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_body_part.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/model.dart';
|
||||
|
||||
extension EmailExtension on Email {
|
||||
@@ -23,7 +24,7 @@ extension EmailExtension on Email {
|
||||
return listEmailAddress;
|
||||
}
|
||||
|
||||
Email updatedEmail({Map<KeyWordIdentifier, bool>? newKeywords}) {
|
||||
Email updatedEmail({Map<KeyWordIdentifier, bool>? newKeywords, Map<MailboxId, bool>? newMailboxIds}) {
|
||||
return Email(
|
||||
id,
|
||||
keywords: newKeywords ?? keywords,
|
||||
@@ -37,7 +38,12 @@ extension EmailExtension on Email {
|
||||
to: to,
|
||||
cc: cc,
|
||||
bcc: bcc,
|
||||
replyTo: replyTo
|
||||
replyTo: replyTo,
|
||||
mailboxIds: newMailboxIds ?? mailboxIds,
|
||||
htmlBody: htmlBody,
|
||||
bodyValues: bodyValues,
|
||||
headerUserAgent: headerUserAgent,
|
||||
attachments: attachments
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
import 'package:jmap_dart_client/jmap/core/patch_object.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/reference_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
|
||||
extension MailboxIdExtension on MailboxId {
|
||||
String generatePath() {
|
||||
return '${PatchObject.mailboxIdsProperty}/${id.value}';
|
||||
if (id is ReferenceId) {
|
||||
return '${PatchObject.mailboxIdsProperty}/${id.toString()}';
|
||||
} else {
|
||||
return '${PatchObject.mailboxIdsProperty}/${id.value}';
|
||||
}
|
||||
}
|
||||
|
||||
PatchObject generateMoveToMailboxActionPath(MailboxId destinationMailboxId) {
|
||||
|
||||
@@ -7,4 +7,8 @@ extension MailboxNameExtension on MailboxName {
|
||||
}
|
||||
return name.toLowerCase().compareTo(other.name.toLowerCase());
|
||||
}
|
||||
|
||||
MailboxName toLowerCase() {
|
||||
return MailboxName(name.toLowerCase());
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,9 @@ class PresentationMailbox with EquatableMixin {
|
||||
static final roleDrafts = Role('drafts');
|
||||
static final roleSpam = Role('spam');
|
||||
|
||||
static final outboxMailboxName = MailboxName('Outbox');
|
||||
static final lowerCaseOutboxMailboxName = MailboxName('outbox');
|
||||
|
||||
final MailboxId id;
|
||||
final MailboxName? name;
|
||||
final MailboxId? parentId;
|
||||
@@ -70,7 +73,7 @@ class PresentationMailbox with EquatableMixin {
|
||||
|
||||
bool get isSent => role == roleSent;
|
||||
|
||||
bool get isOutbox => name?.name == 'Outbox';
|
||||
bool get isOutbox => name == lowerCaseOutboxMailboxName || role == roleOutbox;
|
||||
|
||||
bool matchCountingRules() {
|
||||
if (isSpam || isTrash || isDrafts || isTemplates || isSent) {
|
||||
|
||||
Reference in New Issue
Block a user