add user join hub

This commit is contained in:
2026-04-27 20:16:36 +02:00
parent 67203c5971
commit 6f7a913e64
4 changed files with 101 additions and 37 deletions
+16 -16
View File
@@ -221,26 +221,24 @@ func (p *CachedUserPermissions) ClearCanMessage() { *p &^= CachedUserCanMessage
func (p CachedUserPermissions) CanMessage() bool { return p&CachedUserCanMessage != 0 }
type Hub struct {
Mu sync.RWMutex `json:"-"`
CreatedAt time.Time `json:"createdAt"`
Roles [256]*HubRole `json:"-"`
Users map[uuid.UUID]*HubUser `json:"-"`
Groups [256]*HubGroup `json:"-"`
Channels map[uuid.UUID]*HubChannel `json:"-"`
Name string `json:"name"`
IconUrl string `json:"iconUrl"`
BgUrl string `json:"backgroundUrl"`
JoinRole *HubRole `json:"joinRole"`
Id uuid.UUID `json:"id"`
Creator uuid.UUID `json:"creator"`
Color Rgba `json:"color"`
UserColorAllowed bool `json:"userColorAllowed"`
Mu sync.RWMutex `json:"-"`
CreatedAt time.Time `json:"createdAt"`
Roles [256]*HubRole `json:"-"`
Users map[uuid.UUID]*HubUser `json:"-"`
Groups [256]*HubGroup `json:"-"`
Name string `json:"name"`
IconUrl string `json:"iconUrl"`
BgUrl string `json:"backgroundUrl"`
JoinRole *HubRole `json:"joinRole"`
Id uuid.UUID `json:"id"`
Creator uuid.UUID `json:"creator"`
Color Rgba `json:"color"`
UserColorAllowed bool `json:"userColorAllowed"`
}
func NewHub() *Hub {
return &Hub{
Users: make(map[uuid.UUID]*HubUser),
Channels: make(map[uuid.UUID]*HubChannel),
Users: make(map[uuid.UUID]*HubUser),
}
}
@@ -282,12 +280,14 @@ type HubGroup struct {
Color Rgba `json:"color"`
RolesCanView HubBoundRoles `json:"rolesCanView"`
UsersCachedPermissions map[uuid.UUID]CachedUserPermissions `json:"-"`
Channels map[uuid.UUID]*HubChannel `json:"channels"`
Id uint8 `json:"id"` // Id 0 for unused
}
func NewHubGroup() *HubGroup {
return &HubGroup{
UsersCachedPermissions: make(map[uuid.UUID]CachedUserPermissions),
Channels: make(map[uuid.UUID]*HubChannel),
}
}