From 5240daddd1ce18a55f3117111b1eace2216cbad2 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 16 Oct 2014 21:47:35 +0200 Subject: [PATCH] Simplify get_peer_role --- vroom.pl | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/vroom.pl b/vroom.pl index c445bdf..9371345 100755 --- a/vroom.pl +++ b/vroom.pl @@ -422,19 +422,16 @@ helper get_peer_role => sub { LIMIT 1'); }; if ($@){ - return {msg => $@}; + return 0; } $sth->execute($data->{peer_id},$data->{room}); if ($sth->err){ - return {msg => "DB Error: " . $sth->errstr . " (code " . $sth->err . ")"}; + return 0; } my $role; $sth->bind_columns(\$role); $sth->fetch; - return { - ok => 1, - data => $role - }; + return $role; }; # Promote a peer to owner @@ -1532,7 +1529,7 @@ post '/*action' => [action => [qw/action admin\/action/]] => sub { my $id = $self->param('id'); my %emailNotif; if ($self->session($room) && $self->session($room)->{role}){ - if ($self->session($room)->{role} ne 'owner' && $self->get_peer_role({room => $room, peer_id => $id})->{data} eq 'owner'){ + if ($self->session($room)->{role} ne 'owner' && $self->get_peer_role({room => $room, peer_id => $id}) eq 'owner'){ $self->session($room)->{role} = 'owner'; } my $res = $self->set_peer_role({