Encrypted messaging app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.1 KiB

  1. package Models
  2. import (
  3. "database/sql"
  4. "time"
  5. "github.com/gofrs/uuid"
  6. )
  7. // MessageData holds the content of the message
  8. // encrypted through the Message.SymmetricKey
  9. type MessageData struct {
  10. Base
  11. Data string ` json:"data"` // Stored encrypted
  12. AttachmentID *uuid.UUID ` json:"attachment_id"`
  13. Attachment Attachment ` json:"attachment"`
  14. SenderID string `gorm:"not null" json:"sender_id"` // Stored encrypted
  15. SymmetricKey string `gorm:"not null" json:"symmetric_key"` // Stored encrypted
  16. }
  17. // Message holds data pertaining to each users' message
  18. type Message struct {
  19. Base
  20. MessageDataID uuid.UUID ` json:"message_data_id"`
  21. MessageData MessageData ` json:"message_data"`
  22. SymmetricKey string `gorm:"not null" json:"symmetric_key"` // Stored encrypted
  23. AssociationKey string `gorm:"not null" json:"association_key"` // Stored encrypted
  24. Expiry sql.NullTime ` json:"expiry"`
  25. CreatedAt time.Time `gorm:"not null" json:"created_at"`
  26. }