refactor: bunch of improvements
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user