Generate shorter random room names

Fix #18
master
Daniel Berteaud 11 years ago
parent f1012ad480
commit 4a6e292ea6
  1. 13
      public/vroom.pl

@ -218,6 +218,17 @@ helper valid_room_name => sub {
return $ret; return $ret;
}; };
# Generate a random name
helper get_random_name => sub {
my $self = shift;
my $name = join '' => map{('a'..'z','0'..'9')[rand 36]} 0..9;
# Get another one if already taken
while ($self->get_room($name)){
$name = $self->get_random_name();
}
return $name;
};
any '/' => 'index'; any '/' => 'index';
get '/about' => sub { get '/about' => sub {
@ -257,7 +268,7 @@ get '/goodby/(:room)' => sub {
post '/create' => sub { post '/create' => sub {
my $self = shift; my $self = shift;
$self->res->headers->cache_control('max-age=1, no-cache'); $self->res->headers->cache_control('max-age=1, no-cache');
my $name = $self->param('roomName') || lc guid_string(); my $name = $self->param('roomName') || $self->get_random_name();
$self->login; $self->login;
unless ($self->valid_room_name($name)){ unless ($self->valid_room_name($name)){
return $self->render('error', return $self->render('error',

Loading…
Cancel
Save