feat: add raw report display to rspamd card
Add a collapsible Raw Report section to RspamdCard, storing the raw X-Spamd-Result header value and displaying it like SpamAssassin's report.
This commit is contained in:
parent
d9b9ea87c6
commit
27650a3496
3 changed files with 29 additions and 3 deletions
|
|
@ -982,6 +982,9 @@ components:
|
||||||
name: "BAYES_HAM"
|
name: "BAYES_HAM"
|
||||||
score: -1.9
|
score: -1.9
|
||||||
params: "0.02"
|
params: "0.02"
|
||||||
|
report:
|
||||||
|
type: string
|
||||||
|
description: Full rspamd report (raw X-Spamd-Result header)
|
||||||
|
|
||||||
RspamdSymbol:
|
RspamdSymbol:
|
||||||
type: object
|
type: object
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,8 @@ func (a *RspamdAnalyzer) AnalyzeRspamd(email *EmailMessage) *api.RspamdResult {
|
||||||
// Parse X-Spamd-Result header (primary source for score, threshold, and symbols)
|
// Parse X-Spamd-Result header (primary source for score, threshold, and symbols)
|
||||||
// Format: "default: False [-3.91 / 15.00];\n\tSYMBOL(score)[params]; ..."
|
// Format: "default: False [-3.91 / 15.00];\n\tSYMBOL(score)[params]; ..."
|
||||||
if spamdResult, ok := headers["X-Spamd-Result"]; ok {
|
if spamdResult, ok := headers["X-Spamd-Result"]; ok {
|
||||||
|
report := strings.ReplaceAll(spamdResult, "; ", ";\n")
|
||||||
|
result.Report = &report
|
||||||
a.parseSpamdResult(spamdResult, result)
|
a.parseSpamdResult(spamdResult, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,7 @@
|
||||||
|
|
||||||
const effectiveAction = $derived.by(() => {
|
const effectiveAction = $derived.by(() => {
|
||||||
const rejectThreshold = rspamd.threshold > 0 ? rspamd.threshold : 15;
|
const rejectThreshold = rspamd.threshold > 0 ? rspamd.threshold : 15;
|
||||||
if (rspamd.score >= rejectThreshold)
|
if (rspamd.score >= rejectThreshold) return { label: "Reject", cls: "bg-danger" };
|
||||||
return { label: "Reject", cls: "bg-danger" };
|
|
||||||
if (rspamd.score >= RSPAMD_ADD_HEADER_THRESHOLD)
|
if (rspamd.score >= RSPAMD_ADD_HEADER_THRESHOLD)
|
||||||
return { label: "Add header", cls: "bg-warning text-dark" };
|
return { label: "Add header", cls: "bg-warning text-dark" };
|
||||||
if (rspamd.score >= RSPAMD_GREYLIST_THRESHOLD)
|
if (rspamd.score >= RSPAMD_GREYLIST_THRESHOLD)
|
||||||
|
|
@ -31,7 +30,7 @@
|
||||||
<div class="card-header {$theme === 'light' ? 'bg-white' : 'bg-dark'}">
|
<div class="card-header {$theme === 'light' ? 'bg-white' : 'bg-dark'}">
|
||||||
<h4 class="mb-0 d-flex justify-content-between align-items-center">
|
<h4 class="mb-0 d-flex justify-content-between align-items-center">
|
||||||
<span>
|
<span>
|
||||||
<i class="bi bi-shield-exclamation me-2"></i>
|
<i class="bi bi-bug me-2"></i>
|
||||||
rspamd Analysis
|
rspamd Analysis
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
|
|
@ -108,10 +107,32 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if rspamd.report}
|
||||||
|
<details class="mt-3">
|
||||||
|
<summary class="cursor-pointer fw-bold">Raw Report</summary>
|
||||||
|
<pre
|
||||||
|
class="mt-2 small {$theme === 'light'
|
||||||
|
? 'bg-light'
|
||||||
|
: 'bg-secondary'} p-3 rounded">{rspamd.report}</pre>
|
||||||
|
</details>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.cursor-pointer {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
details summary {
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
details summary:hover {
|
||||||
|
color: var(--bs-primary);
|
||||||
|
}
|
||||||
|
|
||||||
/* Darker table colors in dark mode */
|
/* Darker table colors in dark mode */
|
||||||
:global([data-bs-theme="dark"]) .table-warning {
|
:global([data-bs-theme="dark"]) .table-warning {
|
||||||
--bs-table-bg: rgba(255, 193, 7, 0.2);
|
--bs-table-bg: rgba(255, 193, 7, 0.2);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue