1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2026-01-08 04:01:55 +00:00

policy: Impl Addressing{} and Recipient{} for #84

This commit is contained in:
James Hillyerd
2018-03-17 11:15:17 -07:00
parent d132efd6fa
commit 469a778d81
4 changed files with 167 additions and 49 deletions

25
pkg/policy/recipient.go Normal file
View File

@@ -0,0 +1,25 @@
package policy
import "net/mail"
// Recipient represents a potential email recipient, allows policies for it to be queried.
type Recipient struct {
mail.Address
apolicy *Addressing
// LocalPart is the part of the address before @, including +extension.
LocalPart string
// Domain is the part of the address after @.
Domain string
// Mailbox is the canonical mailbox name for this recipient.
Mailbox string
}
// ShouldAccept returns true if Inbucket should accept mail for this recipient.
func (r *Recipient) ShouldAccept() bool {
return true
}
// ShouldStore returns true if Inbucket should store mail for this recipient.
func (r *Recipient) ShouldStore() bool {
return r.apolicy.ShouldStoreDomain(r.Domain)
}