Documentation
¶
Overview ¶
Package channel provides channel-related utilities and settings management.
Index ¶
- Variables
- func CheckAccessForFullRequest(userAccess int32) error
- func CheckAccessForPartialRequest(userAccess int32, req *PartialSettingsRequest) error
- type AccessDeniedError
- type DeniedSetting
- type FullSettingsRequest
- type GetChannelSettingsResponse
- type PartialSettingsRequest
- type ResponseSettings
- type SettingDef
- type SettingType
- type UpdateChannelSettingsResponse
Constants ¶
This section is empty.
Variables ¶
var Settings = []SettingDef{ {Name: "autojoin", DBColumn: "flags", Type: TypeBool, Level: 500, Flag: flags.ChannelAutoJoin}, {Name: "massdeoppro", DBColumn: "mass_deop_pro", Type: TypeInt, Level: 500, Min: ptr(0), Max: ptr(7)}, {Name: "noop", DBColumn: "flags", Type: TypeBool, Level: 500, Flag: flags.ChannelNoOp}, {Name: "strictop", DBColumn: "flags", Type: TypeBool, Level: 500, Flag: flags.ChannelStrictOp}, {Name: "autotopic", DBColumn: "flags", Type: TypeBool, Level: 450, Flag: flags.ChannelAutoTopic}, {Name: "description", DBColumn: "description", Type: TypeString, Level: 450, MaxLen: ptr(300)}, {Name: "floatlim", DBColumn: "flags", Type: TypeBool, Level: 450, Flag: flags.ChannelFloatLimit}, {Name: "floatgrace", DBColumn: "limit_grace", Type: TypeInt, Level: 450, Min: ptr(0), Max: ptr(19)}, {Name: "floatmargin", DBColumn: "limit_offset", Type: TypeInt, Level: 450, Min: ptr(2), Max: ptr(20)}, {Name: "floatmax", DBColumn: "limit_max", Type: TypeInt, Level: 450, Min: ptr(0), Max: ptr(65536)}, {Name: "floatperiod", DBColumn: "limit_period", Type: TypeInt, Level: 450, Min: ptr(20), Max: ptr(200)}, {Name: "keywords", DBColumn: "keywords", Type: TypeString, Level: 450, MaxLen: ptr(300)}, {Name: "url", DBColumn: "url", Type: TypeString, Level: 450, MaxLen: ptr(128)}, {Name: "userflags", DBColumn: "userflags", Type: TypeInt, Level: 450, Min: ptr(0), Max: ptr(2)}, }
Settings is the registry of all configurable channel settings.
Functions ¶
func CheckAccessForFullRequest ¶
CheckAccessForFullRequest verifies if a user can modify ALL channel settings. Used for PUT requests where all fields are required. Returns an AccessDeniedError if the user lacks permission for any settings.
func CheckAccessForPartialRequest ¶
func CheckAccessForPartialRequest(userAccess int32, req *PartialSettingsRequest) error
CheckAccessForPartialRequest verifies if a user can modify the requested settings. Used for PATCH requests where only provided fields are updated. Returns an AccessDeniedError if the user lacks permission for any requested settings.
Types ¶
type AccessDeniedError ¶
type AccessDeniedError struct {
UserLevel int32 `json:"user_level"`
DeniedSettings []DeniedSetting `json:"denied_settings"`
}
AccessDeniedError is returned when a user attempts to modify settings above their access level.
func (*AccessDeniedError) Error ¶
func (e *AccessDeniedError) Error() string
Error implements the error interface.
func (*AccessDeniedError) GetDeniedSettings ¶
func (e *AccessDeniedError) GetDeniedSettings() []apierrors.DeniedSettingInfo
GetDeniedSettings returns the list of denied settings as DeniedSettingInfo.
func (*AccessDeniedError) GetUserLevel ¶
func (e *AccessDeniedError) GetUserLevel() int32
GetUserLevel returns the user's access level.
type DeniedSetting ¶
type DeniedSetting struct {
Name string `json:"setting"`
RequiredLevel int32 `json:"required_level"`
}
DeniedSetting represents a setting the user lacks permission to modify.
type FullSettingsRequest ¶
type FullSettingsRequest struct {
Autojoin bool `json:"autojoin"`
Massdeoppro int `json:"massdeoppro" validate:"min=0,max=7"`
Noop bool `json:"noop"`
Strictop bool `json:"strictop"`
Autotopic bool `json:"autotopic"`
Description string `json:"description" validate:"max=300,nocontrolchars"`
Floatlim bool `json:"floatlim"`
Floatgrace int `json:"floatgrace" validate:"min=0,max=19"`
Floatmargin int `json:"floatmargin" validate:"min=2,max=20"`
Floatmax int `json:"floatmax" validate:"min=0,max=65536"`
Floatperiod int `json:"floatperiod" validate:"min=20,max=200"`
Keywords string `json:"keywords" validate:"max=300,nocontrolchars"`
URL string `json:"url" validate:"omitempty,url,max=128"`
Userflags int `json:"userflags" validate:"min=0,max=2"`
}
FullSettingsRequest is used for PUT requests where all fields are required.
type GetChannelSettingsResponse ¶
type GetChannelSettingsResponse struct {
ID int32 `json:"id"`
Name string `json:"name"`
MemberCount int32 `json:"member_count"`
CreatedAt int32 `json:"created_at"`
UpdatedAt int32 `json:"updated_at,omitempty"`
Settings ResponseSettings `json:"settings"`
}
GetChannelSettingsResponse is the response for GET /channels/{id}.
type PartialSettingsRequest ¶
type PartialSettingsRequest struct {
Autojoin *bool `json:"autojoin,omitempty"`
Massdeoppro *int `json:"massdeoppro,omitempty" validate:"omitempty,min=0,max=7"`
Noop *bool `json:"noop,omitempty"`
Strictop *bool `json:"strictop,omitempty"`
Autotopic *bool `json:"autotopic,omitempty"`
Description *string `json:"description,omitempty" validate:"omitempty,max=300,nocontrolchars"`
Floatlim *bool `json:"floatlim,omitempty"`
Floatgrace *int `json:"floatgrace,omitempty" validate:"omitempty,min=0,max=19"`
Floatmargin *int `json:"floatmargin,omitempty" validate:"omitempty,min=2,max=20"`
Floatmax *int `json:"floatmax,omitempty" validate:"omitempty,min=0,max=65536"`
Floatperiod *int `json:"floatperiod,omitempty" validate:"omitempty,min=20,max=200"`
Keywords *string `json:"keywords,omitempty" validate:"omitempty,max=300,nocontrolchars"`
URL *string `json:"url,omitempty" validate:"omitempty,url,max=128"`
Userflags *int `json:"userflags,omitempty" validate:"omitempty,min=0,max=2"`
}
PartialSettingsRequest is used for PATCH requests where only provided fields are updated.
type ResponseSettings ¶
type ResponseSettings struct {
Autojoin bool `json:"autojoin"`
Massdeoppro int `json:"massdeoppro"`
Noop bool `json:"noop"`
Strictop bool `json:"strictop"`
Autotopic bool `json:"autotopic"`
Description string `json:"description,omitempty"`
Floatlim bool `json:"floatlim"`
Floatgrace int `json:"floatgrace"`
Floatmargin int `json:"floatmargin"`
Floatmax int `json:"floatmax"`
Floatperiod int `json:"floatperiod"`
Keywords string `json:"keywords,omitempty"`
URL string `json:"url,omitempty"`
Userflags int `json:"userflags"`
}
ResponseSettings represents the settings portion of a channel response.
type SettingDef ¶
type SettingDef struct {
Name string // JSON field name
DBColumn string // Database column name
Type SettingType // Data type
Level int32 // Minimum access level required
Flag flags.Channel // For boolean flags stored in flags column
Min *int // For integers: minimum value
Max *int // For integers: maximum value
MaxLen *int // For strings: max length
}
SettingDef defines a channel setting with its metadata.
func GetSettingByName ¶
func GetSettingByName(name string) *SettingDef
GetSettingByName returns the setting definition for the given name, or nil if not found.
type SettingType ¶
type SettingType int
SettingType represents the data type of a channel setting.
const ( TypeBool SettingType = iota TypeInt TypeString )
type UpdateChannelSettingsResponse ¶
type UpdateChannelSettingsResponse struct {
ID int32 `json:"id"`
Name string `json:"name"`
MemberCount int32 `json:"member_count"`
CreatedAt int32 `json:"created_at"`
UpdatedAt int32 `json:"updated_at"`
Settings ResponseSettings `json:"settings"`
}
UpdateChannelSettingsResponse is the response for PUT/PATCH /channels/{id}.