mirror of https://github.com/dani/vroom.git
Details modified notification emails
This commit is contained in:
parent
ce77729ef8
commit
df6b375f8c
|
@ -108,6 +108,7 @@
|
|||
<li>Protocol::SocketIO::Message</li>
|
||||
<li>Data::Dumper</li>
|
||||
<li>DateTime</li>
|
||||
<li>Array::Diff</li>
|
||||
</ul>
|
||||
</li>
|
||||
<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
|
||||
<pre>
|
||||
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(Crypt::SaltedHash)' 'perl(Etherpad::API)' 'perl(LWP::Protocol::https)' \\
|
||||
'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>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>add_email_notification</td>
|
||||
<td>Add an email to the list of notifications sent when someone joins a room</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>
|
||||
<td>email_notification_change</td>
|
||||
<td>The list of email being notified when someone joins a room has been updated</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>send_invitation</td>
|
||||
|
|
31
vroom.pl
31
vroom.pl
|
@ -23,6 +23,7 @@ use Protocol::SocketIO::Message;
|
|||
use File::Path qw(make_path);
|
||||
use File::Basename;
|
||||
use DateTime;
|
||||
use Array::Diff;
|
||||
use Data::Dumper;
|
||||
|
||||
app->log->level('info');
|
||||
|
@ -654,10 +655,6 @@ helper add_notification => sub {
|
|||
$data->{id},
|
||||
$email
|
||||
);
|
||||
$self->log_event({
|
||||
event => 'add_email_notification',
|
||||
msg => "Adding $email to the notification list for room " . $data->{name}
|
||||
});
|
||||
return 1;
|
||||
};
|
||||
|
||||
|
@ -670,6 +667,26 @@ helper update_email_notifications => sub {
|
|||
if (!$data){
|
||||
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
|
||||
my $sth = eval {
|
||||
$self->db->prepare('DELETE FROM `email_notifications`
|
||||
|
@ -678,12 +695,8 @@ helper update_email_notifications => sub {
|
|||
$sth->execute(
|
||||
$data->{id},
|
||||
);
|
||||
$self->log_event({
|
||||
event => 'reset_email_notification',
|
||||
msg => 'Resetting email notification list for room ' . $data->{name}
|
||||
});
|
||||
# Now, insert new emails
|
||||
foreach my $email (@$emails){
|
||||
foreach my $email (@new){
|
||||
# Skip empty inputs
|
||||
if ($email eq ''){
|
||||
next;
|
||||
|
|
Loading…
Reference in New Issue