diff options
| author | Bobby <[email protected]> | 2026-03-07 17:59:31 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2026-03-07 17:59:31 +0530 |
| commit | a6ec9a807df68978bf3b85314a4c54c60ecc2b7a (patch) | |
| tree | 6201e8d594a3c368cce50ebc402f248814e2025f /models | |
| parent | 57df54999e778887e66775481dab46191b46d0b6 (diff) | |
| download | dove-a6ec9a807df68978bf3b85314a4c54c60ecc2b7a.tar.xz dove-a6ec9a807df68978bf3b85314a4c54c60ecc2b7a.zip | |
feat: implement SMTP server with authentication, port validation, and email storage
Diffstat (limited to 'models')
| -rw-r--r-- | models/alias.go | 10 | ||||
| -rw-r--r-- | models/attachment.go | 14 | ||||
| -rw-r--r-- | models/email.go | 25 | ||||
| -rw-r--r-- | models/mailbox.go | 12 | ||||
| -rw-r--r-- | models/tag.go | 9 | ||||
| -rw-r--r-- | models/user.go | 10 |
6 files changed, 80 insertions, 0 deletions
diff --git a/models/alias.go b/models/alias.go new file mode 100644 index 0000000..5b0dcb3 --- /dev/null +++ b/models/alias.go @@ -0,0 +1,10 @@ +package models + +import "gorm.io/gorm" + +type Alias struct { + gorm.Model + SourceAddress string `gorm:"uniqueIndex;not null" json:"source_address"` + MailboxID uint `gorm:"not null" json:"mailbox_id"` + Mailbox Mailbox `gorm:"foreignKey:MailboxID" json:"mailbox"` +} diff --git a/models/attachment.go b/models/attachment.go new file mode 100644 index 0000000..cd1a741 --- /dev/null +++ b/models/attachment.go @@ -0,0 +1,14 @@ +package models + +import "gorm.io/gorm" + +type Attachment struct { + gorm.Model + EmailID uint `gorm:"not null;index" json:"email_id"` + Email Email `gorm:"foreignKey:EmailID" json:"email"` + Filename string `gorm:"not null" json:"filename"` + ContentType string `gorm:"not null" json:"content_type"` + ContentID string `json:"content_id"` + Size int64 `json:"size"` + IsInline bool `gorm:"default:false" json:"is_inline"` +} diff --git a/models/email.go b/models/email.go new file mode 100644 index 0000000..12b3ad1 --- /dev/null +++ b/models/email.go @@ -0,0 +1,25 @@ +package models + +import "gorm.io/gorm" + +type Email struct { + gorm.Model + MailboxID uint `gorm:"not null;index" json:"mailbox_id"` + Mailbox Mailbox `gorm:"foreignKey:MailboxID" json:"mailbox"` + MessageID string `gorm:"index" json:"message_id"` + Filename string `gorm:"uniqueIndex;not null" json:"filename"` + FromAddress string `gorm:"not null" json:"from_address"` + FromName string `json:"from_name"` + ToAddresses string `gorm:"not null" json:"to_addresses"` + CcAddresses string `json:"cc_addresses"` + BccAddresses string `json:"bcc_addresses"` + ReplyToAddress string `json:"reply_to_address"` + ReturnPath string `json:"return_path"` + Subject string `json:"subject"` + Snippet string `json:"snippet"` + Size int64 `json:"size"` + IsRead bool `gorm:"default:false;index" json:"is_read"` + AttachmentCount int `gorm:"default:0" json:"attachment_count"` + InlineCount int `gorm:"default:0" json:"inline_count"` + Tags []Tag `gorm:"many2many:email_tags" json:"tags"` +} diff --git a/models/mailbox.go b/models/mailbox.go new file mode 100644 index 0000000..da4114f --- /dev/null +++ b/models/mailbox.go @@ -0,0 +1,12 @@ +package models + +import "gorm.io/gorm" + +type Mailbox struct { + gorm.Model + Address string `gorm:"uniqueIndex;not null" json:"address"` + UserID uint `gorm:"not null" json:"user_id"` + User User `gorm:"foreignKey:UserID" json:"user"` + Aliases []Alias `gorm:"foreignKey:MailboxID" json:"aliases"` + Emails []Email `gorm:"foreignKey:MailboxID" json:"emails"` +} diff --git a/models/tag.go b/models/tag.go new file mode 100644 index 0000000..79fa65f --- /dev/null +++ b/models/tag.go @@ -0,0 +1,9 @@ +package models + +import "gorm.io/gorm" + +type Tag struct { + gorm.Model + Name string `gorm:"uniqueIndex;not null" json:"name"` + Emails []Email `gorm:"many2many:email_tags" json:"emails"` +} diff --git a/models/user.go b/models/user.go new file mode 100644 index 0000000..6bb6edf --- /dev/null +++ b/models/user.go @@ -0,0 +1,10 @@ +package models + +import "gorm.io/gorm" + +type User struct { + gorm.Model + Username string `gorm:"uniqueIndex;not null" json:"username"` + DisplayName string `json:"display_name"` + Mailboxes []Mailbox `gorm:"foreignKey:UserID" json:"mailboxes"` +} |
