Switch promote_peer to the new api handler

master
Daniel Berteaud 10 years ago
parent f181eb6406
commit b1e37a673f
  1. 3
      lib/Vroom/Constants.pm
  2. 7
      public/js/vroom.js
  3. 40
      vroom.pl

@ -165,7 +165,8 @@ use constant API_ACTIONS => {
set_join_password => 1, set_join_password => 1,
set_owner_password => 1, set_owner_password => 1,
set_ask_for_name => 1, set_ask_for_name => 1,
email_notification => 1 email_notification => 1,
promote_peer => 1
}, },
participant => { participant => {
ping => 1, ping => 1,

@ -958,10 +958,15 @@ function initVroom(room) {
function promotePeer(id){ function promotePeer(id){
if (peers[id] && peers[id].role != 'owner'){ if (peers[id] && peers[id].role != 'owner'){
$.ajax({ $.ajax({
url: rootUrl + 'api',
data: { data: {
action: 'promote', req: JSON.stringify({
action: 'promote_peer',
param: {
room: roomName, room: roomName,
peer: id peer: id
}
})
}, },
error: function(data) { error: function(data) {
$.notify(locale.ERROR_OCCURRED, 'error'); $.notify(locale.ERROR_OCCURRED, 'error');

@ -1563,6 +1563,24 @@ any '/api' => sub {
} }
); );
} }
# Promote a participant to be owner of a room
elsif ($req->{action} eq 'promote_peer'){
my $peer_id = $req->{param}->{peer_id};
if ($peer_id && $self->promote_peer({room => $room, peer_id => $peer_id})){
return $self->render(
json => {
status => 'success',
msg => $self->l('PEER_PROMOTED')
}
);
}
return $self->render(
json => {
msg => 'error',
status => $self->l('ERROR_OCCURRED')
}
);
}
}; };
# Catch all route: if nothing else match, it's the name of a room # Catch all route: if nothing else match, it's the name of a room
@ -1702,28 +1720,6 @@ post '/*jsapi' => { jsapi => [qw(jsapi admin/jsapi)] } => sub {
}, },
); );
} }
# A participant is being promoted to the owner status
elsif ($action eq 'promote'){
my $peer = $self->param('peer');
my $status = 'error';
my $msg = $self->l('ERROR_OCCURRED');
if (!$peer){
$msg = $self->l('ERROR_OCCURRED');
}
elsif ($self->session($room)->{role} ne 'owner'){
$msg = $self->l('NOT_ALLOWED');
}
elsif ($self->promote_peer({room => $room, peer_id => $peer})){
$status = 'success';
$msg = $self->l('PEER_PROMOTED');
}
return $self->render(
json => {
msg => $msg,
status => $status
}
);
}
# Wipe etherpad data # Wipe etherpad data
elsif ($action eq 'wipeData'){ elsif ($action eq 'wipeData'){
my $status = 'error'; my $status = 'error';

Loading…
Cancel
Save