fix hub bugs, add channel role permission endpoints
Covers: snake_case param renames, mutex RLock/Unlock mismatches, user.Hubs keyed by hub.Id, hub color using new_name, DELETE params sent as query, delete(target.Hubs, hub.Id), root/member role Id swap, and the three new PATCH /hub/channel/roles/* handlers.
This commit is contained in:
+18
-16
@@ -264,24 +264,25 @@ 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:"-"`
|
||||
Channels [256]*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:"-"`
|
||||
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"`
|
||||
}
|
||||
|
||||
func NewHub() *Hub {
|
||||
return &Hub{
|
||||
Users: make(map[uuid.UUID]*HubUser),
|
||||
Users: make(map[uuid.UUID]*HubUser),
|
||||
Channels: map[uuid.UUID]*HubChannel{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,9 +306,9 @@ func (h *HubRole) HasPermission(r Permissions) bool {
|
||||
}
|
||||
|
||||
type HubUser struct {
|
||||
Mu sync.RWMutex `json:"mu"`
|
||||
Mu sync.RWMutex `json:"-"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
Roles HubBoundRoles `json:"-"`
|
||||
Roles HubBoundRoles `json:"roles"`
|
||||
Name string `json:"name"` // Name empty = original name
|
||||
OriginalId uuid.UUID `json:"originalId"`
|
||||
IsMuted bool `json:"isMuted"`
|
||||
@@ -330,6 +331,7 @@ type HubChannel struct {
|
||||
UsersCachedPermissions map[uuid.UUID]CachedUserPermissions `json:"-"`
|
||||
NextBuffIdx uint32 `json:"-"`
|
||||
Id uuid.UUID `json:"id"`
|
||||
Position uint8 `json:"position"`
|
||||
HaveOverflowed bool `json:"-"`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user