add channel: remove create set name logic
This commit is contained in:
+21
-22
@@ -167,9 +167,10 @@ const (
|
||||
PermissionSetRolePermissions
|
||||
|
||||
// Channel permissions
|
||||
PermissionAddChannel
|
||||
PermissionCreateChannel
|
||||
PermissionRemoveChannel
|
||||
PermissionSetChannelName
|
||||
PermissionSetChannelDescription
|
||||
PermissionSetChannelIcon
|
||||
PermissionSetChannelPermittedVisibleRoles
|
||||
PermissionSetChannelPermittedSendMessageRoles
|
||||
@@ -196,7 +197,7 @@ var permissionRegistry = map[string]Permissions{
|
||||
"set_role_color": PermissionSetRoleColor,
|
||||
"set_role_permissions": PermissionSetRolePermissions,
|
||||
"self_role_remove": PermissionUserSelfRoleRemove,
|
||||
"add_channel": PermissionAddChannel,
|
||||
"add_channel": PermissionCreateChannel,
|
||||
"remove_channel": PermissionRemoveChannel,
|
||||
"set_channel_name": PermissionSetChannelName,
|
||||
"set_channel_icon": PermissionSetChannelIcon,
|
||||
@@ -233,10 +234,10 @@ type HubBoundRoles [3]uint64
|
||||
|
||||
const HubBoundRolesMax uint8 = 191
|
||||
|
||||
func (r *HubBoundRoles) Add(bit uint8) { r[bit>>6] |= 1 << (bit & 63) }
|
||||
func (r *HubBoundRoles) Remove(bit uint8) { r[bit>>6] &^= 1 << (bit & 63) }
|
||||
func (r *HubBoundRoles) Has(bit uint8) bool { return r[bit>>6]>>(bit&63)&1 == 1 }
|
||||
func (r *HubBoundRoles) HasSameId(against HubBoundRoles) bool {
|
||||
func (r *HubBoundRoles) Add(bit uint8) { r[bit>>6] |= 1 << (bit & 63) }
|
||||
func (r *HubBoundRoles) Remove(bit uint8) { r[bit>>6] &^= 1 << (bit & 63) }
|
||||
func (r *HubBoundRoles) ContainsRoleId(bit uint8) bool { return r[bit>>6]>>(bit&63)&1 == 1 }
|
||||
func (r *HubBoundRoles) DoesIntersect(against HubBoundRoles) bool {
|
||||
return against[0]&r[0] != 0 || against[1]&r[1] != 0 || against[2]&r[2] != 0
|
||||
}
|
||||
|
||||
@@ -263,25 +264,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:"-"`
|
||||
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:"-"`
|
||||
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"`
|
||||
}
|
||||
|
||||
func NewHub() *Hub {
|
||||
return &Hub{
|
||||
Users: make(map[uuid.UUID]*HubUser),
|
||||
Channels: make(map[uuid.UUID]*HubChannel),
|
||||
Users: make(map[uuid.UUID]*HubUser),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,7 +330,6 @@ 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