mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 13:12:41 +00:00
Implement marking all as read for Miniflux
This commit is contained in:
parent
31f0539dc0
commit
7e17332714
2 changed files with 17 additions and 0 deletions
|
@ -489,6 +489,16 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler {
|
|||
return new EmptyResponse(204);
|
||||
}
|
||||
|
||||
protected function markUserByNum(array $path): ResponseInterface {
|
||||
// this function is restricted to the logged-in user
|
||||
$user = Arsse::$user->propertiesGet(Arsse::$user->id, false);
|
||||
if (((int) $path[1]) !== $user['num']) {
|
||||
return new ErrorResponse("403", 403);
|
||||
}
|
||||
Arsse::$db->articleMark(Arsse::$user->id, ['read' => true], (new Context)->hidden(false));
|
||||
return new EmptyResponse(204);
|
||||
}
|
||||
|
||||
protected function getCategories(): ResponseInterface {
|
||||
$out = [];
|
||||
$meta = Arsse::$user->propertiesGet(Arsse::$user->id, false);
|
||||
|
|
|
@ -400,6 +400,13 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
|
|||
$this->assertMessage(new ErrorResponse("403", 403), $this->req("DELETE", "/users/2112"));
|
||||
}
|
||||
|
||||
public function testMarkAllArticlesAsRead(): void {
|
||||
\Phake::when(Arsse::$db)->articleMark->thenReturn(true);
|
||||
$this->assertMessage(new ErrorResponse("403", 403), $this->req("PUT", "/users/1/mark-all-as-read"));
|
||||
$this->assertMessage(new EmptyResponse(204), $this->req("PUT", "/users/42/mark-all-as-read"));
|
||||
\Phake::verify(Arsse::$db)->articleMark("john.doe@example.com", ['read' => true], (new Context)->hidden(false));
|
||||
}
|
||||
|
||||
public function testListCategories(): void {
|
||||
\Phake::when(Arsse::$db)->folderList->thenReturn(new Result($this->v([
|
||||
['id' => 1, 'name' => "Science"],
|
||||
|
|
Loading…
Reference in a new issue