Switch set_ask_for_name to the new api handler

master
Daniel Berteaud 10 years ago
parent 09917e3286
commit 2e4d09ad0e
  1. 3
      lib/Vroom/Constants.pm
  2. 15
      public/js/vroom.js
  3. 39
      vroom.pl

@ -163,7 +163,8 @@ use constant API_ACTIONS => {
lock_room => 1, lock_room => 1,
unlock_room => 1, unlock_room => 1,
set_join_password => 1, set_join_password => 1,
set_owner_password => 1 set_owner_password => 1,
set_ask_for_name => 1
}, },
participant => { participant => {
ping => 1, ping => 1,

@ -1718,12 +1718,17 @@ function initVroom(room) {
// Force participants to set a name // Force participants to set a name
$('#askForNameButton').change(function() { $('#askForNameButton').change(function() {
var type = ($(this).is(":checked")) ? 'set':'unset'; var set = ($(this).is(":checked")) ? 'on':'off';
$.ajax({ $.ajax({
url: rootUrl + 'api',
data: { data: {
action: 'askForName', req: JSON.stringify({
type: type, action: 'set_ask_for_name',
param: {
set: set,
room: roomName room: roomName
}
})
}, },
error: function(data) { error: function(data) {
$.notify(locale.ERROR_OCCURRED, 'error'); $.notify(locale.ERROR_OCCURRED, 'error');
@ -1731,13 +1736,13 @@ function initVroom(room) {
success: function(data) { success: function(data) {
if (data.status == 'success'){ if (data.status == 'success'){
$.notify(data.msg, 'info'); $.notify(data.msg, 'info');
if (type === 'set'){ if (set === 'on'){
$('#askForNameLabel').addClass('btn-danger active'); $('#askForNameLabel').addClass('btn-danger active');
} }
else{ else{
$('#askForNameLabel').removeClass('btn-danger active'); $('#askForNameLabel').removeClass('btn-danger active');
} }
webrtc.sendToAll('ask_for_name', {action: type}); webrtc.sendToAll('ask_for_name', {action: set});
} }
else{ else{
$.notify(data.msg, 'error'); $.notify(data.msg, 'error');

@ -1390,6 +1390,25 @@ any '/api' => sub {
} }
); );
} }
# Set/unset askForName
elsif ($req->{action} eq 'set_ask_for_name'){
my $set = $req->{param}->{set};
$room->{ask_for_name} = ($set eq 'on') ? 1 : 0;
if ($self->modify_room($room)){
return $self->render(
json => {
status => 'success',
msg => $self->l(($set eq 'on') ? 'FORCE_DISPLAY_NAME' : 'NAME_WONT_BE_ASKED')
}
);
}
return $self->render(
json => {
msg => $self->l('ERROR_OCCURRED'),
status => 'error'
}
);
}
elsif ($req->{action} eq 'authenticate'){ elsif ($req->{action} eq 'authenticate'){
my $pass = $req->{param}->{'password'}; my $pass = $req->{param}->{'password'};
# Auth succeed ? lets promote him to owner of the room # Auth succeed ? lets promote him to owner of the room
@ -1643,26 +1662,6 @@ post '/*jsapi' => { jsapi => [qw(jsapi admin/jsapi)] } => sub {
} }
); );
} }
# Set/unset askForName
elsif ($action eq 'askForName'){
my $type = $self->param('type');
my $status = 'error';
my $msg = $self->l('ERROR_OCCURRED');
if ($prefix ne 'admin' && $self->session($room)->{role} ne 'owner'){
$msg = $self->l('NOT_ALLOWED');
}
$data->{ask_for_name} = ($type eq 'set') ? 1 : 0;
if ($self->modify_room($data)){
$status = 'success';
$msg = $self->l(($type eq 'set') ? 'FORCE_DISPLAY_NAME' : 'NAME_WONT_BE_ASKED');
}
return $self->render(
json => {
msg => $msg,
status => $status
}
);
}
# New participant joined the room # New participant joined the room
elsif ($action eq 'join'){ elsif ($action eq 'join'){
my $name = $self->param('name') || ''; my $name = $self->param('name') || '';

Loading…
Cancel
Save