Simplify has_joined

master
Daniel Berteaud 10 years ago
parent 3fc530292c
commit 88c5d3ccb2
  1. 11
      vroom.pl

@ -468,19 +468,16 @@ helper has_joined => sub {
AND `p`.`participant`=?'); AND `p`.`participant`=?');
}; };
if ($@){ if ($@){
return {msg => $@}; return 0;
} }
$sth->execute($data->{room},$data->{name}); $sth->execute($data->{room},$data->{name});
if ($sth->err){ if ($sth->err){
return {msg => "DB Error: " . $sth->errstr . " (code " . $sth->err . ")"}; return 0;
} }
my $num; my $num;
$sth->bind_columns(\$num); $sth->bind_columns(\$num);
$sth->fetch; $sth->fetch;
return { return ($num == 1) ? 1 : 0 ;
ok => 1,
data => ($num == 1) ? 1 : 0
}
}; };
# Purge disconnected participants from the DB # Purge disconnected participants from the DB
@ -1289,7 +1286,7 @@ post '/*action' => [action => [qw/action admin\/action/]] => sub {
} }
# Refuse any action from non members of the room # Refuse any action from non members of the room
if ($prefix ne 'admin' && (!$self->session('name') || if ($prefix ne 'admin' && (!$self->session('name') ||
!$self->has_joined({name => $self->session('name'), room => $room})->{data} || !$self->has_joined({name => $self->session('name'), room => $room}) ||
!$self->session($room) || !$self->session($room) ||
!$self->session($room)->{role})){ !$self->session($room)->{role})){
return $self->render( return $self->render(

Loading…
Cancel
Save