From af536b9cf6a187be8f22eddb2bfc5df33f526f14 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sun, 5 Mar 2023 20:43:20 +0000 Subject: [PATCH] api: make /media parse seaweedfs_fid --- lib/PoorBooru/API/V0/Controller/Media.pm | 3 ++- lib/PoorBooru/Backend/Controller/Gallery.pm | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/PoorBooru/API/V0/Controller/Media.pm b/lib/PoorBooru/API/V0/Controller/Media.pm index 05dcaa1..a852216 100644 --- a/lib/PoorBooru/API/V0/Controller/Media.pm +++ b/lib/PoorBooru/API/V0/Controller/Media.pm @@ -4,6 +4,7 @@ use strict; use warnings; use Mojo::Base "Mojolicious::Controller"; +use SeaweedFS::FID; my $MEDIA_SEARCH_OPTS = { order_by => { -desc => "media_id" }, @@ -31,7 +32,7 @@ sub list ($self) ->search({}, $MEDIA_SEARCH_OPTS)->page($page); my @media = map +{ media_id => $_->media_id, - seaweedfs_fid => $_->seaweedfs_fid, + seaweedfs_fid => SeaweedFS::FID->from_bin($_->seaweedfs_fid), }, $paged_media->all; return $self->render(json => { diff --git a/lib/PoorBooru/Backend/Controller/Gallery.pm b/lib/PoorBooru/Backend/Controller/Gallery.pm index f6f8c77..09cdb54 100644 --- a/lib/PoorBooru/Backend/Controller/Gallery.pm +++ b/lib/PoorBooru/Backend/Controller/Gallery.pm @@ -24,7 +24,9 @@ sub index ($self) return $self->render(status => $res->code) if $res->is_error; my @media = map +{ - media_src => $self->seaweed->url_for(SeaweedFS::FID->from_bin($_->{seaweedfs_fid})), + media_src => $self->seaweed->url_for( + SeaweedFS::FID->from_string($_->{seaweedfs_fid}) + ), }, @{$res->json->{media}}; return $self->render(template => "gallery", media => \@media);