models

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2025 License: MIT Imports: 2 Imported by: 1

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 ChatToAPIStruct(chat Chat) sw.Chat

func MessageToAPIStatus added in v1.0.3

func MessageToAPIStatus(message Message) sw.Message

func UserToAPIStruct added in v1.0.3

func UserToAPIStruct(user User) sw.User

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

func ChatFromAPIStruct(chat sw.Chat) Chat

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

func MessageFromAPIStruct(message sw.Message) Message

type Token

type Token struct {
	ID           string    `gorm:"primaryKey"`
	UserID       string    `gorm:"not null;index"`
	RefreshToken string    `gorm:"not null;unique"`
	ExpiresAt    time.Time `gorm:"not null"`

	User User `gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE"`
}

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

func UserFromAPIStruct(user sw.User) User

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL