Simplify get_room_by_id

master
Daniel Berteaud 10 years ago
parent f911706ddd
commit 2f3ad038c1
  1. 11
      vroom.pl

@ -230,16 +230,13 @@ helper get_room_by_id => sub {
WHERE `id`=?'); WHERE `id`=?');
}; };
if ($@){ if ($@){
return {msg => $@}; return 0;
} }
$sth->execute($id); $sth->execute($id);
if ($sth->err){ if ($sth->err){
return {msg => "DB Error: " . $sth->errstr . " (code " . $sth->err . ")"}; return 0;
} }
return { return $sth->fetchall_hashref('id')->{$id};
ok => 1,
data => $sth->fetchall_hashref('id')->{$id}
};
}; };
# Update a room, take a room object as a hashref # Update a room, take a room object as a hashref
@ -1078,7 +1075,7 @@ get '/invitation' => sub {
# Delete expired invitation now # Delete expired invitation now
$self->delete_invitations; $self->delete_invitations;
my $invite = $self->get_invitation($inviteId); 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){ if (!$invite || !$room){
return $self->render('error', return $self->render('error',
err => 'ERROR_INVITATION_INVALID', err => 'ERROR_INVITATION_INVALID',

Loading…
Cancel
Save