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.6 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"` // Stored encrypted
  11. SymmetricKey string `gorm:"not null" json:"symmetric_key"` // Stored encrypted
  12. }
  13. type Message struct {
  14. Base
  15. MessageDataID uuid.UUID `json:"message_data_id"`
  16. MessageData MessageData `json:"message_data"`
  17. SymmetricKey string `json:"symmetric_key" gorm:"not null"` // Stored encrypted
  18. AssociationKey string `json:"association_key" gorm:"not null"` // TODO: This links all encrypted messages for a user in a thread together. Find a way to fix this
  19. CreatedAt time.Time `json:"created_at" gorm:"not null"`
  20. }
  21. type ConversationDetail struct {
  22. Base
  23. Name string `gorm:"not null" json:"name"` // Stored encrypted
  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. Admin string `gorm:"not null" json:"admin"` // Bool if user is admin of thread, stored encrypted
  32. SymmetricKey string `gorm:"not null" json:"symmetric_key"` // Stored encrypted
  33. // TODO: Add association_key here
  34. }