mirror of
https://github.com/linuxserver/Heimdall-Apps.git
synced 2026-02-20 04:16:08 +08:00
* Update Immich.php The current implementation of Immich.php issues an `invalid credentials` error on Heimdall when the `config` is enabled with the admin API key. The below changes fixes these issues and renders the `Photos` and `Videos` as per the api endpoint. * Linter fixes
55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\SupportedApps\Immich;
|
|
|
|
class Immich extends \App\SupportedApps implements \App\EnhancedApps
|
|
{
|
|
public $config;
|
|
|
|
//protected $login_first = true; // Uncomment if api requests need to be authed first
|
|
//protected $method = 'POST'; // Uncomment if requests to the API should be set by POST
|
|
|
|
public function __construct()
|
|
{
|
|
//$this->jar = new \GuzzleHttp\Cookie\CookieJar; // Uncomment if cookies need to be set
|
|
}
|
|
|
|
public function test()
|
|
{
|
|
$test = parent::appTest($this->url("server-info/statistics"));
|
|
echo $test->status;
|
|
}
|
|
|
|
public function livestats()
|
|
{
|
|
$status = "inactive";
|
|
$attrs = [
|
|
"headers" => [
|
|
"Accept" => "application/json",
|
|
"x-api-key" => $this->config->api_key,
|
|
],
|
|
];
|
|
$res = parent::execute($this->url("server-info/statistics"), $attrs);
|
|
$details = json_decode($res->getBody());
|
|
|
|
$data = [];
|
|
|
|
if ($details) {
|
|
$status = "active";
|
|
$data["photos"] = number_format($details->photos);
|
|
$data["videos"] = number_format($details->videos);
|
|
$usageInGiB = number_format($details->usage / 1073741824, 2);
|
|
$data["usage"] = $usageInGiB . 'GiB';
|
|
}
|
|
|
|
return parent::getLiveStats($status, $data);
|
|
}
|
|
public function url($endpoint)
|
|
{
|
|
$api_url = parent::normaliseurl($this->config->url) .
|
|
"api/" .
|
|
$endpoint;
|
|
return $api_url;
|
|
}
|
|
}
|