🔀 Merge branch 'fix-mojo-user-agent' into 'development'

Fix use of deprecated method success in Mojo::Transaction

See merge request fiat-tux/hat-softwares/lutim!97
This commit is contained in:
Luc Didry
2025-09-01 18:57:08 +02:00

View File

@@ -313,8 +313,8 @@ sub add {
sleep($c->config->{anti_flood_delay}); sleep($c->config->{anti_flood_delay});
} }
my $ua = Mojo::UserAgent->new; my $ua = Mojo::UserAgent->new;
my $tx = $ua->get($file_url => {DNT => 1}); my $res = $ua->get($file_url => {DNT => 1})->result;
if (my $res = $tx->success) { if ($res->is_success) {
$file_url = url_unescape $file_url; $file_url = url_unescape $file_url;
$file_url =~ m#^.*/([^/?]*)\??.*$#; $file_url =~ m#^.*/([^/?]*)\??.*$#;
my $filename = $1; my $filename = $1;
@@ -325,8 +325,8 @@ sub add {
filename => $filename filename => $filename
); );
$c->app->{wait_for_it}->{$ip} = time; $c->app->{wait_for_it}->{$ip} = time;
} elsif ($tx->res->is_limit_exceeded) { } elsif ($res->is_limit_exceeded) {
my $msg = $c->l('The file exceed the size limit (%1)', $tx->res->max_message_size); my $msg = $c->l('The file exceed the size limit (%1)', $res->max_message_size);
if (defined($c->param('format')) && $c->param('format') eq 'json') { if (defined($c->param('format')) && $c->param('format') eq 'json') {
return $c->render( return $c->render(
json => { json => {
@@ -344,7 +344,7 @@ sub add {
} }
} else { } else {
my $msg = $c->l('An error occured while downloading the image.'); my $msg = $c->l('An error occured while downloading the image.');
$c->app->log->warn('[DOWNLOAD ERROR]'.$c->dumper($tx->error)); $c->app->log->warn('[DOWNLOAD ERROR]'.$c->dumper($res->message));
if (defined($c->param('format')) && $c->param('format') eq 'json') { if (defined($c->param('format')) && $c->param('format') eq 'json') {
return $c->render( return $c->render(
json => { json => {