API for setting a list of blocked usernames. For #782
This commit is contained in:
parent
83ad6db394
commit
61e07bf945
@ -539,7 +539,19 @@ func SetCustomStyles(w http.ResponseWriter, r *http.Request) {
|
||||
data.SetCustomStyles(customStyles.Value.(string))
|
||||
|
||||
controllers.WriteSimpleResponse(w, true, "custom styles updated")
|
||||
}
|
||||
|
||||
// SetUsernameBlocklist will set the list of usernames we do not allow to use.
|
||||
func SetUsernameBlocklist(w http.ResponseWriter, r *http.Request) {
|
||||
usernames, success := getValueFromRequest(w, r)
|
||||
if !success {
|
||||
controllers.WriteSimpleResponse(w, false, "unable to update custom styles")
|
||||
return
|
||||
}
|
||||
|
||||
data.SetUsernameBlocklist(usernames.Value.(string))
|
||||
|
||||
controllers.WriteSimpleResponse(w, true, "blocklist updated")
|
||||
}
|
||||
|
||||
func requirePOST(w http.ResponseWriter, r *http.Request) bool {
|
||||
|
@ -60,6 +60,7 @@ func GetServerConfig(w http.ResponseWriter, r *http.Request) {
|
||||
ExternalActions: data.GetExternalActions(),
|
||||
SupportedCodecs: transcoder.GetCodecs(ffmpeg),
|
||||
VideoCodec: data.GetVideoCodec(),
|
||||
UsernameBlocklist: data.GetUsernameBlocklist(),
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
@ -83,6 +84,7 @@ type serverConfigAdminResponse struct {
|
||||
ExternalActions []models.ExternalAction `json:"externalActions"`
|
||||
SupportedCodecs []string `json:"supportedCodecs"`
|
||||
VideoCodec string `json:"videoCodec"`
|
||||
UsernameBlocklist string `json:"usernameBlocklist"`
|
||||
}
|
||||
|
||||
type videoSettings struct {
|
||||
|
@ -40,6 +40,7 @@ const chatDisabledKey = "chat_disabled"
|
||||
const externalActionsKey = "external_actions"
|
||||
const customStylesKey = "custom_styles"
|
||||
const videoCodecKey = "video_codec"
|
||||
const blockedUsernamesKey = "blocked_usernames"
|
||||
|
||||
// GetExtraPageBodyContent will return the user-supplied body content.
|
||||
func GetExtraPageBodyContent() string {
|
||||
@ -552,3 +553,20 @@ func FindHighestVideoQualityIndex(qualities []models.StreamOutputVariant) int {
|
||||
|
||||
return indexedQualities[0].index
|
||||
}
|
||||
|
||||
// GetUsernameBlocklist will return the blocked usernames as a comma seperated string.
|
||||
func GetUsernameBlocklist() string {
|
||||
usernameString, err := _datastore.GetString(blockedUsernamesKey)
|
||||
|
||||
if err != nil {
|
||||
log.Traceln(blockedUsernamesKey, err)
|
||||
return ""
|
||||
}
|
||||
|
||||
return usernameString
|
||||
}
|
||||
|
||||
// SetUsernameBlocklist set the username blocklist as a comma seperated string.
|
||||
func SetUsernameBlocklist(usernames string) error {
|
||||
return _datastore.SetString(serverMetadataTagsKey, usernames)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user