TF-2302 Fix delete folder
Signed-off-by: dab246 <tdvu@linagora.com> Signed-off-by: dab246 <tdvu@linagora.com> (cherry picked from commit e5d455fd923053d1cd3793204130e6dd4423f5e0)
This commit is contained in:
@@ -56,20 +56,20 @@ mixin HandleSetErrorMixin {
|
||||
}
|
||||
}
|
||||
|
||||
List<MapEntry<Id, SetError>> handleSetResponse(List<SetResponse?> listSetResponse) {
|
||||
Map<Id, SetError> handleSetResponse(List<SetResponse?> listSetResponse) {
|
||||
final listSetResponseNotNull = listSetResponse.whereNotNull().toList();
|
||||
if (listSetResponseNotNull.isEmpty) {
|
||||
return [];
|
||||
return <Id, SetError>{};
|
||||
}
|
||||
|
||||
final List<MapEntry<Id, SetError>> remainedErrors = [];
|
||||
final Map<Id, SetError> remainedErrors = <Id, SetError>{};
|
||||
for (var response in listSetResponseNotNull) {
|
||||
handleSetErrors(
|
||||
notDestroyedError: response.notDestroyed,
|
||||
notUpdatedError: response.notUpdated,
|
||||
notCreatedError: response.notCreated,
|
||||
unCatchErrorHandler: (setErrorEntry) {
|
||||
remainedErrors.add(setErrorEntry);
|
||||
remainedErrors.addEntries({setErrorEntry});
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -204,12 +204,11 @@ class EmailAPI with HandleSetErrorMixin {
|
||||
}
|
||||
|
||||
final emailCreated = setEmailResponse?.created?[idCreateMethod];
|
||||
final listEntriesErrors = handleSetResponse([
|
||||
final mapErrors = handleSetResponse([
|
||||
setEmailResponse,
|
||||
setEmailSubmissionResponse,
|
||||
markAsAnsweredOrForwardedSetResponse
|
||||
]);
|
||||
final mapErrors = Map.fromEntries(listEntriesErrors);
|
||||
|
||||
if (emailCreated != null && mapErrors.isEmpty) {
|
||||
return true;
|
||||
@@ -482,8 +481,7 @@ class EmailAPI with HandleSetErrorMixin {
|
||||
);
|
||||
|
||||
final emailCreated = setEmailResponse?.created?[idCreateMethod];
|
||||
final listEntriesErrors = handleSetResponse([setEmailResponse]);
|
||||
final mapErrors = Map.fromEntries(listEntriesErrors);
|
||||
final mapErrors = handleSetResponse([setEmailResponse]);
|
||||
|
||||
if (emailCreated != null && mapErrors.isEmpty) {
|
||||
return emailCreated;
|
||||
@@ -549,8 +547,7 @@ class EmailAPI with HandleSetErrorMixin {
|
||||
|
||||
final emailUpdated = setEmailResponse?.created?[idCreateMethod];
|
||||
final isEmailDeleted = setEmailResponse?.destroyed?.contains(oldEmailId.id);
|
||||
final listEntriesErrors = handleSetResponse([setEmailResponse]);
|
||||
final mapErrors = Map.fromEntries(listEntriesErrors);
|
||||
final mapErrors = handleSetResponse([setEmailResponse]);
|
||||
|
||||
if (emailUpdated != null && isEmailDeleted == true && mapErrors.isEmpty) {
|
||||
return emailUpdated;
|
||||
|
||||
@@ -197,12 +197,15 @@ class MailboxAPI with HandleSetErrorMixin {
|
||||
|
||||
Future<Map<Id, SetError>> deleteMultipleMailbox(Session session, AccountId accountId, List<MailboxId> mailboxIds) async {
|
||||
final coreCapability = session.getCapabilityProperties<CoreCapability>(
|
||||
accountId, CapabilityIdentifier.jmapCore);
|
||||
final maxMethodCount = coreCapability?.maxCallsInRequest?.value.toInt() ?? 0;
|
||||
accountId,
|
||||
CapabilityIdentifier.jmapCore
|
||||
);
|
||||
int maxMethodCount = coreCapability?.maxCallsInRequest?.value.toInt() ?? CapabilityIdentifierExtension.defaultMaxCallsInRequest;
|
||||
log('MailboxAPI::deleteMultipleMailbox:maxMethodCount: $maxMethodCount');
|
||||
|
||||
final Map<Id,SetError> finalDeletedMailboxErrors = {};
|
||||
var start = 0;
|
||||
var end = 0;
|
||||
int start = 0;
|
||||
int end = 0;
|
||||
while (end < mailboxIds.length) {
|
||||
start = end;
|
||||
if (mailboxIds.length - start >= maxMethodCount) {
|
||||
@@ -282,10 +285,7 @@ class MailboxAPI with HandleSetErrorMixin {
|
||||
if (setMailboxResponse?.updated?.containsKey(request.mailboxId.id) == true) {
|
||||
return true;
|
||||
} else {
|
||||
final listEntriesErrors = handleSetResponse([
|
||||
setMailboxResponse,
|
||||
]);
|
||||
final mapErrors = Map.fromEntries(listEntriesErrors);
|
||||
final mapErrors = handleSetResponse([setMailboxResponse]);
|
||||
throw SetMethodException(mapErrors);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user