From fdb2840451314e0721b8ffb7bf61467bf41b6f93 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Wed, 18 Jun 2014 13:38:36 +0200 Subject: [PATCH] Update activity timestamp for each peer when they ping a room --- public/vroom.pl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/public/vroom.pl b/public/vroom.pl index ce5761b..14e8762 100755 --- a/public/vroom.pl +++ b/public/vroom.pl @@ -397,9 +397,12 @@ helper delete_room => sub { helper ping_room => sub { my $self = shift; my ($name) = @_; - return undef unless ( %{ $self->get_room($name) }); - my $sth = eval { $self->db->prepare("UPDATE `rooms` SET `activity_timestamp`=? WHERE `name`=?;") } || return undef; - $sth->execute(time(),$name) || return undef; + my $data = $self->get_room($name); + return undef unless ($data); + my $sth = eval { $self->db->prepare("UPDATE `rooms` SET `activity_timestamp`=? WHERE `id`=?;") } || return undef; + $sth->execute(time(),$data->{id}) || return undef; + $sth = eval { $self->db->prepare("UPDATE `participants` SET `activity_timestamp`=? WHERE `id`=? AND `participant`=?;") } || return undef; + $sth->execute(time(),$data->{id},$self->session('name')) || return undef; $self->app->log->debug($self->session('name') . " pinged the room $name"); return 1; };