add channel set desc
This commit is contained in:
@@ -870,3 +870,27 @@ func HandleChannelSetName(response http.ResponseWriter, request *http.Request) {
|
||||
|
||||
response.WriteHeader(http.StatusAccepted)
|
||||
}
|
||||
|
||||
func HandleChannelSetDescription(response http.ResponseWriter, request *http.Request) {
|
||||
_, hub, _, _, ok := hubPermissionContext(response, request, normal, types.PermissionSetChannelDescription)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
newDescription := request.FormValue("description")
|
||||
channelId, err := convertions.StringToUint8(request.FormValue("id"))
|
||||
if err != nil {
|
||||
http.Error(response, "invalid channel id", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
hub.Mu.Lock()
|
||||
channel := hub.Channels[channelId]
|
||||
if channel == nil {
|
||||
http.Error(response, "no such channel", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
channel.Description = newDescription
|
||||
hub.Mu.Unlock()
|
||||
|
||||
response.WriteHeader(http.StatusAccepted)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user