refactor: bunch of improvements
All checks were successful
Build Test / test (pull_request) Successful in 35s
JS Unit Tests / test (pull_request) Successful in 33s
PHP Unit Tests / test (pull_request) Successful in 1m5s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-04-23 22:04:36 -04:00
parent d0e8406830
commit acc42d09ee
8 changed files with 406 additions and 259 deletions

View File

@@ -725,24 +725,40 @@ class RemoteMailService {
}
/**
* delete entity from remote storage
* delete entities from remote storage
*
* @since Release 1.0.0
*/
public function entityDelete(string $id): ?string {
public function entityDelete(string ...$identifiers): array {
// construct set request
$r0 = new MailSet($this->dataAccount, null, $this->resourceNamespace, $this->resourceEntityLabel);
// construct object
$r0->delete($id);
foreach ($identifiers as $id) {
$r0->delete($id);
}
// transceive
$bundle = $this->dataStore->perform([$r0]);
// extract response
$response = $bundle->response(0);
// determine if command succeeded
if (array_search($id, $response->deleted()) !== false) {
return $response->stateNew();
// check for command error
if ($response instanceof ResponseException) {
if ($response->type() === 'unknownMethod') {
throw new JmapUnknownMethod($response->description(), 1);
} else {
throw new Exception($response->type() . ': ' . $response->description(), 1);
}
}
return null;
$results = [];
// check for success
foreach ($response->deleteSuccesses() as $id) {
$results[$id] = true;
}
// check for failure
foreach ($response->deleteFailures() as $id => $data) {
$results[$id] = $data['type'] ?? 'unknownError';
}
return $results;
}
/**
@@ -751,7 +767,7 @@ class RemoteMailService {
* @since Release 1.0.0
*
*/
public function entityCopy(string $target, array $sources): array {
public function entityCopy(string $target, string ...$identifiers): array {
return [];
}
@@ -759,15 +775,8 @@ class RemoteMailService {
* move entity in remote storage
*
* @since Release 1.0.0
*
*/
public function entityMove(string $target, array $sources): array {
// extract identifiers from sources
$identifiers = [];
foreach ($sources as $source) {
$identifiers = array_merge($identifiers, $source);
}
public function entityMove(string $target, string ...$identifiers): array {
// construct request
$r0 = new MailSet($this->dataAccount, null, $this->resourceNamespace, $this->resourceEntityLabel);
foreach ($identifiers as $id) {

View File

@@ -69,10 +69,10 @@ class RemoteService {
}
// debugging
if ($service->getDebug()) {
$logDir = Server::getInstance()?->logDir();
$logDir .= '/jmap/' . $service->identifier() . '.json';
$client->configureTransportLogState(true);
$client->configureTransportLogLocation(
sys_get_temp_dir() . '/' . $location->getHost() . '-' . $identity->getIdentity() . '.log'
);
$client->configureTransportLogLocation($logDir);
}
// return
return $client;