Only check invitation response if required

Will greatly reduce number of DB queries
master
Daniel Berteaud 10 years ago
parent c22ed01a86
commit de1cbae578
  1. 5
      vroom.pl

@ -1003,6 +1003,7 @@ websocket '/socket.io/:ver/websocket/:id' => sub {
# Associate the unique ID and name # Associate the unique ID and name
$peers->{$id}->{id} = $self->session('id'); $peers->{$id}->{id} = $self->session('id');
$peers->{$id}->{name} = $self->session('name'); $peers->{$id}->{name} = $self->session('name');
$peers->{$id}->{check_invitations} = 1;
# Register the i18n stash, for localization will be available in the main IOLoop # Register the i18n stash, for localization will be available in the main IOLoop
# Outside of Mojo controller # Outside of Mojo controller
$peers->{$id}->{i18n} = $self->stash->{i18n}; $peers->{$id}->{i18n} = $self->stash->{i18n};
@ -1160,7 +1161,7 @@ Mojo::IOLoop->recurring( 3 => sub {
$peers->{$id}->{socket}->finish; $peers->{$id}->{socket}->finish;
delete $peers->{$id}; delete $peers->{$id};
} }
else { elsif ($peers->{$id}->{check_invitations}) {
my $invitations = app->get_invitation_list($peers->{$id}->{id}); my $invitations = app->get_invitation_list($peers->{$id}->{id});
foreach my $invit (keys %{$invitations}){ foreach my $invit (keys %{$invitations}){
my $msg = ''; my $msg = '';
@ -1186,6 +1187,7 @@ Mojo::IOLoop->recurring( 3 => sub {
} }
) )
); );
delete $peers->{$id}->{check_invitations};
} }
# Send the heartbeat # Send the heartbeat
$peers->{$id}->{socket}->send(Protocol::SocketIO::Message->new( type => 'heartbeat' )) $peers->{$id}->{socket}->send(Protocol::SocketIO::Message->new( type => 'heartbeat' ))
@ -1550,6 +1552,7 @@ any '/api' => sub {
} }
$self->app->log->info("Email invitation to join room " . $req->{param}->{room} . " sent to " . $addr); $self->app->log->info("Email invitation to join room " . $req->{param}->{room} . " sent to " . $addr);
} }
$peers->{$self->session('peer_id')}->{check_invitations} = 1;
return $self->render( return $self->render(
json => { json => {
msg => sprintf($self->l('INVITE_SENT_TO_s'), join("\n", @$rcpts)), msg => sprintf($self->l('INVITE_SENT_TO_s'), join("\n", @$rcpts)),

Loading…
Cancel
Save