TF-3096 Add PublicAsset create quota exception
This commit is contained in:
@@ -612,7 +612,7 @@ packages:
|
|||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: sprint26_5aug
|
ref: sprint26_5aug
|
||||||
resolved-ref: "8dfee5c0386d3848e60673430ca7cb389fa61a54"
|
resolved-ref: "204c97eaa69c73af2d7740bff18ba4308fe8693f"
|
||||||
url: "https://github.com/linagora/jmap-dart-client.git"
|
url: "https://github.com/linagora/jmap-dart-client.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.1.0"
|
version: "0.1.0"
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ packages:
|
|||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: sprint26_5aug
|
ref: sprint26_5aug
|
||||||
resolved-ref: "8dfee5c0386d3848e60673430ca7cb389fa61a54"
|
resolved-ref: "204c97eaa69c73af2d7740bff18ba4308fe8693f"
|
||||||
url: "https://github.com/linagora/jmap-dart-client.git"
|
url: "https://github.com/linagora/jmap-dart-client.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.1.0"
|
version: "0.1.0"
|
||||||
|
|||||||
+1
-1
@@ -296,7 +296,7 @@ packages:
|
|||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: sprint26_5aug
|
ref: sprint26_5aug
|
||||||
resolved-ref: "8dfee5c0386d3848e60673430ca7cb389fa61a54"
|
resolved-ref: "204c97eaa69c73af2d7740bff18ba4308fe8693f"
|
||||||
url: "https://github.com/linagora/jmap-dart-client.git"
|
url: "https://github.com/linagora/jmap-dart-client.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.1.0"
|
version: "0.1.0"
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ packages:
|
|||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: sprint26_5aug
|
ref: sprint26_5aug
|
||||||
resolved-ref: "8dfee5c0386d3848e60673430ca7cb389fa61a54"
|
resolved-ref: "204c97eaa69c73af2d7740bff18ba4308fe8693f"
|
||||||
url: "https://github.com/linagora/jmap-dart-client.git"
|
url: "https://github.com/linagora/jmap-dart-client.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.1.0"
|
version: "0.1.0"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:jmap_dart_client/http/converter/identities/public_asset_identities_converter.dart';
|
import 'package:jmap_dart_client/http/converter/identities/public_asset_identities_converter.dart';
|
||||||
import 'package:jmap_dart_client/http/http_client.dart';
|
import 'package:jmap_dart_client/http/http_client.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/error/method/error_method_response.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/patch_object.dart';
|
import 'package:jmap_dart_client/jmap/core/patch_object.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||||
@@ -88,15 +89,22 @@ class PublicAssetApi {
|
|||||||
.build()
|
.build()
|
||||||
.execute();
|
.execute();
|
||||||
final publicAsset = response.parse<SetPublicAssetResponse>(
|
final publicAsset = response.parse<SetPublicAssetResponse>(
|
||||||
invocation.methodCallId,
|
invocation.methodCallId,
|
||||||
SetPublicAssetResponse.deserialize
|
SetPublicAssetResponse.deserialize
|
||||||
)?.created?[generateCreateId];
|
)?.created?[generateCreateId];
|
||||||
|
|
||||||
if (publicAsset == null) {
|
final notCreatedError = response.parse<SetPublicAssetResponse>(
|
||||||
throw const CannotCreatePublicAssetException();
|
invocation.methodCallId,
|
||||||
|
SetPublicAssetResponse.deserialize
|
||||||
|
)?.notCreated?[generateCreateId];
|
||||||
|
|
||||||
|
if (notCreatedError == null && publicAsset != null) return publicAsset;
|
||||||
|
|
||||||
|
if (notCreatedError?.type == ErrorMethodResponse.overQuota) {
|
||||||
|
throw PublicAssetQuotaExceededException(message: notCreatedError?.description);
|
||||||
}
|
}
|
||||||
|
|
||||||
return publicAsset;
|
throw const CannotCreatePublicAssetException();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> destroyPublicAssets(
|
Future<void> destroyPublicAssets(
|
||||||
|
|||||||
@@ -2,6 +2,12 @@ class CannotCreatePublicAssetException implements Exception {
|
|||||||
const CannotCreatePublicAssetException();
|
const CannotCreatePublicAssetException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class PublicAssetQuotaExceededException implements Exception {
|
||||||
|
const PublicAssetQuotaExceededException({required this.message});
|
||||||
|
|
||||||
|
final String? message;
|
||||||
|
}
|
||||||
|
|
||||||
class CannotDestroyPublicAssetException implements Exception {
|
class CannotDestroyPublicAssetException implements Exception {
|
||||||
const CannotDestroyPublicAssetException();
|
const CannotDestroyPublicAssetException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2920,7 +2920,7 @@
|
|||||||
"placeholders_order": [],
|
"placeholders_order": [],
|
||||||
"placeholders": {}
|
"placeholders": {}
|
||||||
},
|
},
|
||||||
"pleaseChooseAnImageSizeCorrectly": "Please choose an image size <= {maxSize}KB",
|
"pleaseChooseAnImageSizeCorrectly": "Please choose an image with size less than {maxSize}KB",
|
||||||
"@pleaseChooseAnImageSizeCorrectly": {
|
"@pleaseChooseAnImageSizeCorrectly": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"placeholders_order": [
|
"placeholders_order": [
|
||||||
@@ -3988,6 +3988,12 @@
|
|||||||
"placeholders_order": [],
|
"placeholders_order": [],
|
||||||
"placeholders": {}
|
"placeholders": {}
|
||||||
},
|
},
|
||||||
|
"generalSignatureImageUploadError": "There was an error while uploading the image. Please try again.",
|
||||||
|
"@generalSignatureImageUploadError": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
"thisImageCannotBePastedIntoTheEditor": "This image cannot be pasted into the editor.",
|
"thisImageCannotBePastedIntoTheEditor": "This image cannot be pasted into the editor.",
|
||||||
"@thisImageCannotBePastedIntoTheEditor": {
|
"@thisImageCannotBePastedIntoTheEditor": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
|
|||||||
@@ -3026,7 +3026,7 @@ class AppLocalizations {
|
|||||||
|
|
||||||
String pleaseChooseAnImageSizeCorrectly(int maxSize) {
|
String pleaseChooseAnImageSizeCorrectly(int maxSize) {
|
||||||
return Intl.message(
|
return Intl.message(
|
||||||
'Please choose an image size <= ${maxSize}KB',
|
'Please choose an image with size less than ${maxSize}KB',
|
||||||
name: 'pleaseChooseAnImageSizeCorrectly',
|
name: 'pleaseChooseAnImageSizeCorrectly',
|
||||||
args: [maxSize]);
|
args: [maxSize]);
|
||||||
}
|
}
|
||||||
@@ -4177,6 +4177,12 @@ class AppLocalizations {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String get generalSignatureImageUploadError {
|
||||||
|
return Intl.message(
|
||||||
|
'There was an error while uploading the image. Please try again.',
|
||||||
|
name: 'generalSignatureImageUploadError');
|
||||||
|
}
|
||||||
|
|
||||||
String get thisImageCannotBePastedIntoTheEditor {
|
String get thisImageCannotBePastedIntoTheEditor {
|
||||||
return Intl.message(
|
return Intl.message(
|
||||||
'This image cannot be pasted into the editor.',
|
'This image cannot be pasted into the editor.',
|
||||||
|
|||||||
+1
-1
@@ -604,7 +604,7 @@ packages:
|
|||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: sprint26_5aug
|
ref: sprint26_5aug
|
||||||
resolved-ref: "8dfee5c0386d3848e60673430ca7cb389fa61a54"
|
resolved-ref: "204c97eaa69c73af2d7740bff18ba4308fe8693f"
|
||||||
url: "https://github.com/linagora/jmap-dart-client.git"
|
url: "https://github.com/linagora/jmap-dart-client.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.1.0"
|
version: "0.1.0"
|
||||||
|
|||||||
+1
-1
@@ -1196,7 +1196,7 @@ packages:
|
|||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: sprint26_5aug
|
ref: sprint26_5aug
|
||||||
resolved-ref: "8dfee5c0386d3848e60673430ca7cb389fa61a54"
|
resolved-ref: "204c97eaa69c73af2d7740bff18ba4308fe8693f"
|
||||||
url: "https://github.com/linagora/jmap-dart-client.git"
|
url: "https://github.com/linagora/jmap-dart-client.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.1.0"
|
version: "0.1.0"
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ packages:
|
|||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: sprint26_5aug
|
ref: sprint26_5aug
|
||||||
resolved-ref: "8dfee5c0386d3848e60673430ca7cb389fa61a54"
|
resolved-ref: "204c97eaa69c73af2d7740bff18ba4308fe8693f"
|
||||||
url: "https://github.com/linagora/jmap-dart-client.git"
|
url: "https://github.com/linagora/jmap-dart-client.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.1.0"
|
version: "0.1.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user