diff --git a/internal/api/room/control.go b/internal/api/room/control.go index 7539ae26..05d7fd55 100644 --- a/internal/api/room/control.go +++ b/internal/api/room/control.go @@ -106,3 +106,21 @@ func (h *RoomHandler) controlGive(w http.ResponseWriter, r *http.Request) { utils.HttpSuccess(w) } + +func (h *RoomHandler) controlReset(w http.ResponseWriter, r *http.Request) { + host := h.sessions.GetHost() + if host == nil { + utils.HttpSuccess(w) + return + } + + h.sessions.ClearHost() + + h.sessions.Broadcast( + message.Control{ + Event: event.CONTROL_RELEASE, + ID: host.ID(), + }, nil) + + utils.HttpSuccess(w) +} diff --git a/internal/api/room/handler.go b/internal/api/room/handler.go index cca2b044..a073f7a0 100644 --- a/internal/api/room/handler.go +++ b/internal/api/room/handler.go @@ -58,6 +58,7 @@ func (h *RoomHandler) Route(r chi.Router) { r.With(auth.AdminsOnly).Post("/take", h.controlTake) r.With(auth.AdminsOnly).Post("/give", h.controlGive) + r.With(auth.AdminsOnly).Post("/reset", h.controlReset) }) r.Route("/screen", func(r chi.Router) {