feat: implement download

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-05-23 20:18:58 -04:00
parent 640e3aa811
commit 9cdebd82b8
15 changed files with 336 additions and 172 deletions

View File

@@ -194,7 +194,7 @@ class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface,
// Attempt to authenticate and list mailboxes as a connectivity check
$client = RemoteService::freshClient($service);
$service = RemoteService::mailService($service, $client);
$mailboxes = $service->collectionList();
$mailboxes = iterator_to_array($service->collectionList());
$latency = (int) round((microtime(true) - $startTime) * 1000);
@@ -205,36 +205,9 @@ class Provider implements ProviderBaseInterface, ProviderServiceMutateInterface,
. ' (Latency: ' . $latency . ' ms)',
];
} catch (\Throwable $e) {
$latency = (int) round((microtime(true) - $startTime) * 1000);
$location = ($service instanceof Service) ? $service->getLocation() : null;
$target = $location
? $location->getEncryption() . '://' . $location->getHost() . ':' . $location->getPort()
: 'unknown host';
// stream_socket_client errors are suppressed with @ in gricob — recover them
$phpError = error_get_last();
$detail = $e->getMessage() !== '' ? $e->getMessage() : ($phpError['message'] ?? '');
if ($detail === '' && $location !== null) {
$host = $location->getHost();
if ($host !== '' && gethostbyname($host) === $host) {
$detail = "hostname '{$host}' could not be resolved";
} else {
$detail = 'connection refused or timed out — check port and encryption settings';
}
} elseif ($detail === '') {
$detail = 'no details — check host, port, and encryption settings';
}
return [
'success' => false,
'message' => sprintf(
'Connection to %s failed (%s): %s',
$target,
(new \ReflectionClass($e))->getShortName(),
$detail,
),
'message' => 'Test failed: ' . $e->getMessage(),
];
}
}