From ad6a6cb9c01e41df4596faa1a363b7b17f8ac356 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sun, 19 Feb 2023 20:22:30 +0000 Subject: [PATCH] backend: implement /random --- lib/PoorBooru.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/PoorBooru.pm b/lib/PoorBooru.pm index c09fc8e..2c7b6cf 100644 --- a/lib/PoorBooru.pm +++ b/lib/PoorBooru.pm @@ -149,6 +149,11 @@ get "/media/:media_id" => sub { }; get "/random" => sub { + my $res = api_get("/random"); + send_error("API error", 500) if !$res->{success}; + + my $data = decode_json($res->{content}); + forward "/media/" . $data->{id}; }; true;