119 lines
2.3 KiB
Go
119 lines
2.3 KiB
Go
package db
|
|
|
|
import "time"
|
|
|
|
type Domain struct {
|
|
ID int64
|
|
DomainName string
|
|
IsActive bool
|
|
CreatedAt time.Time
|
|
VerificationToken string
|
|
IsVerified bool
|
|
VerifiedAt *time.Time
|
|
// MFAExempt overrides [Auth] enforce_mailbox_mfa off for every mailbox under this
|
|
// domain, regardless of that mailbox's own MFAExempt.
|
|
MFAExempt bool
|
|
}
|
|
|
|
type Sender struct {
|
|
ID int64
|
|
Email string
|
|
PasswordHash string
|
|
DomainID int64
|
|
CanSendAsDomain bool
|
|
IsActive bool
|
|
CreatedAt time.Time
|
|
StoreMessageContent bool
|
|
}
|
|
|
|
// CanSendAs mirrors Sender.can_send_as in models.py.
|
|
func (s Sender) CanSendAs(fromAddress string) bool {
|
|
if equalFold(fromAddress, s.Email) {
|
|
return true
|
|
}
|
|
if !s.CanSendAsDomain {
|
|
return false
|
|
}
|
|
senderDomain := domainPart(s.Email)
|
|
fromDomain := domainPart(fromAddress)
|
|
return senderDomain != "" && senderDomain == fromDomain
|
|
}
|
|
|
|
type WhitelistedIP struct {
|
|
ID int64
|
|
IPAddress string
|
|
DomainID int64
|
|
IsActive bool
|
|
CreatedAt time.Time
|
|
StoreMessageContent bool
|
|
}
|
|
|
|
type EmailLog struct {
|
|
ID int64
|
|
MessageID string
|
|
Timestamp time.Time
|
|
PeerIP string
|
|
MailFrom string
|
|
ToAddress string
|
|
CcAddresses string
|
|
BccAddresses string
|
|
Subject string
|
|
EmailHeaders string
|
|
MessageBody string
|
|
Status string
|
|
DKIMSigned bool
|
|
Username string
|
|
CreatedAt time.Time
|
|
}
|
|
|
|
type EmailRecipientLog struct {
|
|
ID int64
|
|
EmailLogID int64
|
|
Recipient string
|
|
RecipientType string
|
|
Status string
|
|
ErrorCode string
|
|
ErrorMessage string
|
|
ServerResponse string
|
|
}
|
|
|
|
type AuthLog struct {
|
|
ID int64
|
|
AuthType string
|
|
Identifier string
|
|
IPAddress string
|
|
Success bool
|
|
Message string
|
|
CreatedAt time.Time
|
|
}
|
|
|
|
type DKIMKey struct {
|
|
ID int64
|
|
DomainID int64
|
|
Selector string
|
|
PrivateKey string
|
|
PublicKey string
|
|
IsActive bool
|
|
CreatedAt time.Time
|
|
ReplacedAt *time.Time
|
|
}
|
|
|
|
type CustomHeader struct {
|
|
ID int64
|
|
DomainID int64
|
|
HeaderName string
|
|
HeaderValue string
|
|
IsActive bool
|
|
CreatedAt time.Time
|
|
}
|
|
|
|
type EmailAttachment struct {
|
|
ID int64
|
|
EmailLogID int64
|
|
Filename string
|
|
ContentType string
|
|
FilePath string
|
|
Size int64
|
|
UploadedAt time.Time
|
|
}
|