diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2026-05-26 11:24:58 +0300 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2026-05-26 11:24:58 +0300 |
| commit | a865ff1754f812e8cd163e4bfc1b8cbb2d10c2df (patch) | |
| tree | 3f12009857aea047d99b998e881dee13835f87b4 /classes/Handler/StorelastreadHandler.php | |
| parent | fa1bccd968647f6ab5cce0ec4293b39c6fde7633 (diff) | |
| download | the-epube-a865ff1754f812e8cd163e4bfc1b8cbb2d10c2df.tar.gz the-epube-a865ff1754f812e8cd163e4bfc1b8cbb2d10c2df.tar.xz | |
unify lastread position handlers
Diffstat (limited to 'classes/Handler/StorelastreadHandler.php')
| -rw-r--r-- | classes/Handler/StorelastreadHandler.php | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/classes/Handler/StorelastreadHandler.php b/classes/Handler/StorelastreadHandler.php deleted file mode 100644 index fa06769..0000000 --- a/classes/Handler/StorelastreadHandler.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php - -namespace Handler; - -use AuthRequired; -use ORM; -use Request; -use RequestHandlerInterface; -use Response; - -class StorelastreadHandler implements RequestHandlerInterface, AuthRequired -{ - public function handle(Request $request): Response - { - $page = (int) $request->getAttribute('page'); - $bookid = (int) $request->getAttribute('id'); - $timestamp = (int) $request->getAttribute('timestamp'); - $cfi = $request->getAttribute('cfi', ''); - $owner = $_SESSION["owner"] ?? ""; - - if ($bookid) { - $book = ORM::for_table('epube_books') - ->where('bookid', $bookid) - ->where('owner', $owner) - ->find_one(); - - if ($book) { - if (($timestamp >= $book->lastts) && ($page >= $book->lastread || $page == PAGE_RESET_PROGRESS)) { - $book->set([ - 'lastread' => $page, - 'lastcfi' => $cfi, - 'lastts' => $timestamp, - ]); - } - } else { - $book = ORM::for_table('epube_books')->create(); - $book->set([ - 'bookid' => $bookid, - 'owner' => $owner, - 'lastread' => $page, - 'lastcfi' => $cfi, - 'lastts' => $timestamp, - ]); - } - - $book->save(); - } - - return (new Response())->withBody(json_encode(["page" => $page, "cfi" => $cfi])); - } -} |
