* [PATCH] learn: use "spam" as subject for removal commits
@ 2017-11-16 19:14 Eric Wong
2017-11-16 20:45 ` [PATCH 1/2] learn: use "spam" as subject for removal commits (part #2) Eric Wong
0 siblings, 1 reply; 3+ messages in thread
From: Eric Wong @ 2017-11-16 19:14 UTC (permalink / raw)
To: meta
Sometimes an email is an innocent removal "rm" for a
misdirected, off-topic post, while most removed messages are
"spam". Allow anybody to look at history and easily distinguish
the reason for removing the message.
---
lib/PublicInbox/Import.pm | 6 ++++--
script/public-inbox-learn | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index 31dc769..8c9d1cb 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -90,7 +90,7 @@ sub _check_path ($$$$) {
# ('MISMATCH', msg) on mismatch
# (:MARK, msg) on success
sub remove {
- my ($self, $mime) = @_; # mime = Email::MIME
+ my ($self, $mime, $msg) = @_; # mime = Email::MIME
my $mid = mid_mime($mime);
my $path = mid2path($mid);
@@ -138,10 +138,12 @@ sub remove {
}
my $ident = $self->{ident};
my $now = now2822();
+ $msg ||= 'rm';
+ my $len = length($msg) + 1;
print $w "commit $ref\nmark :$commit\n",
"author $ident $now\n",
"committer $ident $now\n",
- "data 3\nrm\n\n",
+ "data $len\n$msg\n\n",
'from ', ($parent ? $parent : $tip), "\n" or wfail;
print $w "D $path\n\n" or wfail;
$self->{nchg}++;
diff --git a/script/public-inbox-learn b/script/public-inbox-learn
index 71aa50f..75294a0 100755
--- a/script/public-inbox-learn
+++ b/script/public-inbox-learn
@@ -81,7 +81,7 @@ foreach my $recipient (keys %dests) {
# may train for each cross-posted message, and this
# script already learns for every list in
# ~/.public-inbox/config
- $im->remove($mime);
+ $im->remove($mime, $train);
} else { # $train eq "ham"
# no checking for spam here, we assume the message has
# been reviewed by a human at this point:
--
EW
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 1/2] learn: use "spam" as subject for removal commits (part #2)
2017-11-16 19:14 [PATCH] learn: use "spam" as subject for removal commits Eric Wong
@ 2017-11-16 20:45 ` Eric Wong
2017-11-16 20:45 ` [PATCH 2/2] watch: use "spam" in commit message for removals Eric Wong
0 siblings, 1 reply; 3+ messages in thread
From: Eric Wong @ 2017-11-16 20:45 UTC (permalink / raw)
To: meta
We need to use the correct subject when doing global scanning,
too. In fact, the per-recipient spam training path is entirely
redundant at this point.
---
script/public-inbox-learn | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/script/public-inbox-learn b/script/public-inbox-learn
index 75294a0..5041d82 100755
--- a/script/public-inbox-learn
+++ b/script/public-inbox-learn
@@ -58,7 +58,7 @@ if ($train eq 'spam') {
my $name = $ibx->{name};
my $addr = $ibx->{-primary_address};
my $im = PublicInbox::Import->new($git, $name, $addr, $ibx);
- $im->remove($mime);
+ $im->remove($mime, 'spam');
$im->done;
});
}
--
EW
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] watch: use "spam" in commit message for removals
2017-11-16 20:45 ` [PATCH 1/2] learn: use "spam" as subject for removal commits (part #2) Eric Wong
@ 2017-11-16 20:45 ` Eric Wong
0 siblings, 0 replies; 3+ messages in thread
From: Eric Wong @ 2017-11-16 20:45 UTC (permalink / raw)
To: meta
This makes it easy to identify the reason for message removals.
---
lib/PublicInbox/WatchMaildir.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm
index 5ae3d21..424186b 100644
--- a/lib/PublicInbox/WatchMaildir.pm
+++ b/lib/PublicInbox/WatchMaildir.pm
@@ -132,11 +132,11 @@ sub _remove_spam {
my ($ibx) = @_;
eval {
my $im = _importer_for($self, $ibx);
- $im->remove($mime);
+ $im->remove($mime, 'spam');
if (my $scrub = _scrubber_for($ibx)) {
my $scrubbed = $scrub->scrub($mime) or return;
$scrubbed == 100 and return;
- $im->remove($scrubbed);
+ $im->remove($scrubbed, 'spam');
}
};
if ($@) {
--
EW
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-11-16 20:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-16 19:14 [PATCH] learn: use "spam" as subject for removal commits Eric Wong
2017-11-16 20:45 ` [PATCH 1/2] learn: use "spam" as subject for removal commits (part #2) Eric Wong
2017-11-16 20:45 ` [PATCH 2/2] watch: use "spam" in commit message for removals Eric Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).