TF-940 Fix can not download attachment
This commit is contained in:
@@ -41,41 +41,39 @@ class DownloadAttachmentForWebInteractor {
|
|||||||
onReceiveController.add(Right(StartDownloadAttachmentForWeb(taskId, attachment)));
|
onReceiveController.add(Right(StartDownloadAttachmentForWeb(taskId, attachment)));
|
||||||
|
|
||||||
final currentAccount = await _accountRepository.getCurrentAccount();
|
final currentAccount = await _accountRepository.getCurrentAccount();
|
||||||
|
AccountRequest? accountRequest;
|
||||||
|
|
||||||
final bytesDownloaded = await Future.wait([
|
if (currentAccount.authenticationType == AuthenticationType.oidc) {
|
||||||
if (currentAccount.authenticationType == AuthenticationType.oidc)
|
final tokenOidc = await _authenticationOIDCRepository.getStoredTokenOIDC(currentAccount.id);
|
||||||
_authenticationOIDCRepository.getStoredTokenOIDC(currentAccount.id)
|
accountRequest = AccountRequest(
|
||||||
else
|
token: tokenOidc.toToken(),
|
||||||
credentialRepository.getAuthenticationInfoStored()
|
authenticationType: AuthenticationType.oidc);
|
||||||
], eagerError: true).then((List responses) async {
|
} else {
|
||||||
AccountRequest accountRequest;
|
final authenticationInfoCache = await credentialRepository.getAuthenticationInfoStored();
|
||||||
|
if (authenticationInfoCache != null) {
|
||||||
if (currentAccount.authenticationType == AuthenticationType.oidc) {
|
|
||||||
final tokenOidc = responses.first as TokenOIDC;
|
|
||||||
accountRequest = AccountRequest(
|
accountRequest = AccountRequest(
|
||||||
token: tokenOidc.toToken(),
|
userName: UserName(authenticationInfoCache.username),
|
||||||
authenticationType: AuthenticationType.oidc);
|
password: Password(authenticationInfoCache.password),
|
||||||
} else {
|
|
||||||
accountRequest = AccountRequest(
|
|
||||||
userName: responses.first as UserName,
|
|
||||||
password: responses.last as Password,
|
|
||||||
authenticationType: AuthenticationType.basic);
|
authenticationType: AuthenticationType.basic);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return await emailRepository.downloadAttachmentForWeb(
|
if (accountRequest != null) {
|
||||||
|
final bytesDownloaded = await emailRepository.downloadAttachmentForWeb(
|
||||||
taskId,
|
taskId,
|
||||||
attachment,
|
attachment,
|
||||||
accountId,
|
accountId,
|
||||||
baseDownloadUrl,
|
baseDownloadUrl,
|
||||||
accountRequest,
|
accountRequest,
|
||||||
onReceiveController
|
onReceiveController);
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
yield Right<Failure, Success>(DownloadAttachmentForWebSuccess(
|
yield Right<Failure, Success>(DownloadAttachmentForWebSuccess(
|
||||||
taskId,
|
taskId,
|
||||||
attachment,
|
attachment,
|
||||||
bytesDownloaded));
|
bytesDownloaded));
|
||||||
|
} else {
|
||||||
|
yield Left<Failure, Success>(DownloadAttachmentForWebFailure(taskId, null));
|
||||||
|
}
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
yield Left<Failure, Success>(DownloadAttachmentForWebFailure(
|
yield Left<Failure, Success>(DownloadAttachmentForWebFailure(
|
||||||
taskId,
|
taskId,
|
||||||
|
|||||||
@@ -32,39 +32,36 @@ class DownloadAttachmentsInteractor {
|
|||||||
String baseDownloadUrl
|
String baseDownloadUrl
|
||||||
) async* {
|
) async* {
|
||||||
try {
|
try {
|
||||||
final account = await _accountRepository.getCurrentAccount();
|
final currentAccount = await _accountRepository.getCurrentAccount();
|
||||||
|
|
||||||
log('ExportAttachmentInteractor::execute(): account: $account');
|
AccountRequest? accountRequest;
|
||||||
|
|
||||||
final taskIds = await Future.wait([
|
if (currentAccount.authenticationType == AuthenticationType.oidc) {
|
||||||
if (account.authenticationType == AuthenticationType.oidc)
|
final tokenOidc = await _authenticationOIDCRepository.getStoredTokenOIDC(currentAccount.id);
|
||||||
_authenticationOIDCRepository.getStoredTokenOIDC(account.id)
|
accountRequest = AccountRequest(
|
||||||
else
|
token: tokenOidc.toToken(),
|
||||||
credentialRepository.getAuthenticationInfoStored()
|
authenticationType: AuthenticationType.oidc);
|
||||||
], eagerError: true
|
} else {
|
||||||
).then((List responses) async {
|
final authenticationInfoCache = await credentialRepository.getAuthenticationInfoStored();
|
||||||
AccountRequest accountRequest;
|
if (authenticationInfoCache != null) {
|
||||||
|
|
||||||
if (account.authenticationType == AuthenticationType.oidc) {
|
|
||||||
final tokenOidc = responses.first as TokenOIDC;
|
|
||||||
accountRequest = AccountRequest(
|
accountRequest = AccountRequest(
|
||||||
token: tokenOidc.toToken(),
|
userName: UserName(authenticationInfoCache.username),
|
||||||
authenticationType: AuthenticationType.oidc);
|
password: Password(authenticationInfoCache.password),
|
||||||
} else {
|
|
||||||
accountRequest = AccountRequest(
|
|
||||||
userName: responses.first as UserName,
|
|
||||||
password: responses.last as Password,
|
|
||||||
authenticationType: AuthenticationType.basic);
|
authenticationType: AuthenticationType.basic);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return await emailRepository.downloadAttachments(
|
if (accountRequest != null) {
|
||||||
|
final taskIds = await emailRepository.downloadAttachments(
|
||||||
attachments,
|
attachments,
|
||||||
accountId,
|
accountId,
|
||||||
baseDownloadUrl,
|
baseDownloadUrl,
|
||||||
accountRequest);
|
accountRequest);
|
||||||
});
|
|
||||||
|
|
||||||
yield Right<Failure, Success>(DownloadAttachmentsSuccess(taskIds));
|
yield Right<Failure, Success>(DownloadAttachmentsSuccess(taskIds));
|
||||||
|
} else {
|
||||||
|
yield Left<Failure, Success>(DownloadAttachmentsFailure(null));
|
||||||
|
}
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
log('DownloadAttachmentsInteractor::execute(): $exception');
|
log('DownloadAttachmentsInteractor::execute(): $exception');
|
||||||
if (exception is DownloadAttachmentHasTokenExpiredException) {
|
if (exception is DownloadAttachmentHasTokenExpiredException) {
|
||||||
|
|||||||
@@ -31,39 +31,37 @@ class ExportAttachmentInteractor {
|
|||||||
CancelToken cancelToken
|
CancelToken cancelToken
|
||||||
) async* {
|
) async* {
|
||||||
try {
|
try {
|
||||||
final account = await _accountRepository.getCurrentAccount();
|
final currentAccount = await _accountRepository.getCurrentAccount();
|
||||||
|
|
||||||
log('ExportAttachmentInteractor::execute(): account: $account');
|
AccountRequest? accountRequest;
|
||||||
|
|
||||||
final downloadedResponse = await Future.wait([
|
if (currentAccount.authenticationType == AuthenticationType.oidc) {
|
||||||
if (account.authenticationType == AuthenticationType.oidc)
|
final tokenOidc = await _authenticationOIDCRepository.getStoredTokenOIDC(currentAccount.id);
|
||||||
_authenticationOIDCRepository.getStoredTokenOIDC(account.id)
|
accountRequest = AccountRequest(
|
||||||
else
|
token: tokenOidc.toToken(),
|
||||||
credentialRepository.getAuthenticationInfoStored()
|
authenticationType: AuthenticationType.oidc);
|
||||||
], eagerError: true
|
} else {
|
||||||
).then((List responses) async {
|
final authenticationInfoCache = await credentialRepository.getAuthenticationInfoStored();
|
||||||
AccountRequest accountRequest;
|
if (authenticationInfoCache != null) {
|
||||||
|
|
||||||
if (account.authenticationType == AuthenticationType.oidc) {
|
|
||||||
final tokenOidc = responses.first as TokenOIDC;
|
|
||||||
accountRequest = AccountRequest(
|
accountRequest = AccountRequest(
|
||||||
token: tokenOidc.toToken(),
|
userName: UserName(authenticationInfoCache.username),
|
||||||
authenticationType: AuthenticationType.oidc);
|
password: Password(authenticationInfoCache.password),
|
||||||
} else {
|
|
||||||
accountRequest = AccountRequest(
|
|
||||||
userName: responses.first as UserName,
|
|
||||||
password: responses.last as Password,
|
|
||||||
authenticationType: AuthenticationType.basic);
|
authenticationType: AuthenticationType.basic);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return await emailRepository.exportAttachment(
|
if (accountRequest != null) {
|
||||||
|
final downloadedResponse = await emailRepository.exportAttachment(
|
||||||
attachment,
|
attachment,
|
||||||
accountId,
|
accountId,
|
||||||
baseDownloadUrl,
|
baseDownloadUrl,
|
||||||
accountRequest,
|
accountRequest,
|
||||||
cancelToken);
|
cancelToken);
|
||||||
});
|
|
||||||
yield Right<Failure, Success>(ExportAttachmentSuccess(downloadedResponse));
|
yield Right<Failure, Success>(ExportAttachmentSuccess(downloadedResponse));
|
||||||
|
} else {
|
||||||
|
yield Left<Failure, Success>(ExportAttachmentFailure(null));
|
||||||
|
}
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
log('ExportAttachmentInteractor::execute(): exception: $exception');
|
log('ExportAttachmentInteractor::execute(): exception: $exception');
|
||||||
yield Left<Failure, Success>(ExportAttachmentFailure(exception));
|
yield Left<Failure, Success>(ExportAttachmentFailure(exception));
|
||||||
|
|||||||
Reference in New Issue
Block a user