54 lines
1.5 KiB
Go
54 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/coder/websocket"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type User struct {
|
|
Name string
|
|
Pronouns string
|
|
PasswordHash string
|
|
CreatedAt time.Time
|
|
WsConn *websocket.Conn
|
|
Id uint32
|
|
Groups map[uint32]struct{}
|
|
Connections map[uuid.UUID]*Connection
|
|
Color [3]uint8
|
|
}
|
|
|
|
type Connection struct {
|
|
Id uuid.UUID `json:"id"`
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
MessagesBuf [MaxDirectMsgCache]*Message `json:"-"`
|
|
RequestorId uint32 `json:"requestorId"`
|
|
RecipientId uint32 `json:"recipientId"`
|
|
State uint8 `json:"state"`
|
|
}
|
|
|
|
type Message struct {
|
|
Id uuid.UUID `json:"id"`
|
|
Content string `json:"content"`
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
Sender uint32 `json:"sender"`
|
|
IsGroupMessage bool `json:"isGroupMessage"`
|
|
}
|
|
|
|
type Group struct {
|
|
Name string `json:"name"`
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
Id uint32 `json:"-"`
|
|
CreatorId uint32 `json:"creatorId"`
|
|
OwnerId uint32 `json:"ownerId"`
|
|
Users map[uint32]struct{} `json:"-"`
|
|
Color [3]uint8 `json:"color"`
|
|
EnableUserColors bool `json:"enableUserColors"`
|
|
}
|
|
|
|
type LoginReturn struct {
|
|
Token string `json:"token"`
|
|
UserId uint32 `json:"userId"`
|
|
}
|