TF-1961 Transform html email content in composer

(cherry picked from commit f5470c130744242195b265a0ea4aad044ad8e740)
This commit is contained in:
dab246
2023-08-18 19:42:04 +07:00
committed by Dat Vu
parent e06d35f1e1
commit 8eed49fd73
45 changed files with 1139 additions and 644 deletions
@@ -6,6 +6,7 @@ import 'package:core/data/model/source_type/data_source_type.dart';
import 'package:core/data/network/download/downloaded_response.dart';
import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
import 'package:core/presentation/utils/html_transformer/transform_configuration.dart';
import 'package:dartz/dartz.dart';
import 'package:dio/dio.dart';
import 'package:jmap_dart_client/jmap/account_id.dart';
@@ -109,22 +110,16 @@ class EmailRepositoryImpl extends EmailRepository {
@override
Future<List<EmailContent>> transformEmailContent(
List<EmailContent> emailContents,
List<Attachment> attachmentInlines,
String? baseUrlDownload,
AccountId accountId,
{bool draftsEmail = false}
) async {
final mapUrlDownloadCID = {
for (var attachment in attachmentInlines)
attachment.cid! : attachment.getDownloadUrl(baseUrlDownload!, accountId)
};
List<EmailContent> emailContents,
Map<String, String> mapCidImageDownloadUrl,
TransformConfiguration transformConfiguration
) async {
return await Future.wait(emailContents
.map((emailContent) async {
return await _htmlDataSource.transformEmailContent(
emailContent,
mapUrlDownloadCID,
draftsEmail: draftsEmail
mapCidImageDownloadUrl,
transformConfiguration,
);
})
.toList());
@@ -173,13 +168,6 @@ class EmailRepositoryImpl extends EmailRepository {
return emailDataSource[DataSourceType.network]!.deleteEmailPermanently(session, accountId, emailId);
}
@override
Future<List<EmailContent>> addTooltipWhenHoverOnLink(List<EmailContent> emailContents) {
return Future.wait(emailContents
.map((emailContent) => _htmlDataSource.addTooltipWhenHoverOnLink(emailContent))
.toList());
}
@override
Future<jmap.State?> getEmailState(Session session, AccountId accountId) {
return _stateDataSource.getState(accountId, session.username, StateType.email);
@@ -219,4 +207,9 @@ class EmailRepositoryImpl extends EmailRepository {
Future<DetailedEmail> getStoredNewEmail(Session session, AccountId accountId, EmailId emailId) {
return emailDataSource[DataSourceType.hiveCache]!.getStoredNewEmail(session, accountId, emailId);
}
@override
Future<String> transformHtmlEmailContent(String htmlContent, TransformConfiguration configuration) {
return _htmlDataSource.transformHtmlEmailContent(htmlContent, configuration);
}
}