TF-2683 Integrate update always read receipt setting in composer (#2700)
This commit is contained in:
@@ -3,24 +3,20 @@ import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/extensions/email_request_extension.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/model/email_request.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/state/send_email_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/repository/email_repository.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/domain/model/create_new_mailbox_request.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/domain/repository/mailbox_repository.dart';
|
||||
import 'package:tmail_ui_user/features/sending_queue/presentation/model/sending_email_action_type.dart';
|
||||
import 'package:tmail_ui_user/features/server_settings/domain/repository/server_settings_repository.dart';
|
||||
|
||||
class SendEmailInteractor {
|
||||
final EmailRepository _emailRepository;
|
||||
final MailboxRepository _mailboxRepository;
|
||||
final ServerSettingsRepository _serverSettingsRepository;
|
||||
|
||||
SendEmailInteractor(
|
||||
this._emailRepository,
|
||||
this._mailboxRepository,
|
||||
this._serverSettingsRepository);
|
||||
this._mailboxRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(
|
||||
Session session,
|
||||
@@ -42,14 +38,10 @@ class SendEmailInteractor {
|
||||
final currentMailboxState = listState.first;
|
||||
final currentEmailState = listState.last;
|
||||
|
||||
EmailRequest? updatedEmailRequest = await _getUpdatedEmailRequestIfAvailable(
|
||||
accountId,
|
||||
emailRequest);
|
||||
|
||||
final result = await _emailRepository.sendEmail(
|
||||
session,
|
||||
accountId,
|
||||
updatedEmailRequest ?? emailRequest,
|
||||
emailRequest,
|
||||
mailboxRequest: mailboxRequest
|
||||
);
|
||||
|
||||
@@ -85,22 +77,4 @@ class SendEmailInteractor {
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Future<EmailRequest?> _getUpdatedEmailRequestIfAvailable(
|
||||
AccountId accountId,
|
||||
EmailRequest emailRequest
|
||||
) async {
|
||||
bool alwaysReadReceipt = true;
|
||||
EmailRequest? updatedEmailRequest;
|
||||
try {
|
||||
final serverSettings = await _serverSettingsRepository.getServerSettings(accountId);
|
||||
alwaysReadReceipt = serverSettings.settings?.alwaysReadReceipts ?? true;
|
||||
} catch (_) {
|
||||
alwaysReadReceipt = true;
|
||||
}
|
||||
if (!alwaysReadReceipt) {
|
||||
updatedEmailRequest = emailRequest.withUpdatedEmailHeaderMdn({});
|
||||
}
|
||||
return updatedEmailRequest;
|
||||
}
|
||||
}
|
||||
@@ -205,17 +205,17 @@ class ComposerBindings extends BaseBindings {
|
||||
Get.lazyPut(() => UploadController(Get.find<UploadAttachmentInteractor>()));
|
||||
Get.lazyPut(() => RichTextWebController());
|
||||
Get.lazyPut(() => ComposerController(
|
||||
Get.find<DeviceInfoPlugin>(),
|
||||
Get.find<LocalFilePickerInteractor>(),
|
||||
Get.find<GetEmailContentInteractor>(),
|
||||
Get.find<GetAllIdentitiesInteractor>(),
|
||||
Get.find<UploadController>(),
|
||||
Get.find<RemoveComposerCacheOnWebInteractor>(),
|
||||
Get.find<SaveComposerCacheOnWebInteractor>(),
|
||||
Get.find<RichTextWebController>(),
|
||||
Get.find<DownloadImageAsBase64Interactor>(),
|
||||
Get.find<TransformHtmlEmailContentInteractor>(),
|
||||
Get.find<GetAlwaysReadReceiptSettingInteractor>(),
|
||||
Get.find<DeviceInfoPlugin>(),
|
||||
Get.find<LocalFilePickerInteractor>(),
|
||||
Get.find<GetEmailContentInteractor>(),
|
||||
Get.find<GetAllIdentitiesInteractor>(),
|
||||
Get.find<UploadController>(),
|
||||
Get.find<RemoveComposerCacheOnWebInteractor>(),
|
||||
Get.find<SaveComposerCacheOnWebInteractor>(),
|
||||
Get.find<RichTextWebController>(),
|
||||
Get.find<DownloadImageAsBase64Interactor>(),
|
||||
Get.find<TransformHtmlEmailContentInteractor>(),
|
||||
Get.find<GetAlwaysReadReceiptSettingInteractor>(),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -735,7 +735,7 @@ class ComposerController extends BaseController {
|
||||
},
|
||||
headerUserAgent: {IndividualHeaderIdentifier.headerUserAgent : userAgent},
|
||||
attachments: attachments.isNotEmpty ? attachments : null,
|
||||
headerMdn: {IndividualHeaderIdentifier.headerMdn: getEmailAddressSender()},
|
||||
headerMdn: hasRequestReadReceipt.value ? { IndividualHeaderIdentifier.headerMdn: getEmailAddressSender() } : {},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -325,7 +325,6 @@ class MailboxDashBoardBindings extends BaseBindings {
|
||||
Get.lazyPut(() => SendEmailInteractor(
|
||||
Get.find<EmailRepository>(),
|
||||
Get.find<MailboxRepository>(),
|
||||
Get.find<ServerSettingsRepository>()
|
||||
));
|
||||
SendingQueueInteractorBindings().dependencies();
|
||||
Get.lazyPut(() => StoreSessionInteractor(Get.find<SessionRepository>()));
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ class AlwaysReadReceiptController extends BaseController {
|
||||
void _updateAlwaysReadReceiptSettingSuccess(
|
||||
UpdateAlwaysReadReceiptSettingSuccess success
|
||||
) {
|
||||
_updateAlwaysReadReceiptValue(success.isEnabled);
|
||||
_updateAlwaysReadReceiptValue(success.alwaysReadReceiptIsEnabled);
|
||||
}
|
||||
|
||||
void toggleAlwaysReadReceipt() {
|
||||
|
||||
@@ -97,8 +97,7 @@ class SendEmailInteractorBindings extends InteractorsBindings {
|
||||
void bindingsInteractor() {
|
||||
Get.lazyPut(() => SendEmailInteractor(
|
||||
Get.find<EmailRepository>(),
|
||||
Get.find<MailboxRepository>(),
|
||||
Get.find<ServerSettingsRepository>()));
|
||||
Get.find<MailboxRepository>()));
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
+3
-3
@@ -3,12 +3,12 @@ import 'package:core/core.dart';
|
||||
class UpdatingAlwaysReadReceiptSetting extends LoadingState {}
|
||||
|
||||
class UpdateAlwaysReadReceiptSettingSuccess extends UIState {
|
||||
final bool isEnabled;
|
||||
final bool alwaysReadReceiptIsEnabled;
|
||||
|
||||
UpdateAlwaysReadReceiptSettingSuccess({required this.isEnabled});
|
||||
UpdateAlwaysReadReceiptSettingSuccess({required this.alwaysReadReceiptIsEnabled});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [isEnabled];
|
||||
List<Object?> get props => [alwaysReadReceiptIsEnabled];
|
||||
}
|
||||
|
||||
class UpdateAlwaysReadReceiptSettingFailure extends FeatureFailure {
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ class UpdateAlwaysReadReceiptSettingInteractor {
|
||||
)
|
||||
);
|
||||
yield Right(UpdateAlwaysReadReceiptSettingSuccess(
|
||||
isEnabled: result.settings?.alwaysReadReceipts ?? true));
|
||||
alwaysReadReceiptIsEnabled: result.settings?.alwaysReadReceipts ?? true));
|
||||
} catch (e) {
|
||||
yield Left(UpdateAlwaysReadReceiptSettingFailure(e));
|
||||
}
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ void main() {
|
||||
.execute(accountId, alwaysReadReceipts),
|
||||
emitsInOrder([
|
||||
Right(UpdatingAlwaysReadReceiptSetting()),
|
||||
Right(UpdateAlwaysReadReceiptSettingSuccess(isEnabled: alwaysReadReceipts)),
|
||||
Right(UpdateAlwaysReadReceiptSettingSuccess(alwaysReadReceiptIsEnabled: alwaysReadReceipts)),
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user