diff --git a/lib/Vroom/Constants.pm b/lib/Vroom/Constants.pm index 7aef8c2..8dafe3c 100644 --- a/lib/Vroom/Constants.pm +++ b/lib/Vroom/Constants.pm @@ -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 } }; diff --git a/public/js/vroom.js b/public/js/vroom.js index 57e55ec..1f6cb35 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -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'); diff --git a/vroom.pl b/vroom.pl index f2bc4bc..2419fb7 100755 --- a/vroom.pl +++ b/vroom.pl @@ -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';