add channel set desc

This commit is contained in:
2026-05-02 13:01:14 +02:00
parent 40cb7736c2
commit cb003d235f
2 changed files with 25 additions and 0 deletions
+1
View File
@@ -83,6 +83,7 @@ func main() {
http.HandleFunc("PUT /hub/channel", withCORS(httpRequest.HandleChannelCreate)) http.HandleFunc("PUT /hub/channel", withCORS(httpRequest.HandleChannelCreate))
http.HandleFunc("DELETE /hub/channel", withCORS(httpRequest.HandleChannelRemove)) http.HandleFunc("DELETE /hub/channel", withCORS(httpRequest.HandleChannelRemove))
http.HandleFunc("PATCH /hub/name", withCORS(httpRequest.HandleChannelSetName)) http.HandleFunc("PATCH /hub/name", withCORS(httpRequest.HandleChannelSetName))
http.HandleFunc("PATCH /hub/description", withCORS(httpRequest.HandleChannelSetDescription))
http.HandleFunc("POST /connection/message", withCORS(httpRequest.HandleDm)) http.HandleFunc("POST /connection/message", withCORS(httpRequest.HandleDm))
http.HandleFunc("GET /ws", wsServer.ServeWsConnection) http.HandleFunc("GET /ws", wsServer.ServeWsConnection)
+24
View File
@@ -870,3 +870,27 @@ func HandleChannelSetName(response http.ResponseWriter, request *http.Request) {
response.WriteHeader(http.StatusAccepted) 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)
}