Files
ignacionelson 6e47d76ba6 ProjectSend 2.0.0
Client file sharing, rebuilt from the ground up: a private area per
client, resumable uploads, folders, groups and categories, sharing with
expiry dates and download limits, comments, file versions, an activity
log, a REST API, and sixteen languages.

This repository begins here. ProjectSend 2 was developed privately, and
that development history is not published — the previous generation
remains available, with its own history, at projectsend/legacy.

Free software under the GNU General Public License v2, or (at your
option) any later version.
2026-08-14 01:38:12 -03:00

58 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Modules\Platform\Updates;
use App\Modules\Platform\Capabilities\Capability;
use App\Modules\Platform\Capabilities\CapabilityRegistry;
use App\Modules\Platform\Settings\Setting;
use App\Modules\Platform\Settings\Settings;
/**
* The single "is a newer version known, and what does it look like"
* check — shared by the dashboard's System card (informational, gated
* only on view_system_info + edition) and HandleInertiaRequests' topbar
* notice (actionable, additionally gated on manage_updates). Both read
* the same cache CheckForUpdatesCommand writes; neither ever makes a
* live HTTP call.
*/
class LatestReleaseInfo
{
public function __construct(
private readonly CapabilityRegistry $capabilities,
private readonly Settings $settings,
) {}
/**
* @return array{version: string, title: string, notes: string, url: string, published_at: string}|null
*/
public function current(): ?array
{
if (! $this->capabilities->has(Capability::SystemUpdates)) {
return null;
}
$latestVersion = $this->string(Setting::LatestKnownVersion);
if ($latestVersion === '' || ! version_compare($latestVersion, (string) config('projectsend.version'), '>')) {
return null;
}
return [
'version' => $latestVersion,
'title' => $this->string(Setting::LatestReleaseTitle),
'notes' => $this->string(Setting::LatestReleaseNotes),
'url' => $this->string(Setting::LatestReleaseUrl),
'published_at' => $this->string(Setting::LatestReleasePublishedAt),
];
}
private function string(Setting $setting): string
{
$value = $this->settings->get($setting);
return is_string($value) ? $value : '';
}
}