From bbe77d48cf0ae72fca9bbe739f332076b935d982 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Fri, 13 Jun 2014 16:39:23 +0200 Subject: [PATCH] Create etherpad group when joining, not creating the room So it's created for pre-existing rooms --- public/vroom.pl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/public/vroom.pl b/public/vroom.pl index 6a2c174..04cd412 100755 --- a/public/vroom.pl +++ b/public/vroom.pl @@ -200,15 +200,6 @@ helper create_room => sub { my $tp = $self->get_random(49); $sth->execute($name,time(),time(),$owner,$tp,$config->{realm}) || return undef; $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; }; @@ -859,6 +850,15 @@ get '/(*room)' => sub { $self->session($room => {role => 'participant'}) if (!$self->session($room) || !$self->session($room)->{role}); # Create etherpad session if needed 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')); $self->session($room)->{etherpadAuthorId} = $id; my $etherpadSession = $ec->create_session($data->{etherpad_group}, $id, time + 86400);