From 466df3e029fecdabac373d73989c7fceebe6ae28 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 29 Jul 2018 10:05:13 +0000 Subject: mda: allow configuring globally without spamc support This reuses some of the configuration from -watch, but remains independent since some configurations will use -watch for some inboxes and -mda for others. The default remains "spamc" for -mda users so nothing changes without explicit configuration. Per-inbox configurations may also be supported in the future. --- lib/PublicInbox/Spamcheck.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/PublicInbox/Spamcheck.pm (limited to 'lib/PublicInbox/Spamcheck.pm') diff --git a/lib/PublicInbox/Spamcheck.pm b/lib/PublicInbox/Spamcheck.pm new file mode 100644 index 00000000..062479d6 --- /dev/null +++ b/lib/PublicInbox/Spamcheck.pm @@ -0,0 +1,25 @@ +# Copyright (C) 2018 all contributors +# License: AGPL-3.0+ +package PublicInbox::Spamcheck; +use strict; +use warnings; + +sub get { + my ($config, $key, $default) = @_; + my $spamcheck = $config->{$key}; + $spamcheck = $default unless $spamcheck; + + return if !$spamcheck || $spamcheck eq 'none'; + + if ($spamcheck eq 'spamc') { + $spamcheck = 'PublicInbox::Spamcheck::Spamc'; + } + if ($spamcheck =~ /::/) { + eval "require $spamcheck"; + return $spamcheck->new; + } + warn "unsupported $key=$spamcheck\n"; + undef; +} + +1; -- cgit v1.2.3-24-ge0c7