Switch wipe_data to the new api handler

master
Daniel Berteaud 10 years ago
parent b1e37a673f
commit f5ab168d77
  1. 3
      lib/Vroom/Constants.pm
  2. 11
      public/js/vroom.js
  3. 42
      vroom.pl

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

@ -1062,19 +1062,24 @@ function initVroom(room) {
function wipeRoomData(){ function wipeRoomData(){
if (etherpad.enabled){ if (etherpad.enabled){
$.ajax({ $.ajax({
url: rootUrl + 'api',
data: { data: {
action: 'wipeData', req: JSON.stringify({
action: 'wipe_data',
param: {
room: roomName room: roomName
}
})
}, },
async: false, async: false,
error: function(data){ error: function(data){
$.notify(locale.ERROR_OCCURRED, 'error'); $.notify(locale.ERROR_OCCURRED, 'error');
}, },
success: function(data){ success: function(data){
if (data.status && data.status == 'success' && $('#etherpadContainer').html() != ''){ if (data.status && data.status === 'success' && $('#etherpadContainer').html() != ''){
loadEtherpadIframe(); loadEtherpadIframe();
} }
else if (data.msg){ else if (data.status !== 'success' && data.msg){
$.notify(data.msg, 'error'); $.notify(data.msg, 'error');
} }
} }

@ -1581,6 +1581,25 @@ any '/api' => sub {
} }
); );
} }
# Wipe room data (chat history and etherpad content)
elsif ($req->{action} eq 'wipe_data'){
if (!$ec || ($ec->delete_pad($room->{etherpad_group} . '$' . $room->{name}) &&
$self->create_pad($room->{name}) &&
$self->create_etherpad_session($room->{name}))){
return $self->render(
json => {
status => 'success',
msg => $self->l('DATA_WIPED')
}
);
}
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 # Catch all route: if nothing else match, it's the name of a room
@ -1720,29 +1739,6 @@ post '/*jsapi' => { jsapi => [qw(jsapi admin/jsapi)] } => sub {
}, },
); );
} }
# Wipe etherpad data
elsif ($action eq 'wipeData'){
my $status = 'error';
my $msg = $self->l('ERROR_OCCURRED');
if ($self->session($room)->{role} ne 'owner'){
$msg = $self->l('NOT_ALLOWED');
}
elsif (!$ec){
$msg = 'NOT_ENABLED';
}
elsif ($ec->delete_pad($data->{etherpad_group} . '$' . $room) &&
$self->create_pad($room) &&
$self->create_etherpad_session($room)){
$status = 'success';
$msg = '';
}
return $self->render(
json => {
msg => $msg,
status => $status
}
);
}
elsif ($action eq 'padSession'){ elsif ($action eq 'padSession'){
my $status = 'error'; my $status = 'error';
my $msg = $self->l('ERROR_OCCURRED'); my $msg = $self->l('ERROR_OCCURRED');

Loading…
Cancel
Save