add hub function

This commit is contained in:
cos
2026-04-30 11:44:54 +02:00
parent 909d222a89
commit 0afed9a326
10 changed files with 203 additions and 128 deletions
+20 -17
View File
@@ -18,7 +18,8 @@ import (
type Rgba [4]uint8
type Sha256Hash [sha256.Size]byte
func (r Rgba) GetRandom() Rgba {
func RandomRgba() Rgba {
var r Rgba
for i := range r {
r[i] = uint8(rand.IntN(256))
}
@@ -26,19 +27,19 @@ func (r Rgba) GetRandom() Rgba {
}
type User struct {
Mu sync.RWMutex `json:"-"`
Name string `json:"name"`
Pronouns string `json:"pronouns"`
Description string `json:"description"`
AvatarType string `json:"avatarType"`
ProfileBgType string `json:"profileBackgroundType"`
PasswordHash string `json:"-"`
CreatedAt time.Time `json:"createdAt"`
WsConn *websocket.Conn `json:"-"`
Id uuid.UUID `json:"-"`
Connections map[uuid.UUID]*Connection `json:"-"`
Hubs map[uuid.UUID]*Hub `json:"-"`
Color Rgba `json:"color"`
Mu sync.RWMutex `json:"-"`
Name string `json:"name"`
Pronouns string `json:"pronouns"`
Description string `json:"description"`
AvatarKey string `json:"avatarType"`
ProfileBgKey string `json:"profileBackgroundType"`
PasswordHash string `json:"-"`
CreatedAt time.Time `json:"createdAt"`
WsConn *websocket.Conn `json:"-"`
Id uuid.UUID `json:"-"`
Connections map[uuid.UUID]*Connection `json:"-"`
Hubs map[uuid.UUID]*Hub `json:"-"`
Color Rgba `json:"color"`
}
type UserProfileUpdateList struct {
@@ -122,7 +123,7 @@ type Message struct {
Receiver uuid.UUID `json:"receiver"`
}
type LoginReturn struct {
type LoginResponse struct {
Token string `json:"token"`
UserId uuid.UUID `json:"userId"`
}
@@ -149,14 +150,16 @@ const (
PermissionSetUserColorAllowed
// User permissions
PermissionAddUser
PermissionInviteUser
PermissionRemoveUser
PermissionRenameUser
PermissionSelfRename
PermissionMuteUser
PermissionUserAddRole
PermissionUserRemoveRole
// Role permissions
PermissionAddRole
PermissionCreateRole
PermissionRemoveRole
PermissionSetRoleName
PermissionSetRoleColor