package Models
|
|
|
|
import (
|
|
"database/sql"
|
|
"time"
|
|
|
|
"github.com/gofrs/uuid"
|
|
)
|
|
|
|
// MessageData holds the content of the message
|
|
// encrypted through the Message.SymmetricKey
|
|
type MessageData struct {
|
|
Base
|
|
Data string ` json:"data"` // Stored encrypted
|
|
AttachmentID *uuid.UUID ` json:"attachment_id"`
|
|
Attachment Attachment ` json:"attachment"`
|
|
SenderID string `gorm:"not null" json:"sender_id"` // Stored encrypted
|
|
SymmetricKey string `gorm:"not null" json:"symmetric_key"` // Stored encrypted
|
|
}
|
|
|
|
// Message holds data pertaining to each users' message
|
|
type Message struct {
|
|
Base
|
|
MessageDataID uuid.UUID ` json:"message_data_id"`
|
|
MessageData MessageData ` json:"message_data"`
|
|
SymmetricKey string `gorm:"not null" json:"symmetric_key"` // Stored encrypted
|
|
AssociationKey string `gorm:"not null" json:"association_key"` // Stored encrypted
|
|
ExpiryRaw string ` json:"expiry"`
|
|
Expiry sql.NullTime ` json:"-"`
|
|
CreatedAt time.Time `gorm:"not null" json:"created_at"`
|
|
}
|