From 2f3ad038c107b64644dfbd3572184c28c27224af Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 16 Oct 2014 21:25:15 +0200 Subject: [PATCH] Simplify get_room_by_id --- vroom.pl | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/vroom.pl b/vroom.pl index 0d1465f..bcc138e 100755 --- a/vroom.pl +++ b/vroom.pl @@ -230,16 +230,13 @@ helper get_room_by_id => sub { WHERE `id`=?'); }; if ($@){ - return {msg => $@}; + return 0; } $sth->execute($id); if ($sth->err){ - return {msg => "DB Error: " . $sth->errstr . " (code " . $sth->err . ")"}; + return 0; } - return { - ok => 1, - data => $sth->fetchall_hashref('id')->{$id} - }; + return $sth->fetchall_hashref('id')->{$id}; }; # Update a room, take a room object as a hashref @@ -1078,7 +1075,7 @@ get '/invitation' => sub { # Delete expired invitation now $self->delete_invitations; my $invite = $self->get_invitation($inviteId); - my $room = $self->get_room_by_id($invite->{room_id})->{data}; + my $room = $self->get_room_by_id($invite->{room_id}); if (!$invite || !$room){ return $self->render('error', err => 'ERROR_INVITATION_INVALID',