diff --git a/lib/REST/AbstractHandler.php b/lib/REST/AbstractHandler.php index 6060da4..f0e39e7 100644 --- a/lib/REST/AbstractHandler.php +++ b/lib/REST/AbstractHandler.php @@ -6,6 +6,7 @@ declare(strict_types=1); namespace JKingWeb\Arsse\REST; +use JKingWeb\Arsse\Arsse; use JKingWeb\Arsse\Misc\Date; use JKingWeb\Arsse\Misc\ValueInfo; use Psr\Http\Message\ServerRequestInterface; @@ -15,6 +16,15 @@ abstract class AbstractHandler implements Handler { abstract public function __construct(); abstract public function dispatch(ServerRequestInterface $req): ResponseInterface; + /** @codeCoverageIgnore */ + protected function now(): \DateTimeImmutable { + return Date::normalize("now"); + } + + protected function isAdmin(): bool { + return (bool) Arsse::$user->propertiesGet(Arsse::$user->id, false)['admin']; + } + protected function fieldMapNames(array $data, array $map): array { $out = []; foreach ($map as $to => $from) { diff --git a/lib/REST/Miniflux/V1.php b/lib/REST/Miniflux/V1.php index 99c6a9b..5474dc0 100644 --- a/lib/REST/Miniflux/V1.php +++ b/lib/REST/Miniflux/V1.php @@ -116,11 +116,6 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler { public function __construct() { } - /** @codeCoverageIgnore */ - protected function now(): \DateTimeImmutable { - return Date::normalize("now"); - } - protected function authenticate(ServerRequestInterface $req): bool { // first check any tokens; this is what Miniflux does if ($req->hasHeader("X-Auth-Token")) { @@ -143,11 +138,6 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler { return false; } - protected function isAdmin(): bool { - return (bool) Arsse::$user->propertiesGet(Arsse::$user->id, false)['admin']; - } - - public function dispatch(ServerRequestInterface $req): ResponseInterface { // try to authenticate if (!$this->authenticate($req)) {