Files
mailgoserver/internal/db/models.go
T
2026-08-12 12:56:22 +01:00

116 lines
2.2 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
}
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
}