From e00e0f7605f809abf0ce512c41e9f3e5671870c9 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 15 May 2014 10:40:40 +0200 Subject: [PATCH] Cleanup the ping action handler --- public/vroom.pl | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/public/vroom.pl b/public/vroom.pl index 83b0f11..1d94296 100755 --- a/public/vroom.pl +++ b/public/vroom.pl @@ -529,27 +529,23 @@ post '/action' => sub { ); } elsif ($action eq 'ping'){ + my $status = 'error'; + my $msg = 'ERROR_OCCURED'; my $res = $self->ping_room($room); # Cleanup expired rooms every ~10 pings if ((int (rand 100)) <= 10){ $self->delete_rooms; } - if (!$res){ - return $self->render( - json => { - msg => $self->l('ERROR_OCCURED'), - status => 'error' - }, - ); - } - else{ - return $self->render( - json => { - msg => '', - status => 'success' - } - ); + if ($res){ + $status = 'success'; + $msg = ''; } + return $self->render( + json => { + msg => $msg, + status => $status + } + ); } elsif ($action eq 'setPassword'){ my $pass = $self->param('password');