Allow several email addresses for invitations

master
Daniel Berteaud 10 years ago
parent 428f7599dd
commit dfda2f03f4
  1. 2
      lib/Vroom/I18N/en.pm
  2. 2
      lib/Vroom/I18N/fr.pm
  3. 43
      public/js/vroom.js
  4. 2
      templates/default/configure_modal.html.ep
  5. 12
      templates/default/invite_modal.html.ep
  6. 33
      vroom.pl

@ -16,7 +16,7 @@ our %Lexicon = (
"ERROR_NOT_LOGGED_IN" => "Sorry, your not logged in",
"JS_REQUIRED" => "VROOM needs javascript to work properly",
"EMAIL_INVITATION" => "Video conference invitation",
"INVITE_SENT_TO_s" => "An invitation was sent to %s",
"INVITE_SENT_TO_s" => "An invitation was sent to the following addresses\n%s",
"YOU_ARE_INVITED_TO_A_MEETING" => "You are awaited on a video conferecing room. " .
"Before joining it, make sure you have all the necessary",
"A_MODERN_BROWSER" => "A modern web browser, recent versions of Mozilla Firefox, Google Chrome or Opera will work",

@ -40,7 +40,7 @@ our %Lexicon = (
"FROM" => "De la part de",
"GIVE_US_YOUR_FEEDBACK" => "Parlez-nous de votre expérience",
"YOUR_FEEDBACK_HELPS_US" => "Votre retour d'expérience (bonne ou mauvaise) peut nous aider à améliorer ce service",
"INVITE_SENT_TO_s" => "Une invitation a été envoyée à %s",
"INVITE_SENT_TO_s" => "Une invitation a été envoyée aux adresses suivantes\n%s",
"DATA_WIPED" => "Les données ont été supprimées",
"ROOM_DATA_WIPED_BY_s" => "Les données du salon (historique du tchat, prise de notes) ont été supprimées par %s",
"NOT_ENABLED" => "Cette fonctionalité n'est pas activée",

@ -175,22 +175,22 @@ function maxHeight(){
}
// Create a new input field
function addEmailInputField(val){
var parentEl = $('.email-list'),
function addEmailInputField(form, val){
var parentEl = $('#' + form),
currentEntry = parentEl.find('.email-entry:last'),
newEntry = $(currentEntry.clone()).css('display', 'none').appendTo(parentEl);
newEntry.find('input').val(val);
newEntry.removeClass('has-error');
adjustAddRemoveEmailButtons();
adjustAddRemoveEmailButtons(form);
newEntry.show(100);
}
// Adjust add and remove buttons foir email notifications
function adjustAddRemoveEmailButtons(){
$('.email-list').find('.email-entry:not(:last) .btn-add-email')
function adjustAddRemoveEmailButtons(form){
$('#' + form).find('.email-entry:not(:last) .btn-add-email')
.removeClass('btn-primary').removeClass('btn-add-email')
.addClass('btn-danger').addClass('btn-remove-email')
.html('<span class="glyphicon glyphicon-minus"></span>');
$('.email-list').find('.email-entry:last .btn-remove-email')
$('#' + form).find('.email-entry:last .btn-remove-email')
.removeClass('btn-danger').removeClass('btn-remove-email')
.addClass('btn-primary').addClass('btn-add-email')
.html('<span class="glyphicon glyphicon-plus"></span>');
@ -198,7 +198,7 @@ function adjustAddRemoveEmailButtons(){
// Add emails input fields
$(document).on('click','button.btn-add-email',function(e){
e.preventDefault();
addEmailInputField('');
addEmailInputField($(this).parents('.email-list:first').attr('id'), '');
});
$(document).on('click','button.btn-remove-email',function(e){
e.preventDefault();
@ -506,7 +506,7 @@ function initAdmin(){
// We keep it so we can clone it again
$('.email-list').find('.email-entry:not(:first)').remove();
$.each(data.notif, function(index, obj){
addEmailInputField(obj.email);
addEmailInputField('email-list-notification', obj.email);
});
// Now, remove the first one if the list is not empty
if (Object.keys(data.notif).length > 0){
@ -652,7 +652,7 @@ function initVroom(room) {
// We keep it so we can clone it again
$('.email-list').find('.email-entry:not(:first)').remove();
$.each(data.notif, function(index, obj){
addEmailInputField(obj.email);
addEmailInputField('email-list-notification', obj.email);
});
// Now, remove the first one if the list is not empty
if (Object.keys(data.notif).length > 0){
@ -1597,20 +1597,35 @@ function initVroom(room) {
// Handle Email Invitation
$('#inviteEmail').submit(function(event) {
event.preventDefault();
var rcpt = $('#recipient').val();
var rcpts = [],
message = $('#message').val();
$('input[name="invitation-recipients[]"]').each(function(){
rcpts.push($(this).val());
});
// Simple email address verification
// not fullproof, but email validation is a real nightmare
if (!rcpt.match(/\S+@\S+\.\S+/)){
$.notify(locale.ERROR_MAIL_INVALID, 'error');
return;
var validEmail = true;
$('.email-list').find('input').each(function(index, input){
if (!$(input).val().match(/\S+@\S+\.\S+/) && $(input).val() !== ''){
$(input).parent().addClass('has-error');
//$(input).parent().notify(locale.ERROR_MAIL_INVALID, 'error');
validEmail = false;
// Break the each loop
return false;
}
else{
$(input).parent().removeClass('has-error');
}
});
if (!validEmail){
return false;
}
$.ajax({
data: {
req: JSON.stringify({
action: 'invite_email',
param: {
rcpt: rcpt,
rcpts: rcpts,
message: message,
room: roomName
}

@ -85,7 +85,7 @@
<label class="col-sm-4 control-label" for="emailNotifications">
<%=l 'NOTIFICATION_ON_JOIN' %>
</label>
<div class="col-sm-8 email-list">
<div class="col-sm-8 email-list" id="email-list-notification">
<div class="email-entry input-group col-sm-8">
<input class="form-control" autocomplete="off" name="emails[]" type="text" placeholder="<%=l 'EMAIL_PLACEHOLDER' %>" />
<span class="input-group-btn">

@ -15,8 +15,16 @@
<label for="recipient" class="col-sm-4 control-label">
<%=l 'RECIPIENT' %>
</label>
<div class="col-sm-8">
<input type="email" id="recipient" class="form-control" placeholder="<%=l 'EMAIL_PLACEHOLDER' %>"/>
<div class="col-sm-8 email-list" id="email-list-invite">
<div class="email-entry input-group col-sm-8">
<input class="form-control" autocomplete="off" name="invitation-recipients[]" type="text" placeholder="<%=l 'EMAIL_PLACEHOLDER' %>" />
<span class="input-group-btn">
<button class="btn btn-primary btn-add-email" type="button">
<span class="glyphicon glyphicon-plus">
</span>
</button>
</span>
</div>
</div>
</div>
<div class="form-group">

@ -1300,20 +1300,32 @@ any '/api' => sub {
}
# Ok, now, we don't have to bother with authorization anymore
if ($req->{action} eq 'invite_email'){
if (!$req->{param}->{rcpt} || $req->{param}->{rcpt}!~ m/\S+@\S+\.\S+$/){
#if (!$req->{param}->{rcpts}){
# return $self->render(
# json => {
# status => 'error',
# msg => $self->l('ERROR_MAIL_INVALID')
# }
# );
#}
my $rcpts = $req->{param}->{rcpts};
foreach my $addr (@$rcpts){
if (!$self->valid_email($addr) && $addr ne ''){
return $self->render(
json => {
status => 'error',
msg => 'ERROR_MAIL_INVALID'
msg => $self->l('ERROR_MAIL_INVALID')
}
);
}
}
foreach my $addr (@$rcpts){
my $token = $self->add_invitation(
$req->{param}->{room},
$req->{param}->{rcpt}
$addr
);
my $sent = $self->mail(
to => $req->{param}->{rcpt},
to => $addr,
subject => $self->l("EMAIL_INVITATION"),
data => $self->render_mail('invite',
room => $req->{param}->{room},
@ -1322,19 +1334,20 @@ any '/api' => sub {
joinPass => ($room->{join_password}) ? 'yes' : 'no'
)
);
if ($token && $sent){
$self->app->log->info("Email invitation to join room " . $req->{param}->{room} . " sent to " . $req->{param}->{rcpt});
if (!$token || !$sent){
return $self->render(
json => {
status => 'success',
msg => sprintf($self->l('INVITE_SENT_TO_s'), $req->{param}->{rcpt})
status => 'error',
msg => 'ERROR_OCCURRED'
}
);
}
$self->app->log->info("Email invitation to join room " . $req->{param}->{room} . " sent to " . $addr);
}
return $self->render(
json => {
status => 'error',
msg => 'ERROR_OCCURRED'
status => 'success',
msg => sprintf($self->l('INVITE_SENT_TO_s'), join("\n", @$rcpts))
}
);
}

Loading…
Cancel
Save