From ceb3690e97b222ec7cf46e94f2a3da78cf968d49 Mon Sep 17 00:00:00 2001
From: Daniel Berteaud
Date: Tue, 20 May 2014 11:17:38 +0200
Subject: [PATCH] Send notifications and add localizations
---
lib/Vroom/I18N/en.pm | 7 +++++++
lib/Vroom/I18N/fr.pm | 7 +++++++
public/vroom.pl | 26 ++++++++++++++++++++------
templates/default/notification.email_html.ep | 26 ++++++++++++++++++++++++++
templates/default/notification.email_text.ep | 13 +++++++++++++
5 files changed, 73 insertions(+), 6 deletions(-)
create mode 100644 templates/default/notification.email_html.ep
create mode 100644 templates/default/notification.email_text.ep
diff --git a/lib/Vroom/I18N/en.pm b/lib/Vroom/I18N/en.pm
index 02265a2..4724614 100644
--- a/lib/Vroom/I18N/en.pm
+++ b/lib/Vroom/I18N/en.pm
@@ -82,6 +82,13 @@ our %Lexicon = (
"OWNER_PASSWORD_MAKES_PERSISTENT" => "You can set a manager password. It will make this room persistent",
"OWNER_PASSWORD" => "Manager password",
"REMOVE_OWNER_PASSWORD" => "Remove the manager password. The room will become ephemeral",
+ "ADD_NOTIFICATION" => "Add a notification",
+ "ADD_THIS_ADDRESS" => "Add this address",
+ "NOTIFICATION_ON_JOIN" => "You can set a list of email address which will receive a notification each time someone joins this room",
+ "s_WILL_BE_NOTIFIED" => "%s will receive a notification each time someone joins this room",
+ "s_WONT_BE_NOTIFIED_ANYMORE" => "%s won't be notified anymore",
+ "JOIN_NOTIFICATION" => "Someone joined the room",
+ "SOMEONE_JOINED_A_ROOM" => "Someone joined a vodeo conference room, and your address is configured to receive this notifications",
"AUTH_SUCCESS" => "You are now authenticated",
"NOT_ALLOWED" => "You are not allowed to do this",
"WRONG_PASSWORD" => "Wrong password",
diff --git a/lib/Vroom/I18N/fr.pm b/lib/Vroom/I18N/fr.pm
index 260636f..a9fef91 100644
--- a/lib/Vroom/I18N/fr.pm
+++ b/lib/Vroom/I18N/fr.pm
@@ -88,6 +88,13 @@ our %Lexicon = (
"OWNER_PASSWORD_MAKES_PERSISTENT" => "Vous pouvez ajouter un mot de passe de gestionnaire. Ceci rendra le salon persistant",
"OWNER_PASSWORD" => "Mot de passe du gestionnaire",
"REMOVE_OWNER_PASSWORD" => "Supprimer le mot de passe du gestionnaire. Le salon redeviendra éphémère",
+ "ADD_NOTIFICATION" => "Ajouter une notification",
+ "ADD_THIS_ADDRESS" => "Ajouter cette adresse",
+ "NOTIFICATION_ON_JOIN" => "Vous pouvez ajouter des adresses email qui recevront une notification dès que quelqu'un rejoint ce salon",
+ "s_WILL_BE_NOTIFIED" => "%s recevra une notification à chaque fois qu'une personne rejoint ce salon",
+ "s_WONT_BE_NOTIFIED_ANYMORE" => "%s ne recevra plus les notifications pour ce salon",
+ "JOIN_NOTIFICATION" => "Quelqu'un a rejoint votre salon",
+ "SOMEONE_JOINED_A_ROOM" => "Quelqu'un a rejoint un salon de vidéo conférence, et votre adresse est configurée pour recevoir ces notifications",
"AUTH_SUCCESS" => "Vous êtes maintenant authentifié",
"NOT_ALLOWED" => "Vous n'êtes pas autorisé à faire ceci",
"WRONG_PASSWORD" => "Mauvais mot de passe",
diff --git a/public/vroom.pl b/public/vroom.pl
index c45e2cd..c40324b 100755
--- a/public/vroom.pl
+++ b/public/vroom.pl
@@ -597,8 +597,22 @@ get '/(*room)' => sub {
room => $room
);
}
+ # Send notifications
+ foreach my $rcpt ($self->get_notification($room)){
+ $self->email(
+ header => [
+ Subject => encode("MIME-Header", $self->l("JOIN_NOTIFICATION")),
+ To => $rcpt
+ ],
+ data => [
+ template => 'notification',
+ room => $room,
+ ],
+ );
+ }
# Now display the room page
$self->render('join',
+ format => 'html',
turnPassword => $data->{token}
);
};
@@ -805,24 +819,24 @@ post '/action' => sub {
my $email = $self->param('email');
my $type = $self->param('type');
my $status = 'error';
- my $msg = 'ERROR_OCCURED';
+ my $msg = $self->l('ERROR_OCCURED');
if ($self->session($room)->{role} ne 'owner'){
- $msg = 'NOT_ALLOWED';
+ $msg = $self->l('NOT_ALLOWED');
}
elsif ($email !~ m/^\S+@\S+\.\S+$/){
- $msg = 'ERROR_MAIL_INVALID';
+ $msg = $self->l('ERROR_MAIL_INVALID');
}
elsif ($type eq 'add' && $self->add_notification($room,$email)){
$status = 'success';
- $msg = 's_WILL_BE_NOTIFIED';
+ $msg = sprintf($self->l('s_WILL_BE_NOTIFIED'), $email);
}
elsif ($type eq 'remove' && $self->remove_notification($room,$email)){
$status = 'success';
- $msg = 's_WONT_BE_NOTIFIED_ANYMORE';
+ $msg = sprintf($self->l('s_WONT_BE_NOTIFIED_ANYMORE'), $email);
}
return $self->render(
json => {
- msg => $self->l($msg),
+ msg => $msg,
status => $status
}
);
diff --git a/templates/default/notification.email_html.ep b/templates/default/notification.email_html.ep
new file mode 100644
index 0000000..287bc84
--- /dev/null
+++ b/templates/default/notification.email_html.ep
@@ -0,0 +1,26 @@
+<%
+ my $url = $self->url_for('/')->to_abs;
+ $url .= ($url =~ m/\/$/) ? '' : '/';
+%>
+
+ <%=l 'SOMEONE_JOINED_A_ROOM' %>
+
+
+ <%=l 'WHEN_YOU_ARE_READY' %>
+
+
+
+
+
+
+ <%=l 'HAVE_A_NICE_MEETING' %>
+
+
+ —
+
+ <%=l 'EMAIL_SIGN' %>
+
diff --git a/templates/default/notification.email_text.ep b/templates/default/notification.email_text.ep
new file mode 100644
index 0000000..b215b06
--- /dev/null
+++ b/templates/default/notification.email_text.ep
@@ -0,0 +1,13 @@
+<%
+ my $url = $self->url_for('/')->to_abs;
+ $url .= ($url =~ m/\/$/) ? '' : '/';
+%>
+<%==l 'SOMEONE_JOINED_A_ROOM' %>
+
+<%=l 'WHEN_YOU_ARE_READY' %>
+
+<%== $url . $room %>
+
+<%=l 'HAVE_A_NICE_MEETING' %>
+--
+<%==l 'EMAIL_SIGN' %>