From dd29ef6c1bd9e026e4e7018b838b1574f6b54e96 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Fri, 5 Feb 2021 09:04:00 -0500 Subject: [PATCH] Add feed refreshing stubs --- lib/REST/Miniflux/V1.php | 16 ++++++++++++++++ tests/cases/REST/Miniflux/TestV1.php | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/lib/REST/Miniflux/V1.php b/lib/REST/Miniflux/V1.php index 51884ea..2198ebb 100644 --- a/lib/REST/Miniflux/V1.php +++ b/lib/REST/Miniflux/V1.php @@ -1161,6 +1161,22 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler { return new EmptyResponse(204); } + protected function refreshFeed(array $path): ResponseInterface { + // NOTE: This is a no-op; we simply check that the feed exists + try { + Arsse::$db->subscriptionPropertiesGet(Arsse::$user->id, (int) $path[1]); + } catch (ExceptionInput $e) { + return new ErrorResponse("404", 404); + } + return new EmptyResponse(204); + } + + protected function refreshAllFeeds(): ResponseInterface { + // NOTE: This is a no-op + // It could be implemented, but the need is considered low since we use a dynamic schedule always + return new EmptyResponse(204); + } + public static function tokenGenerate(string $user, string $label): string { // Miniflux produces tokenss in base64url alphabet $t = str_replace(["+", "/"], ["-", "_"], base64_encode(random_bytes(self::TOKEN_LENGTH))); diff --git a/tests/cases/REST/Miniflux/TestV1.php b/tests/cases/REST/Miniflux/TestV1.php index 18982f3..22a53db 100644 --- a/tests/cases/REST/Miniflux/TestV1.php +++ b/tests/cases/REST/Miniflux/TestV1.php @@ -921,4 +921,20 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest { [new ExceptionInput("subjectMissing"), null, new ErrorResponse("404", 404)], ]; } + + public function testRefreshAFeed(): void { + \Phake::when(Arsse::$db)->subscriptionPropertiesGet->thenReturn([]); + $this->assertMessage(new EmptyResponse(204), $this->req("PUT", "/feeds/47/refresh")); + \Phake::verify(Arsse::$db)->subscriptionPropertiesGet(Arsse::$user->id, 47); + } + + public function testRefreshAMissingFeed(): void { + \Phake::when(Arsse::$db)->subscriptionPropertiesGet->thenThrow(new ExceptionInput("subjectMissing")); + $this->assertMessage(new ErrorResponse("404", 404), $this->req("PUT", "/feeds/2112/refresh")); + \Phake::verify(Arsse::$db)->subscriptionPropertiesGet(Arsse::$user->id, 2112); + } + + public function testRefreshAllFeeds(): void { + $this->assertMessage(new EmptyResponse(204), $this->req("PUT", "/feeds/refresh")); + } }