diff --git a/pkg/analyzer/spamassassin.go b/pkg/analyzer/spamassassin.go index 6ab41cc..cb80fe6 100644 --- a/pkg/analyzer/spamassassin.go +++ b/pkg/analyzer/spamassassin.go @@ -214,7 +214,7 @@ func (a *SpamAssassinAnalyzer) CalculateSpamAssassinScore(result *api.SpamAssass return 0, "F" // Failed spam test } else { // Linear scale between 0 and required threshold - percentage := 100 - int(math.Round(float64(score*100/result.RequiredScore))) - return percentage, ScoreToGrade(percentage - 15) + percentage := 100 - int(math.Round(float64(score*100/(2*result.RequiredScore)))) + return percentage, ScoreToGrade(percentage - 5) } } diff --git a/pkg/analyzer/spamassassin_test.go b/pkg/analyzer/spamassassin_test.go index 16ff854..b539f24 100644 --- a/pkg/analyzer/spamassassin_test.go +++ b/pkg/analyzer/spamassassin_test.go @@ -181,7 +181,7 @@ func TestGetSpamAssassinScore(t *testing.T) { Score: 2.0, RequiredScore: 5.0, }, - expectedScore: 60, // 100 - round(2*100/5) = 100 - 40 = 60 + expectedScore: 80, // 100 - round(2*100/5) = 100 - 40 = 60 }, { name: "Score at threshold", diff --git a/web/src/lib/components/SummaryCard.svelte b/web/src/lib/components/SummaryCard.svelte index 43ea811..971c1ac 100644 --- a/web/src/lib/components/SummaryCard.svelte +++ b/web/src/lib/components/SummaryCard.svelte @@ -336,6 +336,7 @@ // Content/spam assessment const spamAssassin = report.spamassassin; const contentScore = report.summary?.content_score || 0; + const spamScore = report.summary?.spam_score || 0; segments.push({ text: ". " }); if (spamAssassin?.is_spam) { @@ -353,13 +354,34 @@ highlight: { color: "warning", bold: true }, link: "#content-details" }); - } else if (contentScore >= 100) { + } else if (contentScore >= 100 && spamScore >= 100) { segments.push({ text: "Content " }); segments.push({ text: "looks great", highlight: { color: "good", bold: true }, link: "#content-details" }); + } else if (spamScore < 50) { + segments.push({ text: "Your " }); + segments.push({ + text: "spam score", + highlight: { color: "danger", bold: true }, + link: "#spam-details" + }); + segments.push({ text: " is low" }); + if (report.spamassassin.tests.includes("EMPTY_MESSAGE")) { + segments.push({ text: " (you sent an empty message, which can cause this issue, retry with some real content)", highlight: { bold: true } }); + } + } else if (spamScore < 90) { + segments.push({ text: "Pay attention to your " }); + segments.push({ + text: "spam score", + highlight: { color: "warning", bold: true }, + link: "#spam-details" + }); + if (report.spamassassin.tests.includes("EMPTY_MESSAGE")) { + segments.push({ text: " (you sent an empty message, which can cause this issue, retry with some real content)", highlight: { bold: true } }); + } } else if (contentScore >= 80) { segments.push({ text: "Content " }); segments.push({