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
2.1 KiB

2 years ago
2 years ago
  1. package Models
  2. import (
  3. "time"
  4. "github.com/gofrs/uuid"
  5. )
  6. // ConversationDetail stores the name for the conversation
  7. type ConversationDetail struct {
  8. Base
  9. Name string `gorm:"not null" json:"name"` // Stored encrypted
  10. Users []ConversationDetailUser ` json:"users"`
  11. TwoUser string `gorm:"not null" json:"two_user"`
  12. AttachmentID *uuid.UUID ` json:"attachment_id"`
  13. Attachment Attachment ` json:"attachment"`
  14. }
  15. // ConversationDetailUser all users associated with a customer
  16. type ConversationDetailUser struct {
  17. Base
  18. ConversationDetailID uuid.UUID `gorm:"not null" json:"conversation_detail_id"`
  19. ConversationDetail ConversationDetail `gorm:"not null" json:"conversation"`
  20. UserID string `gorm:"not null" json:"user_id"` // Stored encrypted
  21. Username string `gorm:"not null" json:"username"` // Stored encrypted
  22. Admin string `gorm:"not null" json:"admin"` // Stored encrypted
  23. AssociationKey string `gorm:"not null" json:"association_key"` // Stored encrypted
  24. PublicKey string `gorm:"not null" json:"public_key"` // Stored encrypted
  25. }
  26. // UserConversation Used to link the current user to their conversations
  27. type UserConversation struct {
  28. Base
  29. UserID uuid.UUID `gorm:"type:uuid;column:user_id;not null;" json:"user_id"`
  30. User User ` json:"user"`
  31. ConversationDetailID string `gorm:"not null" json:"conversation_detail_id"` // 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. CreatedAt time.Time `gorm:"not null" json:"created_at"`
  35. }