@ -193,6 +193,34 @@ helper get_participants => sub {
return@res;
};
# Set the role of a peer
helperset_peer_role=>sub{
my$self=shift;
my($room,$name,$id,$role)=@_;
# Check if this ID isn't the one from another peer first
my$sth=eval{$self->db->prepare("SELECT * FROM participants WHERE peer_id=? AND participant!=? AND id IN (SELECT id FROM rooms WHERE name=?)")}||returnundef;
$sth->execute($id,$name,$room)||returnundef;
returnundefif($sth->rows>0);
$sth=eval{$self->db->prepare("UPDATE participants SET peer_id=?,role=? WHERE participant=? AND id IN (SELECT id FROM rooms WHERE name=?)")}||returnundef;