TF-605 Use bearer token download attachment on Android
This commit is contained in:
@@ -25,6 +25,7 @@ import 'package:tmail_ui_user/features/login/data/datasource_impl/hive_account_d
|
||||
import 'package:tmail_ui_user/features/login/data/local/account_cache_manager.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/local/oidc_configuration_cache_manager.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/local/token_oidc_cache_manager.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/network/config/authorization_interceptors.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/network/oidc_http_client.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/repository/account_repository_impl.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/repository/authentication_oidc_repository_impl.dart';
|
||||
@@ -32,6 +33,7 @@ import 'package:tmail_ui_user/features/login/data/repository/credential_reposito
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/account_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/authentication_oidc_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/credential_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/usecases/refresh_token_oidc_interactor.dart';
|
||||
|
||||
class EmailBindings extends BaseBindings {
|
||||
|
||||
@@ -79,6 +81,9 @@ class EmailBindings extends BaseBindings {
|
||||
Get.lazyPut(() => DownloadAttachmentsInteractor(
|
||||
Get.find<EmailRepository>(),
|
||||
Get.find<CredentialRepository>(),
|
||||
Get.find<AccountRepository>(),
|
||||
Get.find<AuthenticationOIDCRepository>(),
|
||||
Get.find<AuthorizationInterceptors>(),
|
||||
));
|
||||
Get.lazyPut(() => ExportAttachmentInteractor(
|
||||
Get.find<EmailRepository>(),
|
||||
@@ -92,6 +97,10 @@ class EmailBindings extends BaseBindings {
|
||||
Get.find<EmailRepository>(),
|
||||
Get.find<CredentialRepository>(),
|
||||
));
|
||||
Get.lazyPut(() => RefreshTokenOIDCInteractor(
|
||||
Get.find<AuthenticationOIDCRepository>(),
|
||||
Get.find<AccountRepository>(),
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -228,7 +228,7 @@ class EmailController extends BaseController {
|
||||
final status = await Permission.storage.status;
|
||||
switch (status) {
|
||||
case PermissionStatus.granted:
|
||||
_downloadAttachmentsAction(context, attachments);
|
||||
_downloadAttachmentsAction(attachments);
|
||||
break;
|
||||
case PermissionStatus.permanentlyDenied:
|
||||
_appToast.showToast(AppLocalizations.of(context).you_need_to_grant_files_permission_to_download_attachments);
|
||||
@@ -237,7 +237,7 @@ class EmailController extends BaseController {
|
||||
final requested = await Permission.storage.request();
|
||||
switch (requested) {
|
||||
case PermissionStatus.granted:
|
||||
_downloadAttachmentsAction(context, attachments);
|
||||
_downloadAttachmentsAction(attachments);
|
||||
break;
|
||||
default:
|
||||
_appToast.showToast(AppLocalizations.of(context).you_need_to_grant_files_permission_to_download_attachments);
|
||||
@@ -246,11 +246,11 @@ class EmailController extends BaseController {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_downloadAttachmentsAction(context, attachments);
|
||||
_downloadAttachmentsAction(attachments);
|
||||
}
|
||||
}
|
||||
|
||||
void _downloadAttachmentsAction(BuildContext context, List<Attachment> attachments) async {
|
||||
void _downloadAttachmentsAction(List<Attachment> attachments) async {
|
||||
final accountId = mailboxDashBoardController.accountId.value;
|
||||
if (accountId != null && mailboxDashBoardController.sessionCurrent != null) {
|
||||
final baseDownloadUrl = mailboxDashBoardController.sessionCurrent!.getDownloadUrl();
|
||||
@@ -258,7 +258,7 @@ class EmailController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
void _downloadAttachmentsFailure(Failure failure) {
|
||||
void _downloadAttachmentsFailure(DownloadAttachmentsFailure failure) {
|
||||
if (currentContext != null) {
|
||||
_appToast.showErrorToast(AppLocalizations.of(currentContext!).attachment_download_failed);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user