TF-48 Create and update object for compose email
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||
import 'package:model/email/email_address_cache.dart';
|
||||
|
||||
extension EmailAddressExtension on EmailAddress {
|
||||
|
||||
@@ -26,4 +27,6 @@ extension EmailAddressExtension on EmailAddress {
|
||||
String getEmail() => email != null ? email! : '';
|
||||
|
||||
String getName() => name != null ? name! : '';
|
||||
|
||||
EmailAddressCache toEmailAddressCache() => EmailAddressCache(name ?? '', email ?? '');
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
extension EmailExtension on Email {
|
||||
|
||||
Set<String> getRecipientEmailAddressList() {
|
||||
final listEmailAddress = Set<String>();
|
||||
final listToAddress = to.getListAddress() ?? [];
|
||||
final listCcAddress = cc.getListAddress() ?? [];
|
||||
final listBccAddress = bcc.getListAddress() ?? [];
|
||||
listEmailAddress.addAll(listToAddress + listCcAddress + listBccAddress);
|
||||
return listEmailAddress;
|
||||
}
|
||||
|
||||
EmailContent toEmailContent() {
|
||||
return EmailContent(
|
||||
id,
|
||||
htmlBody: htmlBody,
|
||||
attachments: attachments,
|
||||
bodyValues: bodyValues
|
||||
);
|
||||
}
|
||||
|
||||
PresentationEmail toPresentationEmail({SelectMode selectMode = SelectMode.INACTIVE}) {
|
||||
return PresentationEmail(
|
||||
id,
|
||||
keywords: keywords,
|
||||
size: size,
|
||||
receivedAt: receivedAt,
|
||||
hasAttachment: hasAttachment,
|
||||
preview: preview,
|
||||
subject: subject,
|
||||
sentAt: sentAt,
|
||||
from: from,
|
||||
to: to,
|
||||
cc: cc,
|
||||
bcc: bcc,
|
||||
replyTo: replyTo,
|
||||
selectMode: selectMode
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import 'package:model/extensions/email_address_extension.dart';
|
||||
|
||||
extension ListEmailAddressExtension on Set<EmailAddress>? {
|
||||
|
||||
List<String>? getListAddress() => this?.map((emailAddress) => emailAddress.getEmail()).toList();
|
||||
|
||||
List<String> getListEmailAddress({ExpandMode expandMode = ExpandMode.EXPAND, int limitAddress = 1, bool isFullEmailAddress = false}) {
|
||||
if (this != null) {
|
||||
if (expandMode == ExpandMode.EXPAND) {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import 'package:model/model.dart';
|
||||
|
||||
extension PresentationAccountExtension on PresentationAccount {
|
||||
PresentationAccountResponse toPresentationAccountResponse() {
|
||||
return PresentationAccountResponse(emails, preferredEmailIndex, type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
extension PresentationEmailExtension on PresentationEmail {
|
||||
|
||||
int numberOfAllEmailAddress() => to.numberEmailAddress() + cc.numberEmailAddress() + bcc.numberEmailAddress();
|
||||
|
||||
String getEmailDateTime(String newLocale, {String? pattern}) {
|
||||
final emailTime = sentAt ?? receivedAt;
|
||||
if (emailTime != null) {
|
||||
return emailTime.formatDate(pattern: pattern ?? emailTime.value.toPattern(), locale: newLocale);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:model/model.dart';
|
||||
|
||||
extension UserProfileExtension on UserProfile {
|
||||
UserProfileResponse toUserProfileResponse() {
|
||||
return UserProfileResponse(
|
||||
id,
|
||||
firstName,
|
||||
lastName,
|
||||
jobTitle,
|
||||
service,
|
||||
buildingLocation,
|
||||
officeLocation,
|
||||
mainPhone,
|
||||
description,
|
||||
currentAvatar,
|
||||
avatars,
|
||||
accounts.map((account) => account.toPresentationAccountResponse()).toList()
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user