TF-2871 Handle click notification to open detailed email on iOS
This commit is contained in:
@@ -106,7 +106,7 @@ abstract class BaseController extends GetxController
|
||||
(failure) {
|
||||
if (failure is FeatureFailure) {
|
||||
final exception = _performFilterExceptionInError(failure.exception);
|
||||
logError('BaseController::onData:exception: $exception');
|
||||
logError('$runtimeType::onData:exception: $exception');
|
||||
if (exception != null) {
|
||||
handleExceptionAction(failure: failure, exception: exception);
|
||||
} else {
|
||||
@@ -120,7 +120,7 @@ abstract class BaseController extends GetxController
|
||||
}
|
||||
|
||||
void onError(Object error, StackTrace stackTrace) {
|
||||
logError('BaseController::onError():error: $error | stackTrace: $stackTrace');
|
||||
logError('$runtimeType::onError():error: $error | stackTrace: $stackTrace');
|
||||
final exception = _performFilterExceptionInError(error);
|
||||
if (exception != null) {
|
||||
handleExceptionAction(exception: exception);
|
||||
@@ -132,7 +132,7 @@ abstract class BaseController extends GetxController
|
||||
void onDone() {}
|
||||
|
||||
Exception? _performFilterExceptionInError(dynamic error) {
|
||||
logError('BaseController::_performFilterExceptionInError(): $error');
|
||||
logError('$runtimeType::_performFilterExceptionInError(): $error');
|
||||
if (error is NoNetworkError || error is ConnectionTimeout || error is InternalServerError) {
|
||||
if (PlatformInfo.isWeb && currentOverlayContext != null && currentContext != null) {
|
||||
appToast.showToastMessage(
|
||||
@@ -157,7 +157,7 @@ abstract class BaseController extends GetxController
|
||||
void handleErrorViewState(Object error, StackTrace stackTrace) {}
|
||||
|
||||
void handleExceptionAction({Failure? failure, Exception? exception}) {
|
||||
logError('BaseController::handleExceptionAction():failure: $failure | exception: $exception');
|
||||
logError('$runtimeType::handleExceptionAction():failure: $failure | exception: $exception');
|
||||
if (exception is ConnectionError) {
|
||||
if (currentOverlayContext != null && currentContext != null) {
|
||||
appToast.showToastErrorMessage(
|
||||
@@ -183,7 +183,7 @@ abstract class BaseController extends GetxController
|
||||
}
|
||||
|
||||
void handleFailureViewState(Failure failure) async {
|
||||
logError('BaseController::handleFailureViewState(): ${failure.runtimeType}');
|
||||
logError('$runtimeType::handleFailureViewState():Failure = $failure');
|
||||
if (failure is LogoutOidcFailure) {
|
||||
if (_isFcmEnabled) {
|
||||
_getStoredFirebaseRegistrationFromCache();
|
||||
@@ -197,7 +197,7 @@ abstract class BaseController extends GetxController
|
||||
}
|
||||
|
||||
void handleSuccessViewState(Success success) async {
|
||||
log('BaseController::handleSuccessViewState(): ${success.runtimeType}');
|
||||
log('$runtimeType::handleSuccessViewState():Success = ${success.runtimeType}');
|
||||
if (success is LogoutOidcSuccess) {
|
||||
if (_isFcmEnabled) {
|
||||
_getStoredFirebaseRegistrationFromCache();
|
||||
@@ -214,7 +214,7 @@ abstract class BaseController extends GetxController
|
||||
void startFpsMeter() {
|
||||
FpsManager().start();
|
||||
fpsCallback = (fpsInfo) {
|
||||
log('BaseController::startFpsMeter(): $fpsInfo');
|
||||
log('$runtimeType::startFpsMeter(): $fpsInfo');
|
||||
};
|
||||
if (fpsCallback != null) {
|
||||
FpsManager().addFpsCallback(fpsCallback!);
|
||||
@@ -234,7 +234,7 @@ abstract class BaseController extends GetxController
|
||||
requireCapability(session!, accountId!, [tmailContactCapabilityIdentifier]);
|
||||
TMailAutoCompleteBindings().dependencies();
|
||||
} catch (e) {
|
||||
logError('BaseController::injectAutoCompleteBindings(): exception: $e');
|
||||
logError('$runtimeType::injectAutoCompleteBindings(): exception: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ abstract class BaseController extends GetxController
|
||||
requireCapability(session!, accountId!, [CapabilityIdentifier.jmapMdn]);
|
||||
MdnInteractorBindings().dependencies();
|
||||
} catch(e) {
|
||||
logError('BaseController::injectMdnBindings(): exception: $e');
|
||||
logError('$runtimeType::injectMdnBindings(): exception: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ abstract class BaseController extends GetxController
|
||||
requireCapability(session!, accountId!, [capabilityForward]);
|
||||
ForwardingInteractorsBindings().dependencies();
|
||||
} catch(e) {
|
||||
logError('BaseController::injectForwardBindings(): exception: $e');
|
||||
logError('$runtimeType::injectForwardBindings(): exception: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,14 +261,14 @@ abstract class BaseController extends GetxController
|
||||
requireCapability(session!, accountId!, [capabilityRuleFilter]);
|
||||
EmailRulesInteractorBindings().dependencies();
|
||||
} catch(e) {
|
||||
logError('BaseController::injectRuleFilterBindings(): exception: $e');
|
||||
logError('$runtimeType::injectRuleFilterBindings(): exception: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> injectFCMBindings(Session? session, AccountId? accountId) async {
|
||||
try {
|
||||
requireCapability(session!, accountId!, [FirebaseCapability.fcmIdentifier]);
|
||||
log('BaseController::injectFCMBindings: fcmAvailable = ${AppConfig.fcmAvailable}');
|
||||
log('$runtimeType::injectFCMBindings: fcmAvailable = ${AppConfig.fcmAvailable}');
|
||||
if (AppConfig.fcmAvailable) {
|
||||
final mapEnvData = Map<String, String>.from(dotenv.env);
|
||||
await AppUtils.loadFcmConfigFileToEnv(currentMapEnvData: mapEnvData);
|
||||
@@ -285,7 +285,7 @@ abstract class BaseController extends GetxController
|
||||
throw NotSupportFCMException();
|
||||
}
|
||||
} catch(e) {
|
||||
logError('BaseController::injectFCMBindings(): exception: $e');
|
||||
logError('$runtimeType::injectFCMBindings(): exception: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ abstract class BaseController extends GetxController
|
||||
}
|
||||
|
||||
Future<void> clearDataAndGoToLoginPage() async {
|
||||
log('BaseController::clearDataAndGoToLoginPage:');
|
||||
log('$runtimeType::clearDataAndGoToLoginPage:');
|
||||
await clearAllData();
|
||||
goToLogin();
|
||||
}
|
||||
|
||||
@@ -6,16 +6,18 @@ import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||
import 'package:model/extensions/session_extension.dart';
|
||||
import 'package:model/account/password.dart';
|
||||
import 'package:model/oidc/oidc_configuration.dart';
|
||||
import 'package:model/oidc/token_oidc.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_controller.dart';
|
||||
import 'package:tmail_ui_user/features/home/domain/extensions/session_extensions.dart';
|
||||
import 'package:tmail_ui_user/features/home/domain/state/get_session_state.dart';
|
||||
import 'package:tmail_ui_user/features/home/domain/usecases/get_session_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/state/get_authenticated_account_state.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/state/get_credential_state.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/state/get_stored_token_oidc_state.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/state/update_authentication_account_state.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/usecases/get_authenticated_account_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/usecases/update_authentication_account_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/usecases/update_account_cache_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/vacation/vacation_interactors_bindings.dart';
|
||||
import 'package:tmail_ui_user/main/error/capability_validator.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/remote_exception.dart';
|
||||
@@ -26,16 +28,18 @@ import 'package:tmail_ui_user/main/utils/message_toast_utils.dart';
|
||||
abstract class ReloadableController extends BaseController {
|
||||
final GetSessionInteractor _getSessionInteractor = Get.find<GetSessionInteractor>();
|
||||
final GetAuthenticatedAccountInteractor _getAuthenticatedAccountInteractor = Get.find<GetAuthenticatedAccountInteractor>();
|
||||
final UpdateAuthenticationAccountInteractor _updateAuthenticationAccountInteractor = Get.find<UpdateAuthenticationAccountInteractor>();
|
||||
final UpdateAccountCacheInteractor _updateAccountCacheInteractor = Get.find<UpdateAccountCacheInteractor>();
|
||||
|
||||
@override
|
||||
void handleFailureViewState(Failure failure) {
|
||||
if (failure is GetCredentialFailure ||
|
||||
failure is GetStoredTokenOidcFailure ||
|
||||
failure is GetAuthenticatedAccountFailure) {
|
||||
log('ReloadableController::handleFailureViewState(): failure: $failure');
|
||||
failure is GetAuthenticatedAccountFailure ||
|
||||
failure is UpdateAccountCacheFailure) {
|
||||
logError('$runtimeType::handleFailureViewState():Failure = $failure');
|
||||
goToLogin();
|
||||
} else if (failure is GetSessionFailure) {
|
||||
logError('$runtimeType::handleFailureViewState():Failure = $failure');
|
||||
_handleGetSessionFailure(failure.exception);
|
||||
} else {
|
||||
super.handleFailureViewState(failure);
|
||||
@@ -45,11 +49,26 @@ abstract class ReloadableController extends BaseController {
|
||||
@override
|
||||
void handleSuccessViewState(Success success) {
|
||||
if (success is GetCredentialViewState) {
|
||||
_handleGetCredentialSuccess(success);
|
||||
} else if (success is GetSessionSuccess) {
|
||||
_handleGetSessionSuccess(success);
|
||||
log('$runtimeType::handleSuccessViewState:Success = ${success.runtimeType}');
|
||||
_setDataToInterceptors(
|
||||
baseUrl: success.baseUrl.origin,
|
||||
userName: success.userName,
|
||||
password: success.password);
|
||||
getSessionAction();
|
||||
} else if (success is GetStoredTokenOidcSuccess) {
|
||||
_handleGetStoredTokenOIDCSuccess(success);
|
||||
log('$runtimeType::handleSuccessViewState:Success = ${success.runtimeType}');
|
||||
_setDataToInterceptors(
|
||||
baseUrl: success.baseUrl.toString(),
|
||||
tokenOIDC: success.tokenOidc,
|
||||
oidcConfiguration: success.oidcConfiguration);
|
||||
getSessionAction();
|
||||
} else if (success is GetSessionSuccess) {
|
||||
log('$runtimeType::handleSuccessViewState:Success = ${success.runtimeType}');
|
||||
updateAccountCache(success.session);
|
||||
} else if (success is UpdateAccountCacheSuccess) {
|
||||
log('$runtimeType::handleSuccessViewState:Success = ${success.runtimeType}');
|
||||
dynamicUrlInterceptors.changeBaseUrl(success.apiUrl);
|
||||
handleReloaded(success.session);
|
||||
} else {
|
||||
super.handleSuccessViewState(success);
|
||||
}
|
||||
@@ -66,22 +85,25 @@ abstract class ReloadableController extends BaseController {
|
||||
consumeState(_getAuthenticatedAccountInteractor.execute());
|
||||
}
|
||||
|
||||
void _setUpInterceptors(GetCredentialViewState credentialViewState) {
|
||||
dynamicUrlInterceptors.setJmapUrl(credentialViewState.baseUrl.origin);
|
||||
dynamicUrlInterceptors.changeBaseUrl(credentialViewState.baseUrl.origin);
|
||||
authorizationInterceptors.setBasicAuthorization(
|
||||
credentialViewState.userName,
|
||||
credentialViewState.password,
|
||||
);
|
||||
authorizationIsolateInterceptors.setBasicAuthorization(
|
||||
credentialViewState.userName,
|
||||
credentialViewState.password,
|
||||
);
|
||||
}
|
||||
void _setDataToInterceptors({
|
||||
required String baseUrl,
|
||||
UserName? userName,
|
||||
Password? password,
|
||||
TokenOIDC? tokenOIDC,
|
||||
OIDCConfiguration? oidcConfiguration
|
||||
}) {
|
||||
dynamicUrlInterceptors.setJmapUrl(baseUrl);
|
||||
dynamicUrlInterceptors.changeBaseUrl(baseUrl);
|
||||
|
||||
void _handleGetCredentialSuccess(GetCredentialViewState credentialViewState) {
|
||||
_setUpInterceptors(credentialViewState);
|
||||
getSessionAction();
|
||||
if (userName != null && password != null) {
|
||||
authorizationInterceptors.setBasicAuthorization(userName, password);
|
||||
authorizationIsolateInterceptors.setBasicAuthorization(userName, password);
|
||||
}
|
||||
|
||||
if (tokenOIDC != null && oidcConfiguration != null) {
|
||||
authorizationInterceptors.setTokenAndAuthorityOidc(newToken: tokenOIDC, newConfig: oidcConfiguration);
|
||||
authorizationIsolateInterceptors.setTokenAndAuthorityOidc(newToken: tokenOIDC, newConfig: oidcConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
void getSessionAction() {
|
||||
@@ -98,50 +120,18 @@ abstract class ReloadableController extends BaseController {
|
||||
clearDataAndGoToLoginPage();
|
||||
}
|
||||
|
||||
void _handleGetSessionSuccess(GetSessionSuccess success) {
|
||||
final session = success.session;
|
||||
final personalAccount = session.personalAccount;
|
||||
final apiUrl = session.getQualifiedApiUrl(baseUrl: dynamicUrlInterceptors.jmapUrl);
|
||||
if (apiUrl.isNotEmpty) {
|
||||
dynamicUrlInterceptors.changeBaseUrl(apiUrl);
|
||||
updateAuthenticationAccount(session, personalAccount.accountId, session.username);
|
||||
handleReloaded(session);
|
||||
} else {
|
||||
clearDataAndGoToLoginPage();
|
||||
}
|
||||
}
|
||||
|
||||
void handleReloaded(Session session) {}
|
||||
|
||||
void _handleGetStoredTokenOIDCSuccess(GetStoredTokenOidcSuccess tokenOidcSuccess) {
|
||||
_setUpInterceptorsOidc(tokenOidcSuccess);
|
||||
getSessionAction();
|
||||
}
|
||||
|
||||
void _setUpInterceptorsOidc(GetStoredTokenOidcSuccess tokenOidcSuccess) {
|
||||
dynamicUrlInterceptors.setJmapUrl(tokenOidcSuccess.baseUrl.toString());
|
||||
dynamicUrlInterceptors.changeBaseUrl(tokenOidcSuccess.baseUrl.toString());
|
||||
authorizationInterceptors.setTokenAndAuthorityOidc(
|
||||
newToken: tokenOidcSuccess.tokenOidc,
|
||||
newConfig: tokenOidcSuccess.oidcConfiguration);
|
||||
authorizationIsolateInterceptors.setTokenAndAuthorityOidc(
|
||||
newToken: tokenOidcSuccess.tokenOidc,
|
||||
newConfig: tokenOidcSuccess.oidcConfiguration);
|
||||
}
|
||||
|
||||
void injectVacationBindings(Session? session, AccountId? accountId) {
|
||||
try {
|
||||
requireCapability(session!, accountId!, [CapabilityIdentifier.jmapVacationResponse]);
|
||||
VacationInteractorsBindings().dependencies();
|
||||
} catch(e) {
|
||||
logError('ReloadableController::injectVacationBindings(): exception: $e');
|
||||
logError('$runtimeType::injectVacationBindings(): exception: $e');
|
||||
}
|
||||
}
|
||||
|
||||
void updateAuthenticationAccount(Session session, AccountId accountId, UserName userName) {
|
||||
final apiUrl = session.getQualifiedApiUrl(baseUrl: dynamicUrlInterceptors.jmapUrl);
|
||||
if (apiUrl.isNotEmpty) {
|
||||
consumeState(_updateAuthenticationAccountInteractor.execute(accountId, apiUrl, userName));
|
||||
}
|
||||
void updateAccountCache(Session session) {
|
||||
consumeState(_updateAccountCacheInteractor.execute(session));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user