Switch delete_room to the new api

master
Daniel Berteaud 10 years ago
parent 1c8217e208
commit bbf4eee3df
  1. 3
      lib/Vroom/Constants.pm
  2. 7
      public/js/vroom.js
  3. 35
      vroom.pl

@ -167,7 +167,8 @@ use constant API_ACTIONS => {
set_ask_for_name => 1,
email_notification => 1,
promote_peer => 1,
wipe_data => 1
wipe_data => 1,
delete_room => 1
},
participant => {
ping => 1,

@ -2306,9 +2306,14 @@ function initVroom(room) {
webrtc.sendToAll('terminate_room', {});
wipeRoomData();
$.ajax({
url: rootUrl + 'api',
data: {
action: 'deleteRoom',
req: JSON.stringify({
action: 'delete_room',
param: {
room: roomName
}
})
},
async: false,
error: function(data) {

@ -1617,6 +1617,23 @@ any '/api' => sub {
}
);
}
# Delete a room
elsif ($req->{action} eq 'delete_room'){
if ($self->delete_room($room->{name})){
return $self->render(
json => {
msg => $self->l('ROOM_DELETED'),
status => 'success'
}
);
}
return $self->render(
json => {
msg => $self->l('ERROR_OCCURRED'),
status => 'error'
}
);
}
};
# Catch all route: if nothing else match, it's the name of a room
@ -1756,24 +1773,6 @@ post '/*jsapi' => { jsapi => [qw(jsapi admin/jsapi)] } => sub {
},
);
}
# delete the room
elsif ($action eq 'deleteRoom'){
my $status = 'error';
my $msg = $self->l('ERROR_OCCURRED');
if ($prefix ne 'admin' && $self->session($room)->{role} ne 'owner'){
$msg = $self->l('NOT_ALLOWED');
}
elsif ($self->delete_room($room)){
$msg = $self->l('ROOM_DELETED');
$status = 'success';
}
return $self->render(
json => {
msg => $msg,
status => $status
}
);
}
};
# use the templates defined in the config

Loading…
Cancel
Save