Stop using the OO Mojo::JSON interface

as it's deprecated and removed from Mojolicious 6
master
Daniel Berteaud 10 years ago
parent 442a21f4b5
commit c14ab9f617
  1. 14
      vroom.pl

@ -1412,15 +1412,13 @@ any '/api' => sub {
my $self = shift; my $self = shift;
$self->purge_api_keys; $self->purge_api_keys;
my $token = $self->req->headers->header('X-VROOM-API-Key'); my $token = $self->req->headers->header('X-VROOM-API-Key');
my $json = Mojo::JSON->new; my $req = Mojo::JSON::decode_json($self->param('req'));
my $req = $json->decode($self->param('req'));
my $err = $json->error;
my $room; my $room;
if ($err || !$req->{action} || !$req->{param}){ if (!$req->{action} || !$req->{param}){
return $self->render( return $self->render(
json => { json => {
msg => $err, msg => $self->l('ERROR_OCCURRED'),
err => $err err => 'ERROR_OCCURRED'
}, },
status => 503 status => 503
); );
@ -1664,10 +1662,10 @@ any '/api' => sub {
$room->{max_members} = $req->{param}->{max_members}; $room->{max_members} = $req->{param}->{max_members};
# Room persistence can only be set by admins # Room persistence can only be set by admins
if ($req->{param}->{persistent} ne '' && $self->key_can_do_this(token => $token, action => 'set_persistent')){ if ($req->{param}->{persistent} ne '' && $self->key_can_do_this(token => $token, action => 'set_persistent')){
$room->{persistent} = ($req->{param}->{persistent} eq Mojo::JSON->true) ? '1' : '0'; $room->{persistent} = ($req->{param}->{persistent} eq Mojo::JSON::true) ? '1' : '0';
} }
foreach my $pass (qw/join_password owner_password/){ foreach my $pass (qw/join_password owner_password/){
if ($req->{param}->{$pass} eq Mojo::JSON->false){ if ($req->{param}->{$pass} eq Mojo::JSON::false){
$room->{$pass} = undef; $room->{$pass} = undef;
} }
elsif ($req->{param}->{$pass} ne ''){ elsif ($req->{param}->{$pass} ne ''){

Loading…
Cancel
Save