Remove the old api handler

Note that this breaks the admin interface, which will be rewritten
master
Daniel Berteaud 10 years ago
parent bbf4eee3df
commit 27337d4875
  1. 21
      public/js/vroom.js
  2. 47
      vroom.pl

@ -35,7 +35,7 @@ $.ajax({
// Default ajax setup
$.ajaxSetup({
url: rootUrl + 'jsapi',
url: rootUrl + 'api',
type: 'POST',
dataType: 'json',
headers: {
@ -46,7 +46,6 @@ $.ajaxSetup({
// Handle lang switch
$('#switch_lang').change(function(){
$.ajax({
url: rootUrl + 'api',
data: {
req: JSON.stringify({
action: 'switch_lang',
@ -98,7 +97,6 @@ function addNotifiedEmail(email){
function removeNotifiedEmail(email){
var id = escapeJqSelector(email.replace(/['"]/, '_').replace('\\\'', '\''));
$.ajax({
url: rootUrl + 'api',
data: {
req: JSON.stringify({
action: 'email_notification',
@ -527,7 +525,6 @@ function initVroom(room) {
// Get our role and other room settings from the server
function getRoomInfo(){
$.ajax({
url: rootUrl + 'api',
data: {
req: JSON.stringify({
action: 'get_room_info',
@ -593,7 +590,6 @@ function initVroom(room) {
// Get the role of a peer
function getPeerRole(id){
$.ajax({
url: rootUrl + 'api',
data: {
req: JSON.stringify({
action: 'get_peer_role',
@ -958,7 +954,6 @@ function initVroom(room) {
function promotePeer(id){
if (peers[id] && peers[id].role != 'owner'){
$.ajax({
url: rootUrl + 'api',
data: {
req: JSON.stringify({
action: 'promote_peer',
@ -1062,7 +1057,6 @@ function initVroom(room) {
function wipeRoomData(){
if (etherpad.enabled){
$.ajax({
url: rootUrl + 'api',
data: {
req: JSON.stringify({
action: 'wipe_data',
@ -1450,7 +1444,6 @@ function initVroom(room) {
wipeChatHistory();
if (etherpad.enabled){
$.ajax({
url: rootUrl + 'api',
data: {
req: JSON.stringify({
action: 'get_pad_session',
@ -1510,7 +1503,6 @@ function initVroom(room) {
// we send it. Not that I like sending this kind of data to the server
// but it's needed for email notifications
$.ajax({
url: rootUrl + 'api',
data: {
req: JSON.stringify({
action: 'join',
@ -1611,7 +1603,6 @@ function initVroom(room) {
return;
}
$.ajax({
url: rootUrl + 'api',
data: {
req: JSON.stringify({
action: 'invite_email',
@ -1709,7 +1700,6 @@ function initVroom(room) {
$('#lockButton').change(function() {
var action = ($(this).is(":checked")) ? 'lock_room' : 'unlock_room';
$.ajax({
url: rootUrl + 'api',
data: {
req: JSON.stringify({
action: action,
@ -1745,7 +1735,6 @@ function initVroom(room) {
$('#askForNameButton').change(function() {
var set = ($(this).is(":checked")) ? 'on':'off';
$.ajax({
url: rootUrl + 'api',
data: {
req: JSON.stringify({
action: 'set_ask_for_name',
@ -1909,7 +1898,6 @@ function initVroom(room) {
event.preventDefault();
var pass = $('#authPass').val();
$.ajax({
url: rootUrl + 'api',
data: {
req: JSON.stringify({
action: 'authenticate',
@ -1949,7 +1937,6 @@ function initVroom(room) {
}
else{
$.ajax({
url: rootUrl + 'api',
data: {
req: JSON.stringify({
action: 'set_join_password',
@ -1986,7 +1973,6 @@ function initVroom(room) {
if (pass == pass2 && pass != ''){
$('#setJoinPassButton').addClass('disabled');
$.ajax({
url: rootUrl + 'api',
data: {
req: JSON.stringify({
action: 'set_join_password',
@ -2032,7 +2018,6 @@ function initVroom(room) {
}
else{
$.ajax({
url: rootUrl + 'api',
data: {
req: JSON.stringify({
action: 'set_owner_password',
@ -2067,7 +2052,6 @@ function initVroom(room) {
if (pass == pass2 && pass != ''){
$('#setOwnerPassButton').addClass('disabled');
$.ajax({
url: rootUrl + 'api',
data: {
req: JSON.stringify({
action: 'set_owner_password',
@ -2116,7 +2100,6 @@ function initVroom(room) {
$('#newEmailNotificationForm').submit(function(event){
event.preventDefault();
$.ajax({
url: rootUrl + 'api',
data: {
req: JSON.stringify({
action: 'email_notification',
@ -2306,7 +2289,6 @@ function initVroom(room) {
webrtc.sendToAll('terminate_room', {});
wipeRoomData();
$.ajax({
url: rootUrl + 'api',
data: {
req: JSON.stringify({
action: 'delete_room',
@ -2351,7 +2333,6 @@ function initVroom(room) {
// Used to detect inactive rooms
setInterval(function(){
$.ajax({
url: rootUrl + 'api',
data: {
req: JSON.stringify({
action: 'ping',

@ -97,7 +97,7 @@ helper valid_room_name => sub {
my ($name) = @_;
my $ret = {};
# A few names are reserved
my @reserved = qw(about help feedback feedback_thanks goodbye admin create localize jsapi api
my @reserved = qw(about help feedback feedback_thanks goodbye admin create localize api
missing dies password kicked invitation js css img fonts snd);
if ($name !~ m/^[\w\-]{1,49}$/ || grep { $name eq $_ } @reserved){
return 0;
@ -1730,51 +1730,6 @@ get '/:room' => sub {
);
};
# Route for various room actions
post '/*jsapi' => { jsapi => [qw(jsapi admin/jsapi)] } => sub {
my $self = shift;
my $action = $self->param('action');
my $prefix = ($self->stash('jsapi') eq 'admin/jsapi') ? 'admin' : 'room';
my $room = $self->param('room') || '';
# Refuse any action from non members of the room
if ($prefix ne 'admin' && (!$self->session('name') ||
!$self->has_joined({
name => $self->session('name'),
room => $room}) ||
!$self->session($room) ||
!$self->session($room)->{role})){
return $self->render(
json => {
msg => $self->l('ERROR_NOT_LOGGED_IN'),
status => 'error'
}
);
}
# Sanity check on the room name
if (!$self->valid_room_name($room)){
return $self->render(
json => {
msg => $self->l('ERROR_NAME_INVALID'),
status => 'error'
},
);
}
# Push the room name to the stash, just in case
$self->stash(room => $room);
# Gather room info from the DB
my $data = $self->get_room_by_name($room);
# Stop here if the room doesn't exist
if (!$data){
return $self->render(
json => {
msg => sprintf ($self->l('ERROR_ROOM_s_DOESNT_EXIST'), $room),
err => 'ERROR_ROOM_s_DOESNT_EXIST',
status => 'error'
},
);
}
};
# use the templates defined in the config
push @{app->renderer->paths}, 'templates/'.$config->{'interface.template'};
# Set the secret used to sign cookies

Loading…
Cancel
Save