api/v0: remove duplicates from tags in list_media

This commit is contained in:
Lucas Gabriel Vuotto 2025-04-27 15:11:03 +00:00
parent e178a261e6
commit d1031a9162

View file

@ -1,6 +1,8 @@
package Pooru::API::V0::Controller::Media; package Pooru::API::V0::Controller::Media;
use Mojo::Base "Mojolicious::Controller", -signatures; use Mojo::Base "Mojolicious::Controller", -signatures;
use List::Util qw(uniq);
my %search_opts = Pooru::API::V0::_search_opts->%*; my %search_opts = Pooru::API::V0::_search_opts->%*;
sub _list_no_tags ($self, $page) sub _list_no_tags ($self, $page)
@ -64,7 +66,7 @@ sub list ($self)
status => 400, status => 400,
) if $v->has_error; ) if $v->has_error;
my @tags = split(" ", $v->optional("tags")->param // ""); my @tags = uniq split(" ", $v->optional("tags")->param // "");
return $self->render( return $self->render(
json => {error => "Invalid tags."}, json => {error => "Invalid tags."},
status => 400, status => 400,