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