From 09917e3286dfb6b15d8bcde65364d1c0ff3d2b81 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Sun, 18 Jan 2015 21:06:01 +0100 Subject: [PATCH] Switch get_peer_role to the new api handler --- lib/Vroom/Constants.pm | 3 ++- public/js/vroom.js | 11 ++++++++--- vroom.pl | 23 ++++++++++++----------- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/lib/Vroom/Constants.pm b/lib/Vroom/Constants.pm index 6b2b3d6..970d235 100644 --- a/lib/Vroom/Constants.pm +++ b/lib/Vroom/Constants.pm @@ -168,7 +168,8 @@ use constant API_ACTIONS => { participant => { ping => 1, authenticate => 1, - get_room_info => 1 + get_room_info => 1, + get_peer_role => 1 } }; diff --git a/public/js/vroom.js b/public/js/vroom.js index 738b663..67665ea 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -588,10 +588,15 @@ function initVroom(room) { // Get the role of a peer function getPeerRole(id){ $.ajax({ + url: rootUrl + 'api', data: { - action: 'getPeerRole', - room: roomName, - id: id + req: JSON.stringify({ + action: 'get_peer_role', + param: { + room: roomName, + peer_id: id + } + }) }, error: function(data){ $.notify(locale.ERROR_OCCURRED, 'error'); diff --git a/vroom.pl b/vroom.pl index 26fd015..95db0f9 100755 --- a/vroom.pl +++ b/vroom.pl @@ -1465,6 +1465,18 @@ any '/api' => sub { }, ); } + # Return the role of a peer + elsif ($req->{action} eq 'get_peer_role'){ + my $peer_id = $req->{param}->{peer_id}; + my $role = $self->get_peer_role({room => $room->{name}, peer_id => $peer_id}); + return $self->render( + json => { + role => $role, + status => 'success' + } + ); + } + }; # Catch all route: if nothing else match, it's the name of a room @@ -1604,17 +1616,6 @@ post '/*jsapi' => { jsapi => [qw(jsapi admin/jsapi)] } => sub { }, ); } - # Return the role of a peer - elsif ($action eq 'getPeerRole'){ - my $id = $self->param('id'); - my $role = $self->get_peer_role({room => $room, peer_id => $id}); - return $self->render( - json => { - role => $role, - status => 'success' - } - ); - } # Add a new email for notifications when someone joins elsif ($action eq 'emailNotification'){ my $email = $self->param('email');