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. 17
      public/js/vroom.js
  3. 39
      vroom.pl

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

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

Loading…
Cancel
Save