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.

45 lines
3.3 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. MessageExpiryDefault MessageExpiry `gorm:"default:no_expiry" json:"-" sql:"type:ENUM('fifteen_min', 'thirty_min', 'one_hour', 'three_hour', 'six_hour', 'twelve_hour', 'one_day', 'three_day', 'no_expiry')"` // Stored encrypted
  15. MessageExpiry string `gorm:"-" json:"message_expiry"` // Stored encrypted
  16. AdminAddMembers string ` json:"admin_add_members"` // Stored encrypted
  17. AdminEditInfo string ` json:"admin_edit_info"` // Stored encrypted
  18. AdminSendMessages string ` json:"admin_send_messages"` // Stored encrypted
  19. }
  20. // ConversationDetailUser all users associated with a customer
  21. type ConversationDetailUser struct {
  22. Base
  23. ConversationDetailID uuid.UUID `gorm:"not null" json:"conversation_detail_id"`
  24. ConversationDetail ConversationDetail `gorm:"not null" json:"conversation"`
  25. UserID string `gorm:"not null" json:"user_id"` // Stored encrypted
  26. Username string `gorm:"not null" json:"username"` // Stored encrypted
  27. Admin string `gorm:"not null" json:"admin"` // Stored encrypted
  28. AssociationKey string `gorm:"not null" json:"association_key"` // Stored encrypted
  29. PublicKey string `gorm:"not null" json:"public_key"` // Stored encrypted
  30. }
  31. // UserConversation Used to link the current user to their conversations
  32. type UserConversation struct {
  33. Base
  34. UserID uuid.UUID `gorm:"type:uuid;column:user_id;not null;" json:"user_id"`
  35. User User ` json:"user"`
  36. ConversationDetailID string `gorm:"not null" json:"conversation_detail_id"` // Stored encrypted
  37. Admin string `gorm:"not null" json:"admin"` // Bool if user is admin of thread, stored encrypted
  38. SymmetricKey string `gorm:"not null" json:"symmetric_key"` // Stored encrypted
  39. CreatedAt time.Time `gorm:"not null" json:"created_at"`
  40. }