[freeside-commits] branch master updated. f1efa648c501e910f675475c522dde7ed44c671f

Mitch Jackson mitch at freeside.biz
Sun Dec 3 15:07:35 PST 2017


The branch, master has been updated
       via  f1efa648c501e910f675475c522dde7ed44c671f (commit)
      from  48e20d8f1d1b7bccbe0f1a37786cb2c42074a5fc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f1efa648c501e910f675475c522dde7ed44c671f
Author: Mitch Jackson <mitch at freeside.biz>
Date:   Sun Dec 3 23:05:13 2017 +0000

    RT#76877 Add an outgoing email notification blacklist

diff --git a/rt/etc/RT_SiteConfig.pm b/rt/etc/RT_SiteConfig.pm
index 6420d11ef..e22d202e6 100644
--- a/rt/etc/RT_SiteConfig.pm
+++ b/rt/etc/RT_SiteConfig.pm
@@ -58,6 +58,8 @@ Set($MessageBoxRichTextHeight, 368);
 
 #Set(@Plugins,(qw(Extension::QuickDelete RT::FM)));
 
+# Enable blacklist for e-mail notifications (matches via case insensitive regex)
+#Set(@NotifyBlacklist,(qw(reddit.com slashdot.org frank)));
 
 # Define default lifecycle to include resolved_quiet status workflow
 Set(%Lifecycles,
diff --git a/rt/lib/RT/Action/SendEmail_Local.pm b/rt/lib/RT/Action/SendEmail_Local.pm
new file mode 100644
index 000000000..64a04dead
--- /dev/null
+++ b/rt/lib/RT/Action/SendEmail_Local.pm
@@ -0,0 +1,63 @@
+use strict;
+use warnings;
+no warnings qw(redefine);
+
+package RT::Action::SendEmail;
+
+=head1 DESCRIPTION
+
+Overlay for RT::Action::SendEmail to implement a global email notifications
+blacklist.  All components that send email using the SendEmail action will
+be affected by this blacklist.
+
+The web interface uses these filters to decide which email addresses to
+display as sendable.  This gives us the added bonus of transparency.  If
+an e-mail address is blacklisted, it will never appear in the recipient
+list on a ticket correspondance.
+
+=head1 USAGE
+
+To enable the blacklist, add a configuration option to RT_SiteConfig.pm
+
+    Set(@NotifyBlacklist,(qw(reddit.com slashdot.org frank)));
+
+If an email address regex matches any item in the list, no email is sent
+
+=head1 DEV NOTE
+
+This overlay implementation will need to be maintained if RT updates
+the SendEmail action to filter addresses differently.  The benefit of
+using rt overlays is our library changes easily persist between rt versions,
+and don't need to be reimplemented with each release of rt.  The downside
+of overlays if the underlying rt core functionality changes, our overlay
+may break rt until it is removed or updated.
+
+For information on RT library overlays,
+see L<https://rt-wiki.bestpractical.com/wiki/CustomizingWithOverlays>
+
+=cut
+
+sub RecipientFilter {
+    my $self = shift;
+
+    unless (ref $self->{RecipientFilter}) {
+      my @blacklist;
+      eval { @blacklist = @RT::NotifyBlacklist };
+      if (@blacklist) {
+        push @{$self->{RecipientFilter}}, {
+          All => 1,
+          Callback => sub {
+            my $email = shift;
+            for my $block (@blacklist) {
+              return "$email is blacklisted by NotifyBlacklist, skipping"
+                if $email =~ /$block/i;
+            }
+            return 0;
+          }
+        };
+      }
+    }
+    push @{ $self->{RecipientFilter}}, {@_};
+}
+
+1;

-----------------------------------------------------------------------

Summary of changes:
 rt/etc/RT_SiteConfig.pm             |  2 ++
 rt/lib/RT/Action/SendEmail_Local.pm | 63 +++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+)
 create mode 100644 rt/lib/RT/Action/SendEmail_Local.pm




More information about the freeside-commits mailing list