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.

40 lines
1.4 KiB

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