feat: colleciton delete
Some checks failed
Build Test / test (pull_request) Successful in 30s
JS Unit Tests / test (pull_request) Failing after 28s
PHP Unit Tests / test (pull_request) Successful in 1m7s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-05-05 22:32:52 -04:00
parent 5988a372bc
commit b682b0629c
6 changed files with 74 additions and 11 deletions

View File

@@ -549,7 +549,7 @@ class DefaultController extends ControllerAbstract {
throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER);
}
return $this->mailManager->collectionDelete(
$result = $this->mailManager->collectionDelete(
$tenantId,
$userId,
$data['provider'],
@@ -557,6 +557,48 @@ class DefaultController extends ControllerAbstract {
$data['identifier'],
$data['options'] ?? []
);
if (is_bool($result)) {
return [
'outcome' => 'deleted'
];
}
if ($result instanceof JsonSerializable) {
return [
'outcome' => 'moved',
'data' => $result
];
}
return $result;
}
private function collectionMove(string $tenantId, string $userId, array $data): mixed {
if (!isset($data['target'])) {
throw new InvalidArgumentException(self::ERR_MISSING_TARGET);
}
if (!is_string($data['target'])) {
throw new InvalidArgumentException(self::ERR_INVALID_TARGET);
}
if (!isset($data['sources'])) {
throw new InvalidArgumentException(self::ERR_MISSING_SOURCES);
}
if (!is_array($data['sources'])) {
throw new InvalidArgumentException(self::ERR_INVALID_SOURCES);
}
$target = ResourceIdentifier::fromString($data['target']);
if (!$target instanceof CollectionIdentifier) {
throw new InvalidArgumentException('Invalid parameter: target must be provider:service:collection');
}
$source = ResourceIdentifier::fromArray($data['source']);
if (!$source instanceof CollectionIdentifier) {
throw new InvalidArgumentException('Invalid parameter: sources must contain provider:service:collection identifiers');
}
return $this->mailManager->collectionMove($tenantId, $userId, $target, $source);
}
// ==================== Entity Operations ====================

View File

@@ -653,7 +653,7 @@ class Manager {
*
* @return CollectionBaseInterface|null
*/
public function collectionDelete(string $tenantId, ?string $userId, string $providerId, string|int $serviceId, string|int $collectionId, array $options = []): bool {
public function collectionDelete(string $tenantId, ?string $userId, string $providerId, string|int $serviceId, string|int $collectionId, array $options = []): CollectionBaseInterface | bool {
// retrieve service
$service = $this->serviceFetch($tenantId, $userId, $providerId, $serviceId);
@@ -666,10 +666,9 @@ class Manager {
}
$force = $options['force'] ?? false;
$recursive = $options['recursive'] ?? false;
// delete collection
return $service->collectionDelete($collectionId, $force, $recursive);
return $service->collectionDelete($collectionId, $force);
}
// ==================== Message Operations ====================