Switch join action to the new api handler

master
Daniel Berteaud 10 years ago
parent 2dc0ed116a
commit f181eb6406
  1. 3
      lib/Vroom/Constants.pm
  2. 5
      public/js/vroom.js
  3. 45
      vroom.pl

@ -171,7 +171,8 @@ use constant API_ACTIONS => {
ping => 1, ping => 1,
authenticate => 1, authenticate => 1,
get_room_info => 1, get_room_info => 1,
get_peer_role => 1 get_peer_role => 1,
join => 1
} }
}; };

@ -1495,10 +1495,15 @@ function initVroom(room) {
// we send it. Not that I like sending this kind of data to the server // we send it. Not that I like sending this kind of data to the server
// but it's needed for email notifications // but it's needed for email notifications
$.ajax({ $.ajax({
url: rootUrl + 'api',
data: { data: {
req: JSON.stringify({
action: 'join', action: 'join',
param: {
room: roomName, room: roomName,
name: (peers.local.hasName) ? peers.local.displayName : '' name: (peers.local.hasName) ? peers.local.displayName : ''
}
})
}, },
error: function(data) { error: function(data) {
$.notify(locale.ERROR_OCCURRED, 'error'); $.notify(locale.ERROR_OCCURRED, 'error');

@ -1541,7 +1541,28 @@ any '/api' => sub {
} }
); );
} }
# Notify the backend when we join a room
elsif ($req->{action} eq 'join'){
my $name = $req->{param}->{name} || '';
my $subj = sprintf($self->l('s_JOINED_ROOM_s'), ($name eq '') ? $self->l('SOMEONE') : $name, $room);
# Send notifications
my $recipients = $self->get_notification($room);
foreach my $rcpt (keys %{$recipients}){
my $sent = $self->mail(
to => $recipients->{$rcpt}->{email},
subject => $subj,
data => $self->render_mail('notification',
room => $room->{name},
name => $name
)
);
}
return $self->render(
json => {
status => 'success'
}
);
}
}; };
# 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
@ -1681,28 +1702,6 @@ post '/*jsapi' => { jsapi => [qw(jsapi admin/jsapi)] } => sub {
}, },
); );
} }
# New participant joined the room
elsif ($action eq 'join'){
my $name = $self->param('name') || '';
my $subj = sprintf($self->l('s_JOINED_ROOM_s'), ($name eq '') ? $self->l('SOMEONE') : $name, $room);
# Send notifications
my $recipients = $self->get_notification($room);
foreach my $rcpt (keys %{$recipients}){
my $sent = $self->mail(
to => $recipients->{$rcpt}->{email},
subject => $subj,
data => $self->render_mail('notification',
room => $room,
name => $name
)
);
}
return $self->render(
json => {
status => 'success'
}
);
}
# A participant is being promoted to the owner status # A participant is being promoted to the owner status
elsif ($action eq 'promote'){ elsif ($action eq 'promote'){
my $peer = $self->param('peer'); my $peer = $self->param('peer');

Loading…
Cancel
Save