mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2025-01-03 14:32:40 +00:00
Implement feed deletion
This commit is contained in:
parent
8eebb75b18
commit
9197a8d08b
2 changed files with 22 additions and 1 deletions
|
@ -785,7 +785,6 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Arsse::$db->subscriptionPropertiesSet(Arsse::$user->id, (int) $path[1], $in);
|
Arsse::$db->subscriptionPropertiesSet(Arsse::$user->id, (int) $path[1], $in);
|
||||||
return $this->getFeed($path);
|
|
||||||
} catch (ExceptionInput $e) {
|
} catch (ExceptionInput $e) {
|
||||||
switch ($e->getCode()) {
|
switch ($e->getCode()) {
|
||||||
case 10231:
|
case 10231:
|
||||||
|
@ -797,6 +796,16 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
return new ErrorResponse("404", 404);
|
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 {
|
public static function tokenGenerate(string $user, string $label): string {
|
||||||
|
|
|
@ -712,4 +712,16 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
[['title' => "Ook!", 'crawler' => true], ['title' => "Ook!", 'scrape' => true], true, $success]
|
[['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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue