Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChatParticipantsToAPIStruct ¶ added in v1.0.3
func ChatParticipantsToAPIStruct(chatParticipants ChatParticipants) (sw.Chat, sw.User)
func ChatToAPIStruct ¶ added in v1.0.3
func MessageToAPIStatus ¶ added in v1.0.3
func UserToAPIStruct ¶ added in v1.0.3
Types ¶
type Chat ¶
type Chat struct {
ID string `gorm:"primaryKey"`
Name string
Type string `gorm:"not null;check:type IN ('private', 'public')"`
Messages []Message `gorm:"foreignKey:ChatID"`
Participants []ChatParticipants `gorm:"foreignKey:ChatID"`
}
func ChatFromAPIStruct ¶ added in v1.0.3
type ChatParticipants ¶ added in v1.0.2
type ChatParticipants struct {
ChatID string `gorm:"primaryKey"`
UserID string `gorm:"primaryKey"`
Chat *Chat `gorm:"foreignKey:ChatID;constraint:OnDelete:CASCADE"`
User *User `gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE"`
}
func ChatParticipantsFromAPIStruct ¶ added in v1.0.3
func ChatParticipantsFromAPIStruct(chat sw.Chat, user sw.User) ChatParticipants
type Message ¶
type Message struct {
ID string `gorm:"primaryKey"`
SenderID string `gorm:"not null"`
ChatID string `gorm:"not null"`
EncryptedContent string `gorm:"not null"`
Timestamp time.Time `gorm:"autoCreateTime"`
Status string `gorm:"type:string;default:'undelivered'"`
Sender *User `gorm:"foreignKey:SenderID;constraint:OnDelete:CASCADE"`
Chat *Chat `gorm:"foreignKey:ChatID;constraint:OnDelete:CASCADE"`
}
func MessageFromAPIStruct ¶ added in v1.0.3
type User ¶
type User struct {
ID string `gorm:"primaryKey"`
Username string `gorm:"uniqueIndex;not null"`
DisplayName string
AvatarUrl string
Status string `gorm:"type:string;default:'offline'"`
LastSeen time.Time `gorm:"autoUpdateTime"`
Messages []Message `gorm:"foreignKey:SenderID"`
ChatMembers []ChatParticipants `gorm:"foreignKey:UserID"`
}
func UserFromAPIStruct ¶ added in v1.0.3
Click to show internal directories.
Click to hide internal directories.