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.

26 lines
872 B

  1. package Models
  2. import "github.com/gofrs/uuid"
  3. const (
  4. MessageTypeSender = "sender"
  5. MessageTypeReceiver = "reciever"
  6. )
  7. type MessageData struct {
  8. Base
  9. Data []byte `gorm:"not null" json:"data"` // Stored encrypted
  10. }
  11. // TODO: Rename this to something better
  12. type Message struct {
  13. Base
  14. ThreadID uuid.UUID `gorm:"not null" json:"thread_id"`
  15. UserID uuid.UUID `json:"-"`
  16. User User `json:"user"`
  17. MessageDataID uuid.UUID `json:"-"`
  18. MessageData MessageData `json:"message_data"`
  19. MessageType string `gorm:"not null" json:"message_type"` // sender / reciever
  20. RelationalUserId []byte `gorm:"not null" json:"relational_user_id"` // Stored encrypted. UserID for the user this message is in relation to
  21. SymmetricKey string `gorm:"not null" json:"symmetric_key"` // Stored encrypted
  22. }