From bbf4eee3dfcec4405a10619d01a67d74edcc63df Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Sun, 18 Jan 2015 22:51:19 +0100 Subject: [PATCH] Switch delete_room to the new api --- lib/Vroom/Constants.pm | 3 ++- public/js/vroom.js | 9 +++++++-- vroom.pl | 35 +++++++++++++++++------------------ 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/lib/Vroom/Constants.pm b/lib/Vroom/Constants.pm index 8dafe3c..cc234e6 100644 --- a/lib/Vroom/Constants.pm +++ b/lib/Vroom/Constants.pm @@ -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, diff --git a/public/js/vroom.js b/public/js/vroom.js index 1f6cb35..6c55bd6 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -2306,9 +2306,14 @@ function initVroom(room) { webrtc.sendToAll('terminate_room', {}); wipeRoomData(); $.ajax({ + url: rootUrl + 'api', data: { - action: 'deleteRoom', - room: roomName + req: JSON.stringify({ + action: 'delete_room', + param: { + room: roomName + } + }) }, async: false, error: function(data) { diff --git a/vroom.pl b/vroom.pl index 2419fb7..139dbda 100755 --- a/vroom.pl +++ b/vroom.pl @@ -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