Add a new setting to expire persistent rooms

Using a dedicated timeout, so you can set it very high, but still remove very old rooms
Fix #28
master
Daniel Berteaud 11 years ago
parent 883905af6a
commit 6517fb930a
  1. 6
      conf/vroom.conf.sample
  2. 8
      public/vroom.pl

@ -20,8 +20,12 @@ template => 'default',
secret => 'ChangeMe!', secret => 'ChangeMe!',
# App # App
# Rooms without any activity for that long will be destroyed # Rooms without any activity for that long (in seconds) will be destroyed
inactivityTimeout => 3600, inactivityTimeout => 3600,
# Inactivity timeout (in seconds) for persistent rooms
# 0 means they are not deleted. You can use a high number
# so that persistent rooms are kept long enough, but deleted when not used
persistentInactivityTimeout => 0,
logLevel => 'info', logLevel => 'info',
# ID of the Chrome extension for screen sharing # ID of the Chrome extension for screen sharing

@ -72,6 +72,7 @@ our $config = plugin Config => {
feedbackRecipient => 'admin@example.com', feedbackRecipient => 'admin@example.com',
template => 'default', template => 'default',
inactivityTimeout => 3600, inactivityTimeout => 3600,
persistentInactivityTimeout => 0,
logLevel => 'info', logLevel => 'info',
chromeExtensionId => 'ecicdpoejfllflombfanbhfpgcimjddn', chromeExtensionId => 'ecicdpoejfllflombfanbhfpgcimjddn',
sendmail => '/sbin/sendmail' sendmail => '/sbin/sendmail'
@ -193,6 +194,13 @@ helper delete_rooms => sub {
$self->db->do("DELETE FROM participants WHERE id IN (SELECT id FROM rooms WHERE activity_timestamp < $timeout AND persistent='0');"); $self->db->do("DELETE FROM participants WHERE id IN (SELECT id FROM rooms WHERE activity_timestamp < $timeout AND persistent='0');");
$self->db->do("DELETE FROM rooms WHERE activity_timestamp < $timeout AND persistent='0';"); $self->db->do("DELETE FROM rooms WHERE activity_timestamp < $timeout AND persistent='0';");
} || return undef; } || return undef;
if ($config->{persistentInactivityTimeout} && $config->{persistentInactivityTimeout} > 0){
eval {
my $timeout = time()-$config->{persistentInactivityTimeout};
$self->db->do("DELETE FROM participants WHERE id IN (SELECT id FROM rooms WHERE activity_timestamp < $timeout AND persistent='1');");
$self->db->do("DELETE FROM rooms WHERE activity_timestamp < $timeout AND persistent='1';");
} || return undef;
}
return 1; return 1;
}; };

Loading…
Cancel
Save