From cf1ffb01d7fed2e71d89d9be7da7202ebd68254d Mon Sep 17 00:00:00 2001 From: Matthew Meszaros Date: Tue, 3 Nov 2026 14:11:48 +0100 Subject: [PATCH] feat: keep reading past a mobile footer below a bare opt-out command, accept punctuation after a pronoun note, and refuse temporal words as name lines --- internal/app/replyclassify/optout_command.go | 13 +++++++------ internal/app/replyclassify/optout_command_test.go | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/internal/app/replyclassify/optout_command.go b/internal/app/replyclassify/optout_command.go index 9c385d372..4d6a896ee 100644 --- a/internal/app/replyclassify/optout_command.go +++ b/internal/app/replyclassify/optout_command.go @@ -45,7 +45,8 @@ var proseWords = wordSet("i", "me", "my", "we", "us", "our", "you", "your", "it" "do", "would", "could", "can", "will", "if", "so", "just", "actually", "love", "like", "want", "let", "lets", "interested", "please", "call", "send", "tell", "talk", "great", "sounds", "meeting", "demo", "price", "pricing", "yes", "no", "sure", "ok", "okay", "maybe", "later", "today", "tomorrow", "monday", "tuesday", "wednesday", "thursday", - "friday", "saturday", "sunday", "noon", "the", "a", "an", "at", "of", "and", "for", "to", "in", "on", "with", + "friday", "saturday", "sunday", "noon", "next", "week", "month", "year", "soon", "now", "asap", "time", "here", "there", + "the", "a", "an", "at", "of", "and", "for", "to", "in", "on", "with", "ich", "wir", "sie", "ist", "aber", "nicht") // commandPronouns is a pronoun note after a name: "(she/her)". @@ -93,17 +94,17 @@ func isOptOutCommand(body string) bool { } // signatureOnly is a closed whitelist of what may follow the command: blank -// lines, sign-off lines, name lines, and a "--" delimiter or a whole mobile -// footer, below which nothing is read. Any other line means it is not an +// lines, whole mobile footers, sign-off lines, name lines, and a "--" +// delimiter, below which nothing is read. Any other line means it is not an // opt-out. func signatureOnly(lines []string) bool { n := 0 for _, raw := range lines { ln := strings.TrimSpace(raw) switch { - case ln == "": + case ln == "" || commandFooters[commandText(ln)]: continue - case ln == "--" || commandFooters[commandText(ln)]: + case ln == "--": return true } if n++; n > commandMaxLines { @@ -131,7 +132,7 @@ func ledByName(raw string, phrases map[string]bool) bool { // nameLine is one to three capitalized name words or initials, optionally // followed by a pronoun note; a trailing comma or period is allowed. func nameLine(tokens []string) bool { - if len(tokens) > 0 && commandPronouns.MatchString(tokens[len(tokens)-1]) { + if len(tokens) > 0 && commandPronouns.MatchString(strings.TrimRight(tokens[len(tokens)-1], ",.")) { tokens = tokens[:len(tokens)-1] } if len(tokens) == 0 || len(tokens) > 3 { diff --git a/internal/app/replyclassify/optout_command_test.go b/internal/app/replyclassify/optout_command_test.go index 2d03a46ba..489ac8f47 100644 --- a/internal/app/replyclassify/optout_command_test.go +++ b/internal/app/replyclassify/optout_command_test.go @@ -37,6 +37,7 @@ func TestIsOptOutCommandReply(t *testing.T) { "german footer": "Stopp\n\nVon meinem iPhone gesendet", "notice": "Remove\n\n--\nCONFIDENTIALITY NOTICE: The contents of this message are private.", "pronouns": "STOP\nJane Doe (she/her)", + "pronouns comma": "STOP\nJane Doe (she/her),", "sign-off name": "Stop\n\nBest regards, J. Smith", } for name, body := range optOut { @@ -82,6 +83,8 @@ func TestIsOptOutCommandReply(t *testing.T) { "title-cased": "Stop\nMeeting at Noon", "too many lines": "Stop\nJohn\nJane\nJim\nJoe\nJack", "footer prefix": "Stop\nSent from my iPhone because I want a demo", + "after footer": "Stop\nSent from my iPhone\nActually I'd like a demo", + "next week": "Stop\nNext Week", } for name, body := range notOptOut { if IsOptOut("Re: Stop", body) {