Details modified notification emails

master
Daniel Berteaud 9 years ago
parent ce77729ef8
commit df6b375f8c
  1. 15
      templates/default/documentation.html.ep
  2. 31
      vroom.pl

@ -108,6 +108,7 @@
<li>Protocol::SocketIO::Message</li> <li>Protocol::SocketIO::Message</li>
<li>Data::Dumper</li> <li>Data::Dumper</li>
<li>DateTime</li> <li>DateTime</li>
<li>Array::Diff</li>
</ul> </ul>
</li> </li>
<li>The following perl modules are optional <li>The following perl modules are optional
@ -174,7 +175,7 @@ yum install epel-release</pre>
The following command will install everything required to run VROOM The following command will install everything required to run VROOM
<pre> <pre>
yum install git tar wget httpd mod_ssl openssl mariadb-server \\ yum install git tar wget httpd mod_ssl openssl mariadb-server \\
'perl(DBI)' 'perl(DBD::mysql)' \\ 'perl(DBI)' 'perl(DBD::mysql)' 'perl('Array::Diff)' \\
'perl(Mojolicious)' 'perl(Mojolicious::Plugin::I18N)' 'perl(Mojolicious::Plugin::Mail)' \\ 'perl(Mojolicious)' 'perl(Mojolicious::Plugin::I18N)' 'perl(Mojolicious::Plugin::Mail)' \\
'perl(Crypt::SaltedHash)' 'perl(Etherpad::API)' 'perl(LWP::Protocol::https)' \\ 'perl(Crypt::SaltedHash)' 'perl(Etherpad::API)' 'perl(LWP::Protocol::https)' \\
'perl(Sesion::Token)' 'perl(Mojolicious::Plugin::Database)' \\ 'perl(Sesion::Token)' 'perl(Mojolicious::Plugin::Database)' \\
@ -715,16 +716,8 @@ systemctl restart vroom.service</pre>
<td>A room is being deleted by a user action</td> <td>A room is being deleted by a user action</td>
</tr> </tr>
<tr> <tr>
<td>add_email_notification</td> <td>email_notification_change</td>
<td>Add an email to the list of notifications sent when someone joins a room</td> <td>The list of email being notified when someone joins a room has been updated</td>
</tr>
<tr>
<td>reset_email_notification</td>
<td>Reset the list of email being notified when someone joins a rooms</td>
</tr>
<tr>
<td>del_email_notification</td>
<td>Remove an email from the list of notifications sent when someone joins a room</td>
</tr> </tr>
<tr> <tr>
<td>send_invitation</td> <td>send_invitation</td>

@ -23,6 +23,7 @@ use Protocol::SocketIO::Message;
use File::Path qw(make_path); use File::Path qw(make_path);
use File::Basename; use File::Basename;
use DateTime; use DateTime;
use Array::Diff;
use Data::Dumper; use Data::Dumper;
app->log->level('info'); app->log->level('info');
@ -654,10 +655,6 @@ helper add_notification => sub {
$data->{id}, $data->{id},
$email $email
); );
$self->log_event({
event => 'add_email_notification',
msg => "Adding $email to the notification list for room " . $data->{name}
});
return 1; return 1;
}; };
@ -670,6 +667,26 @@ helper update_email_notifications => sub {
if (!$data){ if (!$data){
return 0; return 0;
} }
my $old = $self->get_email_notifications($room);
my @old = sort map { $old->{$_}->{email} } keys $old;
my @new = sort @$emails;
# Remove empty email
@new = grep { $_ ne '' } @new;
my $diff = Array::Diff->diff(\@old, \@new);
# Are we changing the list of email ?
if ($diff->count > 0){
my $msg = "Notification list for room $room has changed\n";
if (scalar @{$diff->deleted} > 0){
$msg .= "Emails being removed: " . join (', ', @{$diff->deleted}) . "\n";
}
if (scalar @{$diff->added} > 0){
$msg .= "Emails being added: " . join (', ', @{$diff->added}) . "\n";
}
$self->log_event({
event => 'email_notification_change',
msg => $msg
});
}
# First, drop all existing notifications # First, drop all existing notifications
my $sth = eval { my $sth = eval {
$self->db->prepare('DELETE FROM `email_notifications` $self->db->prepare('DELETE FROM `email_notifications`
@ -678,12 +695,8 @@ helper update_email_notifications => sub {
$sth->execute( $sth->execute(
$data->{id}, $data->{id},
); );
$self->log_event({
event => 'reset_email_notification',
msg => 'Resetting email notification list for room ' . $data->{name}
});
# Now, insert new emails # Now, insert new emails
foreach my $email (@$emails){ foreach my $email (@new){
# Skip empty inputs # Skip empty inputs
if ($email eq ''){ if ($email eq ''){
next; next;

Loading…
Cancel
Save