|
|
@ -474,8 +474,8 @@ helper add_invitation => sub { |
|
|
|
my $data = $self->get_room($room); |
|
|
|
my $data = $self->get_room($room); |
|
|
|
my $id = $self->get_random(50); |
|
|
|
my $id = $self->get_random(50); |
|
|
|
return undef unless ($data); |
|
|
|
return undef unless ($data); |
|
|
|
my $sth = eval { $self->db->prepare("INSERT INTO invitations (`id`,`from`,`token`,`email`) VALUES (?,?,?,?)") } || return undef; |
|
|
|
my $sth = eval { $self->db->prepare("INSERT INTO invitations (`id`,`from`,`token`,`email`,`timestamp`) VALUES (?,?,?,?,?)") } || return undef; |
|
|
|
$sth->execute($data->{id},$from,$id,$email) || return undef; |
|
|
|
$sth->execute($data->{id},$from,$id,$email,time()) || return undef; |
|
|
|
return $id; |
|
|
|
return $id; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -518,6 +518,17 @@ helper processed_invitation => sub { |
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Purge expired invitation links |
|
|
|
|
|
|
|
helper delete_invitations => sub { |
|
|
|
|
|
|
|
my $self = shift; |
|
|
|
|
|
|
|
$self->app->log->debug('Removing expired invitations'); |
|
|
|
|
|
|
|
# Invitation older than 2 hours doesn't make much sense |
|
|
|
|
|
|
|
my $timeout = time()-7200; |
|
|
|
|
|
|
|
my $sth = eval { $self->db->prepare("DELETE FROM `invitations` WHERE `timestamp` < $timeout;") } || return undef; |
|
|
|
|
|
|
|
$sth->execute() || return undef; |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
# Route / to the index page |
|
|
|
# Route / to the index page |
|
|
|
any '/' => 'index'; |
|
|
|
any '/' => 'index'; |
|
|
|
|
|
|
|
|
|
|
@ -873,6 +884,10 @@ post '/action' => sub { |
|
|
|
if ((int (rand 100)) <= 10){ |
|
|
|
if ((int (rand 100)) <= 10){ |
|
|
|
$self->delete_rooms; |
|
|
|
$self->delete_rooms; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
# And same for expired invitation links |
|
|
|
|
|
|
|
if ((int (rand 100)) <= 10){ |
|
|
|
|
|
|
|
$self->delete_invitations; |
|
|
|
|
|
|
|
} |
|
|
|
if ($res){ |
|
|
|
if ($res){ |
|
|
|
$status = 'success'; |
|
|
|
$status = 'success'; |
|
|
|
$msg = ''; |
|
|
|
$msg = ''; |
|
|
|