Switch get_pad_session to the new api handler

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

@ -170,11 +170,12 @@ use constant API_ACTIONS => {
wipe_data => 1
},
participant => {
ping => 1,
authenticate => 1,
get_room_info => 1,
get_peer_role => 1,
join => 1
ping => 1,
authenticate => 1,
get_room_info => 1,
get_peer_role => 1,
join => 1,
get_padd_session => 1
}
};

@ -1450,9 +1450,14 @@ function initVroom(room) {
wipeChatHistory();
if (etherpad.enabled){
$.ajax({
url: rootUrl + 'api',
data: {
action: 'padSession',
room: roomName,
req: JSON.stringify({
action: 'get_pad_session',
param: {
room: roomName
}
})
},
error: function(data) {
$.notify(locale.ERROR_OCCURRED, 'error');

@ -1600,6 +1600,23 @@ any '/api' => sub {
}
);
}
# Get a new etherpad session
elsif ($req->{action} eq 'get_pad_session'){
if ($self->create_etherpad_session($room->{name})){
return $self->render(
json => {
status => 'success',
msg => $self->l('SESSION_CREATED')
}
);
}
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
@ -1739,26 +1756,6 @@ post '/*jsapi' => { jsapi => [qw(jsapi admin/jsapi)] } => sub {
},
);
}
elsif ($action eq 'padSession'){
my $status = 'error';
my $msg = $self->l('ERROR_OCCURRED');
if ($self->session($room)->{role} !~ m/^owner|participant$/){
$msg = $self->l('NOT_ALLOWED');
}
elsif (!$ec){
$msg = 'NOT_ENABLED';
}
elsif ($self->create_etherpad_session($room)){
$status = 'success';
$msg = '';
}
return $self->render(
json => {
msg => $msg,
status => $status
}
);
}
# delete the room
elsif ($action eq 'deleteRoom'){
my $status = 'error';

Loading…
Cancel
Save