HTTP codes in promote_peer API call

master
Daniel Berteaud 10 years ago
parent 642ebd1afc
commit 5645ff14c7
  1. 11
      public/js/vroom.js
  2. 16
      vroom.pl

@ -1069,17 +1069,18 @@ function initVroom(room) {
}) })
}, },
error: function(data) { error: function(data) {
data = data.responseJSON;
if (data.msg){
$.notify(data.msg, 'error');
}
else{
$.notify(locale.ERROR_OCCURRED, 'error'); $.notify(locale.ERROR_OCCURRED, 'error');
}
}, },
success: function(data) { success: function(data) {
if (data.status == 'success' && data.msg){
webrtc.sendToAll('owner_promoted', {peer: id}); webrtc.sendToAll('owner_promoted', {peer: id});
$.notify(data.msg, 'success'); $.notify(data.msg, 'success');
} }
else if (data.msg){
$.notify(data.msg, 'error');
}
}
}); });
suspendButton($('#actionPromote_' + id)); suspendButton($('#actionPromote_' + id));
} }

@ -1742,7 +1742,17 @@ any '/api' => sub {
# Promote a participant to be owner of a room # Promote a participant to be owner of a room
elsif ($req->{action} eq 'promote_peer'){ elsif ($req->{action} eq 'promote_peer'){
my $peer_id = $req->{param}->{peer_id}; my $peer_id = $req->{param}->{peer_id};
if ($peer_id && $self->promote_peer({room => $room->{name}, peer_id => $peer_id})){ if (!$peer){
return $self->render(
json => {
status => 'error',
msg => $self->l('ERROR_PEER_ID_MISSING'),
err => 'ERROR_PEER_ID_MISSING'
},
status => 400
);
}
elsif ($self->promote_peer({room => $room->{name}, peer_id => $peer_id})){
return $self->render( return $self->render(
json => { json => {
status => 'success', status => 'success',
@ -1754,7 +1764,9 @@ any '/api' => sub {
json => { json => {
status => 'error', status => 'error',
msg => $self->l('ERROR_OCCURRED') msg => $self->l('ERROR_OCCURRED')
} err => 'ERROR_OCCURRED'
},
status => 503
); );
} }
# Wipe room data (chat history and etherpad content) # Wipe room data (chat history and etherpad content)

Loading…
Cancel
Save