add settings update to API.

This commit is contained in:
Miroslav Šedivý 2022-03-27 00:26:25 +01:00
parent 7d53e59945
commit 58fca708a7
2 changed files with 30 additions and 0 deletions

View File

@ -55,6 +55,11 @@ func New(
}
func (h *RoomHandler) Route(r types.Router) {
r.With(auth.AdminsOnly).Route("/settings", func(r types.Router) {
r.Post("/", h.settingsSet)
r.Get("/", h.settingsGet)
})
r.With(auth.AdminsOnly).Route("/broadcast", func(r types.Router) {
r.Get("/", h.broadcastStatus)
r.Post("/start", h.boradcastStart)
@ -108,6 +113,7 @@ func (h *RoomHandler) Route(r types.Router) {
r.Post("/dialog", h.uploadDialogPost)
r.Delete("/dialog", h.uploadDialogClose)
})
}
func (h *RoomHandler) uploadMiddleware(w http.ResponseWriter, r *http.Request) (context.Context, error) {

View File

@ -0,0 +1,24 @@
package room
import (
"net/http"
"gitlab.com/demodesk/neko/server/pkg/utils"
)
func (h *RoomHandler) settingsGet(w http.ResponseWriter, r *http.Request) error {
settings := h.sessions.Settings()
return utils.HttpSuccess(w, settings)
}
func (h *RoomHandler) settingsSet(w http.ResponseWriter, r *http.Request) error {
settings := h.sessions.Settings()
if err := utils.HttpJsonRequest(w, r, &settings); err != nil {
return err
}
h.sessions.UpdateSettings(settings)
return utils.HttpSuccess(w)
}