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.

35 lines
1.3 KiB

  1. package Models
  2. import "github.com/gofrs/uuid"
  3. // TODO: Add support for images
  4. type MessageData struct {
  5. Base
  6. Data string `gorm:"not null" json:"data"` // Stored encrypted
  7. SenderID string `gorm:"not null" json:"sender_id"`
  8. }
  9. type Message struct {
  10. Base
  11. MessageDataID uuid.UUID `json:"-"`
  12. MessageData MessageData `json:"message_data"`
  13. SymmetricKey string `gorm:"not null" json:"symmetric_key"` // Stored encrypted
  14. MessageThreadKey string `gorm:"not null" json:"message_thread_key"`
  15. }
  16. // TODO: Rename to ConversationDetails
  17. type ConversationDetail struct {
  18. Base
  19. Name string `gorm:"not null" json:"name"`
  20. Users string `json:"users"` // Stored as encrypted JSON
  21. }
  22. type UserConversation struct {
  23. Base
  24. UserID uuid.UUID `gorm:"type:uuid;column:user_id;not null;" json:"user_id"`
  25. User User `json:"user"`
  26. ConversationDetailID string `gorm:"not null" json:"conversation_detail_id"` // Stored encrypted
  27. MessageThreadKey string `gorm:"not null" json:"message_thread_key"` // Stored encrypted
  28. Admin string `gorm:"not null" json:"admin"` // Bool if user is admin of thread, stored encrypted
  29. SymmetricKey string `gorm:"not null" json:"symmetric_key"` // Stored encrypted
  30. }