Switch set_persistent to the new API handler

master
Daniel Berteaud 10 years ago
parent 46a1c21388
commit 0a6e2d4f9b
  1. 3
      lib/Vroom/Constants.pm
  2. 4
      public/js/vroom.js
  3. 39
      vroom.pl

@ -155,7 +155,8 @@ use constant JS_STRINGS => qw(
# API actions # API actions
use constant API_ACTIONS => { use constant API_ACTIONS => {
admin => { admin => {
list_rooms => 1 list_rooms => 1,
set_persistent => 1
}, },
owner => { owner => {
invite_email => 1, invite_email => 1,

@ -380,8 +380,8 @@ function initManage(){
} }
} }
else if (param === 'persistentSwitch'){ else if (param === 'persistentSwitch'){
data.action = 'setPersistent'; data.action = 'set_persistent';
data.type = (state) ? 'set' : 'unset'; data.set = (state) ? 'on' : 'off';
sendAction(data,sw); sendAction(data,sw);
} }
// Something isn't implemented yet ? // Something isn't implemented yet ?

@ -1372,6 +1372,24 @@ any '/api' => sub {
} }
); );
} }
elsif ($req->{action} eq 'set_persistent'){
my $set = $self->param('set');
$room->{persistent} = ($set eq 'on') ? 1 : 0;
if ($self->modify_room($room)){
return $self->render(
json => {
status => 'success',
msg => $self->l(($set eq 'on') ? 'ROOM_NOW_PERSISTENT' : 'ROOM_NO_MORE_PERSISTENT')
}
);
}
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
@ -1546,27 +1564,6 @@ post '/*jsapi' => { jsapi => [qw(jsapi admin/jsapi)] } => sub {
); );
} }
# Handle persistence
elsif ($action eq 'setPersistent'){
my $type = $self->param('type');
my $status = 'error';
my $msg = $self->l('ERROR_OCCURRED');
# Only possible through /admin/action
if ($prefix ne 'admin'){
$msg = $self->l('NOT_ALLOWED');
}
$data->{persistent} = ($type eq 'set') ? 1 : 0;
if ($self->modify_room($data)){
$status = 'success';
$msg = $self->l(($type eq 'set') ? 'ROOM_NOW_PERSISTENT' : 'ROOM_NO_MORE_PERSISTENT');
}
return $self->render(
json => {
msg => $msg,
status => $status
}
);
}
# Return your role and various info about the room # Return your role and various info about the room
elsif ($action eq 'getRoomInfo'){ elsif ($action eq 'getRoomInfo'){
my $id = $self->param('id'); my $id = $self->param('id');

Loading…
Cancel
Save