summaryrefslogtreecommitdiff
path: root/models/email.go
blob: 5c884ea2baf753758406fe3bd66005327f26ea6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package models

import (
	"time"

	"gorm.io/gorm"
)

type Email struct {
	ID            uint   `gorm:"primaryKey"`
	UserEmail     string `gorm:"index:idx_user_folder,priority:1;not null"`
	FolderID      uint   `gorm:"index:idx_user_folder,priority:2;not null"`
	UID           uint32 `gorm:"not null"`
	MessageID     string `gorm:"index"`
	From          string `gorm:"not null"`
	FromName      string
	To            string `gorm:"not null"`
	CC            string
	BCC           string
	ReplyTo       string
	Subject       string
	Date          time.Time `gorm:"index"`
	BodyText      string    `gorm:"type:text"`
	BodyHTML      string    `gorm:"type:text"`
	RawHeaders    string    `gorm:"type:text"`
	Snippet       string
	Size          int64
	InReplyTo     string
	IsRead        bool `gorm:"default:false"`
	IsFlagged     bool `gorm:"default:false"`
	IsAnswered    bool `gorm:"default:false"`
	IsDraft       bool `gorm:"default:false"`
	HasAttachment bool `gorm:"default:false"`

	Folder      Folder       `gorm:"foreignKey:FolderID"`
	Attachments []Attachment `gorm:"foreignKey:EmailID"`

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

type Attachment struct {
	gorm.Model
	EmailID uint
	Email   Email `gorm:"foreignKey:EmailID"`

	Filename    string
	ContentType string
	Size        int64
	ContentID   string
	MinIOPath   string `gorm:"index"`
}