add join role endpoint and persistency for hubs

This commit is contained in:
2026-05-06 19:08:18 +02:00
parent 03c13a6e8a
commit f68a249268
12 changed files with 991 additions and 206 deletions
+38 -1
View File
@@ -42,7 +42,7 @@ type User struct {
Color Rgba `json:"color"`
}
type UserProfileUpdateList struct {
type UserProfileUpdate struct {
Pronouns bool
Description bool
Color bool
@@ -148,6 +148,7 @@ const (
PermissionSetHubColor
PermissionRemoveHub
PermissionSetUserColorAllowed
PermissionSetHubJoinRole
// User permissions
PermissionInviteUser
@@ -184,6 +185,7 @@ var permissionRegistry = map[string]Permissions{
"set_hub_color": PermissionSetHubColor,
"remove_hub": PermissionRemoveHub,
"set_user_color_allowed": PermissionSetUserColorAllowed,
"set_hub_join_role": PermissionSetHubJoinRole,
"invite_user": PermissionInviteUser,
"remove_user": PermissionRemoveUser,
"rename_user": PermissionRenameUser,
@@ -263,6 +265,17 @@ func (p *CachedUserPermissions) SetCanMessage() { *p |= CachedUserCanMessage }
func (p *CachedUserPermissions) ClearCanMessage() { *p &^= CachedUserCanMessage }
func (p CachedUserPermissions) CanMessage() bool { return p&CachedUserCanMessage != 0 }
type HubUpdate struct {
Name bool
IconUrl bool
BgUrl bool
JoinRole bool
Id bool
Creator bool
Color bool
UserColorAllowed bool
}
type Hub struct {
Mu sync.RWMutex `json:"-"`
CreatedAt time.Time `json:"createdAt"`
@@ -286,6 +299,13 @@ func NewHub() *Hub {
}
}
type HubRoleUpdate struct {
Name bool
Permissions bool
Color bool
Id bool
}
type HubRole struct {
Name string `json:"role"`
CreatedAt time.Time `json:"createdAt"`
@@ -304,6 +324,12 @@ func (h *HubRole) HasPermission(r Permissions) bool {
return h.Permissions&r != 0
}
type HubUserUpdate struct {
Roles bool
Name bool
IsMuted bool
}
type HubUser struct {
Mu sync.RWMutex `json:"-"`
CreatedAt time.Time `json:"createdAt"`
@@ -317,6 +343,17 @@ func NewHubUser() *HubUser {
return &HubUser{}
}
type HubChannelUpdate struct {
Name bool
Description bool
IconUrl bool
CreatedAt bool
RolesCanView bool
RolesCanMessage bool
RolesCanReadHistory bool
Position bool
}
type HubChannel struct {
Mu sync.RWMutex `json:"-"`
MessagesBuff []*Message `json:"-"`