rework of hubs
This commit is contained in:
+11
-37
@@ -152,25 +152,18 @@ const (
|
||||
PermissionAddUser
|
||||
PermissionRemoveUser
|
||||
PermissionRenameUser
|
||||
PermissionSelfRename
|
||||
PermissionMuteUser
|
||||
|
||||
// Role permissions
|
||||
PermissionAddRole
|
||||
PermissionRemoveRole
|
||||
PermissionChangeRoleName
|
||||
PermissionChangeRoleColor
|
||||
PermissionChangeRoleGlobals
|
||||
PermissionSetRoleName
|
||||
PermissionSetRoleColor
|
||||
|
||||
PermissionNoSelfRoleRemove
|
||||
PermissionSelfRoleRemove
|
||||
PermissionOnlySelfRoleRemove
|
||||
|
||||
// Channel group permissions
|
||||
PermissionAddChannelGroup
|
||||
PermissionRemoveChannelGroup
|
||||
PermissionSetChannelGroupName
|
||||
PermissionSetChannelGroupColor
|
||||
PermissionSetChannelGroupPermittedVisibleRoles
|
||||
|
||||
// Channel permissions
|
||||
PermissionAddChannel
|
||||
PermissionRemoveChannel
|
||||
@@ -238,7 +231,6 @@ type Hub struct {
|
||||
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"`
|
||||
@@ -264,6 +256,7 @@ type HubRole struct {
|
||||
Color Rgba `json:"color"`
|
||||
Id uint8 `json:"id"`
|
||||
BoundedGroup uint8 `json:"boundedGroup"` // BoundedGroup 0 for global
|
||||
IsDeleted bool `json:"-"`
|
||||
}
|
||||
|
||||
func (h *HubRole) GrantPermission(r Permissions) {
|
||||
@@ -277,36 +270,18 @@ func (h *HubRole) HasPermission(r Permissions) bool {
|
||||
}
|
||||
|
||||
type HubUser struct {
|
||||
Mu sync.RWMutex `json:"mu"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
Roles HubBoundRoles `json:"-"`
|
||||
Name string `json:"name"` // Name empty = original name
|
||||
OriginalId uuid.UUID `json:"originalId"`
|
||||
IsGlobalMuted bool `json:"isGlobalMuted"`
|
||||
Mu sync.RWMutex `json:"mu"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
Roles HubBoundRoles `json:"-"`
|
||||
Name string `json:"name"` // Name empty = original name
|
||||
OriginalId uuid.UUID `json:"originalId"`
|
||||
IsMuted bool `json:"isMuted"`
|
||||
}
|
||||
|
||||
func NewHubUser() *HubUser {
|
||||
return &HubUser{}
|
||||
}
|
||||
|
||||
type HubGroup struct {
|
||||
Name string `json:"name"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
Color Rgba `json:"color"`
|
||||
RolesCanView HubBoundRoles `json:"rolesCanView"`
|
||||
UsersCachedPermissions map[uuid.UUID]CachedUserPermissions `json:"-"`
|
||||
Channels map[uuid.UUID]*HubChannel `json:"-"`
|
||||
MutedUsers map[uuid.UUID]struct{} `json:"-"`
|
||||
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),
|
||||
}
|
||||
}
|
||||
|
||||
type HubChannel struct {
|
||||
Mu sync.RWMutex `json:"-"`
|
||||
MessagesBuff []*Message `json:"-"`
|
||||
@@ -320,7 +295,6 @@ type HubChannel struct {
|
||||
UsersCachedPermissions map[uuid.UUID]CachedUserPermissions `json:"-"`
|
||||
NextBuffIdx uint32 `json:"-"`
|
||||
Id uuid.UUID `json:"id"`
|
||||
ParentId uint8 `json:"parentId"`
|
||||
Position uint8 `json:"position"`
|
||||
HaveOverflowed bool `json:"-"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user