1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 13:12:41 +00:00

Implement feed deletion

This commit is contained in:
J. King 2021-01-24 21:12:32 -05:00
parent 8eebb75b18
commit 9197a8d08b
2 changed files with 22 additions and 1 deletions

View file

@ -785,7 +785,6 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler {
}
try {
Arsse::$db->subscriptionPropertiesSet(Arsse::$user->id, (int) $path[1], $in);
return $this->getFeed($path);
} catch (ExceptionInput $e) {
switch ($e->getCode()) {
case 10231:
@ -797,6 +796,16 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler {
return new ErrorResponse("404", 404);
}
}
return $this->getFeed($path);
}
protected function deleteFeed(array $path): ResponseInterface {
try {
Arsse::$db->subscriptionRemove(Arsse::$user->id, (int) $path[1]);
return new EmptyResponse(204);
} catch (ExceptionInput $e) {
return new ErrorResponse("404", 404);
}
}
public static function tokenGenerate(string $user, string $label): string {

View file

@ -712,4 +712,16 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
[['title' => "Ook!", 'crawler' => true], ['title' => "Ook!", 'scrape' => true], true, $success]
];
}
public function testDeleteAFeed(): void {
\Phake::when(Arsse::$db)->subscriptionRemove->thenReturn(true);
$this->assertMessage(new EmptyResponse(204), $this->req("DELETE", "/feeds/2112"));
\Phake::verify(Arsse::$db)->subscriptionRemove(Arsse::$user->id, 2112);
}
public function testDeleteAMissingFeed(): void {
\Phake::when(Arsse::$db)->subscriptionRemove->thenThrow(new ExceptionInput("subjectMissing"));
$this->assertMessage(new ErrorResponse("404", 404), $this->req("DELETE", "/feeds/2112"));
\Phake::verify(Arsse::$db)->subscriptionRemove(Arsse::$user->id, 2112);
}
}