Skip to content

Commit

Permalink
Merge pull request #8 from whataboutpereira/write-header
Browse files Browse the repository at this point in the history
Split the header writing code into a separate writeHeader function.
  • Loading branch information
poolpOrg authored Sep 20, 2019
2 parents fd7973c + c757925 commit f6db88a
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions filter-rspamd.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,18 @@ func flushMessage(s session, token string) {
fmt.Printf("filter-dataline|%s|%s|.\n", token, s.id)
}

func writeHeader(s session, token string, h string, t string ) {
for i, line := range strings.Split( t, "\n") {
if i == 0 {
fmt.Printf("filter-dataline|%s|%s|%s: %s\n",
token, s.id, h, line)
} else {
fmt.Printf("filter-dataline|%s|%s|%s\n",
token, s.id, line)
}
}
}

func rspamdQuery(s session, token string) {
r := strings.NewReader(strings.Join(s.message, "\n"))
client := &http.Client{}
Expand Down Expand Up @@ -307,15 +319,7 @@ func rspamdQuery(s session, token string) {
}

if rr.DKIMSig != "" {
for i, line := range strings.Split(rr.DKIMSig, "\n") {
if i == 0 {
fmt.Printf("filter-dataline|%s|%s|%s: %s\n",
token, s.id, "DKIM-Signature", line)
} else {
fmt.Printf("filter-dataline|%s|%s|%s\n",
token, s.id, line)
}
}
writeHeader(s, token, "DKIM-Signature", rr.DKIMSig)
}

if rr.Action == "add header" {
Expand Down

0 comments on commit f6db88a

Please sign in to comment.