automatically ignore known forwarded addresses, fixes #64
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
// Mailboxes config
|
||||
type MBXConfig struct {
|
||||
Reserved []string
|
||||
Forwarded []string
|
||||
Activation string
|
||||
}
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ func (e *parentEmail) fixtofrom(newSenderMailbox string, domains []string) strin
|
||||
return previousSender
|
||||
}
|
||||
|
||||
func (e *parentEmail) calculateRecipients(from string) {
|
||||
func (e *parentEmail) calculateRecipients(from string, forwardedFrom []string) {
|
||||
recipients := map[string]struct{}{}
|
||||
recipients[e.From] = struct{}{}
|
||||
|
||||
@@ -290,6 +290,10 @@ func (e *parentEmail) calculateRecipients(from string) {
|
||||
for _, addr := range email.AddressList(e.CC) {
|
||||
recipients[addr] = struct{}{}
|
||||
}
|
||||
|
||||
for _, addr := range forwardedFrom {
|
||||
delete(recipients, addr)
|
||||
}
|
||||
delete(recipients, from)
|
||||
|
||||
rcpts := make([]string, 0, len(recipients))
|
||||
@@ -351,7 +355,7 @@ func (b *Bot) getParentEmail(evt *event.Event, newFromMailbox string) *parentEma
|
||||
parent.InReplyTo = utils.EventField[string](&parentEvt.Content, eventMessageIDkey)
|
||||
parent.References = utils.EventField[string](&parentEvt.Content, eventReferencesKey)
|
||||
senderEmail := parent.fixtofrom(newFromMailbox, b.domains)
|
||||
parent.calculateRecipients(senderEmail)
|
||||
parent.calculateRecipients(senderEmail, b.mbxc.Forwarded)
|
||||
parent.MessageID = email.MessageID(parentEvt.ID, parent.FromDomain)
|
||||
if parent.InReplyTo == "" {
|
||||
parent.InReplyTo = parent.MessageID
|
||||
|
||||
Reference in New Issue
Block a user