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:dartz/dartz.dart';
|
||||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/session/session.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/model/email_request.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/domain/state/send_email_state.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/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/model/create_new_mailbox_request.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox/domain/repository/mailbox_repository.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/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 {
|
class SendEmailInteractor {
|
||||||
final EmailRepository _emailRepository;
|
final EmailRepository _emailRepository;
|
||||||
final MailboxRepository _mailboxRepository;
|
final MailboxRepository _mailboxRepository;
|
||||||
final ServerSettingsRepository _serverSettingsRepository;
|
|
||||||
|
|
||||||
SendEmailInteractor(
|
SendEmailInteractor(
|
||||||
this._emailRepository,
|
this._emailRepository,
|
||||||
this._mailboxRepository,
|
this._mailboxRepository);
|
||||||
this._serverSettingsRepository);
|
|
||||||
|
|
||||||
Stream<Either<Failure, Success>> execute(
|
Stream<Either<Failure, Success>> execute(
|
||||||
Session session,
|
Session session,
|
||||||
@@ -42,14 +38,10 @@ class SendEmailInteractor {
|
|||||||
final currentMailboxState = listState.first;
|
final currentMailboxState = listState.first;
|
||||||
final currentEmailState = listState.last;
|
final currentEmailState = listState.last;
|
||||||
|
|
||||||
EmailRequest? updatedEmailRequest = await _getUpdatedEmailRequestIfAvailable(
|
|
||||||
accountId,
|
|
||||||
emailRequest);
|
|
||||||
|
|
||||||
final result = await _emailRepository.sendEmail(
|
final result = await _emailRepository.sendEmail(
|
||||||
session,
|
session,
|
||||||
accountId,
|
accountId,
|
||||||
updatedEmailRequest ?? emailRequest,
|
emailRequest,
|
||||||
mailboxRequest: mailboxRequest
|
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(() => UploadController(Get.find<UploadAttachmentInteractor>()));
|
||||||
Get.lazyPut(() => RichTextWebController());
|
Get.lazyPut(() => RichTextWebController());
|
||||||
Get.lazyPut(() => ComposerController(
|
Get.lazyPut(() => ComposerController(
|
||||||
Get.find<DeviceInfoPlugin>(),
|
Get.find<DeviceInfoPlugin>(),
|
||||||
Get.find<LocalFilePickerInteractor>(),
|
Get.find<LocalFilePickerInteractor>(),
|
||||||
Get.find<GetEmailContentInteractor>(),
|
Get.find<GetEmailContentInteractor>(),
|
||||||
Get.find<GetAllIdentitiesInteractor>(),
|
Get.find<GetAllIdentitiesInteractor>(),
|
||||||
Get.find<UploadController>(),
|
Get.find<UploadController>(),
|
||||||
Get.find<RemoveComposerCacheOnWebInteractor>(),
|
Get.find<RemoveComposerCacheOnWebInteractor>(),
|
||||||
Get.find<SaveComposerCacheOnWebInteractor>(),
|
Get.find<SaveComposerCacheOnWebInteractor>(),
|
||||||
Get.find<RichTextWebController>(),
|
Get.find<RichTextWebController>(),
|
||||||
Get.find<DownloadImageAsBase64Interactor>(),
|
Get.find<DownloadImageAsBase64Interactor>(),
|
||||||
Get.find<TransformHtmlEmailContentInteractor>(),
|
Get.find<TransformHtmlEmailContentInteractor>(),
|
||||||
Get.find<GetAlwaysReadReceiptSettingInteractor>(),
|
Get.find<GetAlwaysReadReceiptSettingInteractor>(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -735,7 +735,7 @@ class ComposerController extends BaseController {
|
|||||||
},
|
},
|
||||||
headerUserAgent: {IndividualHeaderIdentifier.headerUserAgent : userAgent},
|
headerUserAgent: {IndividualHeaderIdentifier.headerUserAgent : userAgent},
|
||||||
attachments: attachments.isNotEmpty ? attachments : null,
|
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.lazyPut(() => SendEmailInteractor(
|
||||||
Get.find<EmailRepository>(),
|
Get.find<EmailRepository>(),
|
||||||
Get.find<MailboxRepository>(),
|
Get.find<MailboxRepository>(),
|
||||||
Get.find<ServerSettingsRepository>()
|
|
||||||
));
|
));
|
||||||
SendingQueueInteractorBindings().dependencies();
|
SendingQueueInteractorBindings().dependencies();
|
||||||
Get.lazyPut(() => StoreSessionInteractor(Get.find<SessionRepository>()));
|
Get.lazyPut(() => StoreSessionInteractor(Get.find<SessionRepository>()));
|
||||||
|
|||||||
+1
-1
@@ -67,7 +67,7 @@ class AlwaysReadReceiptController extends BaseController {
|
|||||||
void _updateAlwaysReadReceiptSettingSuccess(
|
void _updateAlwaysReadReceiptSettingSuccess(
|
||||||
UpdateAlwaysReadReceiptSettingSuccess success
|
UpdateAlwaysReadReceiptSettingSuccess success
|
||||||
) {
|
) {
|
||||||
_updateAlwaysReadReceiptValue(success.isEnabled);
|
_updateAlwaysReadReceiptValue(success.alwaysReadReceiptIsEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleAlwaysReadReceipt() {
|
void toggleAlwaysReadReceipt() {
|
||||||
|
|||||||
@@ -97,8 +97,7 @@ class SendEmailInteractorBindings extends InteractorsBindings {
|
|||||||
void bindingsInteractor() {
|
void bindingsInteractor() {
|
||||||
Get.lazyPut(() => SendEmailInteractor(
|
Get.lazyPut(() => SendEmailInteractor(
|
||||||
Get.find<EmailRepository>(),
|
Get.find<EmailRepository>(),
|
||||||
Get.find<MailboxRepository>(),
|
Get.find<MailboxRepository>()));
|
||||||
Get.find<ServerSettingsRepository>()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
+3
-3
@@ -3,12 +3,12 @@ import 'package:core/core.dart';
|
|||||||
class UpdatingAlwaysReadReceiptSetting extends LoadingState {}
|
class UpdatingAlwaysReadReceiptSetting extends LoadingState {}
|
||||||
|
|
||||||
class UpdateAlwaysReadReceiptSettingSuccess extends UIState {
|
class UpdateAlwaysReadReceiptSettingSuccess extends UIState {
|
||||||
final bool isEnabled;
|
final bool alwaysReadReceiptIsEnabled;
|
||||||
|
|
||||||
UpdateAlwaysReadReceiptSettingSuccess({required this.isEnabled});
|
UpdateAlwaysReadReceiptSettingSuccess({required this.alwaysReadReceiptIsEnabled});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object?> get props => [isEnabled];
|
List<Object?> get props => [alwaysReadReceiptIsEnabled];
|
||||||
}
|
}
|
||||||
|
|
||||||
class UpdateAlwaysReadReceiptSettingFailure extends FeatureFailure {
|
class UpdateAlwaysReadReceiptSettingFailure extends FeatureFailure {
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ class UpdateAlwaysReadReceiptSettingInteractor {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
yield Right(UpdateAlwaysReadReceiptSettingSuccess(
|
yield Right(UpdateAlwaysReadReceiptSettingSuccess(
|
||||||
isEnabled: result.settings?.alwaysReadReceipts ?? true));
|
alwaysReadReceiptIsEnabled: result.settings?.alwaysReadReceipts ?? true));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
yield Left(UpdateAlwaysReadReceiptSettingFailure(e));
|
yield Left(UpdateAlwaysReadReceiptSettingFailure(e));
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ void main() {
|
|||||||
.execute(accountId, alwaysReadReceipts),
|
.execute(accountId, alwaysReadReceipts),
|
||||||
emitsInOrder([
|
emitsInOrder([
|
||||||
Right(UpdatingAlwaysReadReceiptSetting()),
|
Right(UpdatingAlwaysReadReceiptSetting()),
|
||||||
Right(UpdateAlwaysReadReceiptSettingSuccess(isEnabled: alwaysReadReceipts)),
|
Right(UpdateAlwaysReadReceiptSettingSuccess(alwaysReadReceiptIsEnabled: alwaysReadReceipts)),
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user