diff options
author | Eric Wong <e@80x24.org> | 2018-07-29 10:05:13 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2018-07-29 10:20:36 +0000 |
commit | 466df3e029fecdabac373d73989c7fceebe6ae28 (patch) | |
tree | ebd6e15fd155202ef251d14dedb39828dc983ca6 /lib/PublicInbox/Spamcheck.pm | |
parent | 9015a8af2909b0071e54b332bfafc4e5b8d0f6c2 (diff) | |
download | public-inbox-466df3e029fecdabac373d73989c7fceebe6ae28.tar.gz |
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.
Diffstat (limited to 'lib/PublicInbox/Spamcheck.pm')
-rw-r--r-- | lib/PublicInbox/Spamcheck.pm | 25 |
1 files changed, 25 insertions, 0 deletions
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 <meta@public-inbox.org> +# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> +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; |