f7cloud_client/apps/richdocuments/lib/Service/DemoService.php
root 8b6a0139db f7cloud_client
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 22:59:26 +00:00

36 lines
884 B
PHP

<?php
/**
* SPDX-FileCopyrightText: 2020 F7cloud GmbH and F7cloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Richdocuments\Service;
use OCP\Http\Client\IClientService;
use OCP\ICache;
class DemoService {
public function __construct(
private ICache $cache,
private IClientService $clientService,
) {
}
public function fetchDemoServers($refresh = false) {
$servers = $this->cache->get('richdocuments-demo');
if (!$refresh) {
return json_decode($servers, true);
}
$demoServerList = 'https://col.la/f7clouddemoservers';
$client = $this->clientService->newClient();
try {
$response = $client->get($demoServerList);
$servers = json_decode($response->getBody(), true)['servers'] ?? [];
} catch (\Exception) {
$servers = [];
}
$this->cache->set('richdocuments-demo', json_encode($servers));
return $servers;
}
}