|
|
@ -200,15 +200,6 @@ helper create_room => sub { |
|
|
|
my $tp = $self->get_random(49); |
|
|
|
my $tp = $self->get_random(49); |
|
|
|
$sth->execute($name,time(),time(),$owner,$tp,$config->{realm}) || return undef; |
|
|
|
$sth->execute($name,time(),time(),$owner,$tp,$config->{realm}) || return undef; |
|
|
|
$self->app->log->info("Room $name created by " . $self->session('name')); |
|
|
|
$self->app->log->info("Room $name created by " . $self->session('name')); |
|
|
|
# therpad integration ? |
|
|
|
|
|
|
|
if ($ec){ |
|
|
|
|
|
|
|
my $group = $ec->create_group() || undef; |
|
|
|
|
|
|
|
return undef unless ($group); |
|
|
|
|
|
|
|
$sth = eval { $self->db->prepare("UPDATE `rooms` SET `etherpad_group`=? WHERE `name`='$name';") } || return undef; |
|
|
|
|
|
|
|
$sth->execute($group); |
|
|
|
|
|
|
|
$ec->create_group_pad($group,$name) || return undef; |
|
|
|
|
|
|
|
$self->app->log->debug("Etherpad group $group created for room $name"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -859,6 +850,15 @@ get '/(*room)' => sub { |
|
|
|
$self->session($room => {role => 'participant'}) if (!$self->session($room) || !$self->session($room)->{role}); |
|
|
|
$self->session($room => {role => 'participant'}) if (!$self->session($room) || !$self->session($room)->{role}); |
|
|
|
# Create etherpad session if needed |
|
|
|
# Create etherpad session if needed |
|
|
|
if ($ec && !$self->session($room)->{etherpadSession}){ |
|
|
|
if ($ec && !$self->session($room)->{etherpadSession}){ |
|
|
|
|
|
|
|
# pad doesn't exist yet ? |
|
|
|
|
|
|
|
if (!$data->{etherpad_group}){ |
|
|
|
|
|
|
|
my $group = $ec->create_group() || undef; |
|
|
|
|
|
|
|
return undef unless ($group); |
|
|
|
|
|
|
|
my $sth = eval { $self->db->prepare("UPDATE `rooms` SET `etherpad_group`=? WHERE `name`='$room';") } || return undef; |
|
|
|
|
|
|
|
$sth->execute($group); |
|
|
|
|
|
|
|
$ec->create_group_pad($group,$room) || return undef; |
|
|
|
|
|
|
|
$self->app->log->debug("Etherpad group $group created for room $room"); |
|
|
|
|
|
|
|
} |
|
|
|
my $id = $ec->create_author_if_not_exists_for($self->session('name')); |
|
|
|
my $id = $ec->create_author_if_not_exists_for($self->session('name')); |
|
|
|
$self->session($room)->{etherpadAuthorId} = $id; |
|
|
|
$self->session($room)->{etherpadAuthorId} = $id; |
|
|
|
my $etherpadSession = $ec->create_session($data->{etherpad_group}, $id, time + 86400); |
|
|
|
my $etherpadSession = $ec->create_session($data->{etherpad_group}, $id, time + 86400); |
|
|
|