Various cleanups in invitations handling

master
Daniel Berteaud 11 years ago
parent 50cab2837f
commit 2a437cc4fd
  1. 17
      public/vroom.pl
  2. 6
      templates/default/invitation.html.ep
  3. 11
      templates/default/invite.email_html.ep
  4. 9
      templates/default/invite.email_text.ep

@ -476,7 +476,7 @@ helper add_invitation => sub {
my ($room,$email) = @_;
my $from = $self->session('name') || return undef;
my $data = $self->get_room($room);
my $id = $self->get_random(20);
my $id = $self->get_random(30);
return undef unless ($data);
my $sth = eval { $self->db->prepare("INSERT INTO `invitations` (`id`,`from`,`token`,`email`,`timestamp`) VALUES (?,?,?,?,?)") } || return undef;
$sth->execute($data->{id},$from,$id,$email,time()) || return undef;
@ -620,11 +620,12 @@ get '/kicked/(:room)' => sub {
# Route for invitition response
get '/invitation' => sub {
my $self = shift;
my $inviteId = $self->param('id') || '';
my $response = $self->param('response') || 'decline';
my $inviteId = $self->param('token') || '';
# Delecte expired invitation now
$self->delete_invitations;
my $invite = $self->get_invitation($inviteId);
my $room = $self->get_room_by_id($invite->{id});
if (!$invite || !$room || $response !~ m/^(decline|later)$/){
if (!$invite || !$room){
return $self->render('error',
err => 'ERROR_INVITATION_INVALID',
msg => $self->l('ERROR_INVITATION_INVALID'),
@ -634,13 +635,12 @@ get '/invitation' => sub {
$self->render('invitation',
inviteId => $inviteId,
room => $room->{name},
response => $response
);
};
post '/invitation' => sub {
my $self = shift;
my $id = $self->param('id') || '';
my $id = $self->param('token') || '';
my $response = $self->param('response') || 'decline';
my $message = $self->param('message') || '';
if ($response !~ m/^(later|decline)$/ || !$self->respond_invitation($id,$response,$message)){
@ -755,6 +755,7 @@ get '/(*room)' => sub {
$self->redirect_to($self->get_url('/') . lc $room);
}
$self->delete_rooms;
$self->delete_invitations;
unless ($self->valid_room_name($room)){
return $self->render('error',
msg => $self->l('ERROR_NAME_INVALID'),
@ -782,6 +783,7 @@ get '/(*room)' => sub {
);
}
# Now, if the room is password protected and we're not a participant, nor the owner, lets prompt for the password
# Email invitation have a token which can be used instead of password
if ($data->{join_password} &&
(!$self->session($room) || $self->session($room)->{role} !~ m/^participant|owner$/) &&
!$self->check_invite_token($room,$token)){
@ -864,7 +866,8 @@ post '/action' => sub {
template => 'invite',
room => $room,
message => $message,
inviteId => $inviteId
inviteId => $inviteId,
joinPass => ($data->{join_password}) ? 'yes' : 'no'
],
)){
$self->app->log->info($self->session('name') . " sent an invitation for room $room to $rcpt");

@ -26,16 +26,16 @@
<textarea name="message" id="message" class="form-control" rows="5" placeholder="<%=l 'DONT_WAIT_FOR_ME' %>"></textarea>
</div>
<div class="form-group">
<label for="response"><%=l 'YOU_CAN_STILL_CHANGE_YOUR_MIND' %></label>
<label><%=l 'YOU_CAN_STILL_CHANGE_YOUR_MIND' %></label>
<p>
<%=l 'CLICK_SEND_OR_JOIN_NOW' %>
</p>
</div>
<div class="btn-group">
<button type="submit" class="btn btn-default btn-lg"><%=l 'SUBMIT' %></button>
<a class="btn btn-primary btn-lg" role="button" href="<%= $self->get_url('/') . $room %>">
<a class="btn btn-default btn-lg" role="button" href="<%= $self->get_url('/') . $room %><% if ($inviteId ne ''){ %>?token=<%= $inviteId %><% } %>">
<%=l 'JOIN_THIS_ROOM' %>
</a>
<button type="submit" class="btn btn-primary btn-lg"><%=l 'SUBMIT' %></button>
</div>
</form>
</div>

@ -20,8 +20,13 @@
<%=l 'WHEN_YOU_ARE_READY' %>
<center>
<h1>
<a href="<%= $url . $room %>?token=<%= $inviteId %>">
<%= $url . $room %>?token=<%= $inviteId %>
<% my $roomAccess = $room;
if ($joinPass eq 'yes') {
$roomAccess .= '?token=' . $inviteId;
}
%>
<a href="<%= $url . $roomAccess %>">
<%= $url . $roomAccess %>
</a>
</h1>
</center>
@ -37,7 +42,7 @@
<p>
<%=l 'IF_YOU_CANNOT_JOIN' %>
<h3>
<a style="color:red" href="<%= $url . 'invitation?id=' . $inviteId %>">
<a style="color:red" href="<%= $url . 'invitation?token=' . $inviteId %>">
<%=l 'YOU_CAN_NOTIFY_THE_ORGANIZER' %>
</a>
</h3>

@ -10,7 +10,12 @@
<%==l 'WHEN_YOU_ARE_READY' %>
<%= $url . $room %>?token=<%= $inviteId %>
<% my $roomAccess = $room;
if ($joinPass eq 'yes') {
$roomAccess .= '?token=' . $inviteId;
}
%>
<%== $url . $roomAccess %>
<% if ($message && $message ne ''){ %>
<%==l 'MESSAGE_FROM_ORGANIZER' %>:
@ -20,7 +25,7 @@
<%==l 'IF_YOU_CANNOT_JOIN' %> <%==l 'YOU_CAN_NOTIFY_THE_ORGANIZER' %>
<%== $url . 'invitation?id=' . $inviteId %>
<%== $url . 'invitation?token=' . $inviteId %>
<%==l 'HAVE_A_NICE_MEETING' %>
--

Loading…
Cancel
Save