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.

33 lines
1.1 KiB

  1. package Models
  2. import "github.com/gofrs/uuid"
  3. type MessageData struct {
  4. Base
  5. Data []byte `gorm:"not null" json:"data"` // Stored encrypted
  6. SenderID []byte `gorm:"not null" json:"sender_id"`
  7. }
  8. type Message struct {
  9. Base
  10. MessageDataID uuid.UUID `json:"-"`
  11. MessageData MessageData `json:"message_data"`
  12. SymmetricKey []byte `gorm:"not null" json:"symmetric_key"` // Stored encrypted
  13. MessageThreadKey string `gorm:"not null" json:"message_thread_key"`
  14. }
  15. type MessageThread struct {
  16. Base
  17. Name []byte `gorm:"not null" json:"name"`
  18. Users []byte `json:"users"`
  19. }
  20. type MessageThreadUser struct {
  21. Base
  22. UserID uuid.UUID `gorm:"type:uuid;column:user_id;not null;" json:"user_id"`
  23. User User `json:"user"`
  24. MessageThreadID []byte `gorm:"not null" json:"message_thread_link_id"`
  25. MessageThreadKey []byte `gorm:"not null" json:"message_thread_key"`
  26. Admin []byte `gorm:"not null" json:"admin"` // Bool if user is admin of thread, stored encrypted
  27. SymmetricKey []byte `gorm:"not null" json:"symmetric_key"` // Stored encrypted
  28. }