From 6e9887f726b0b4441478ca7aa82983cc0c52f43d Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Fri, 7 Mar 2025 23:56:30 +0900 Subject: [PATCH] updated the notice endpoint to access the 'text' field in the payload for convenience --- server-ctl.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server-ctl.go b/server-ctl.go index 0e64335..de80161 100644 --- a/server-ctl.go +++ b/server-ctl.go @@ -50,6 +50,12 @@ type json_out_server_stats struct { SshProxySessions int64 `json:"pxy-ssh-sessions"` } +// this is a more specialized variant of json_in_notice +type json_in_server_notice struct { + Client string `json:"client"` + Text string `json:"text"` +} + // ------------------------------------ type server_ctl struct { @@ -580,7 +586,7 @@ func (ctl *server_ctl_notices) ServeHTTP(w http.ResponseWriter, req *http.Reques switch req.Method { case http.MethodPost: - var noti json_in_notice + var noti json_in_server_notice err = json.NewDecoder(req.Body).Decode(¬i) if err != nil { @@ -588,7 +594,7 @@ func (ctl *server_ctl_notices) ServeHTTP(w http.ResponseWriter, req *http.Reques goto oops } - err = s.SendNotice("", noti.Text) + err = s.SendNotice(noti.Client, noti.Text) if err != nil { status_code = WriteJsonRespHeader(w, http.StatusInternalServerError) je.Encode(JsonErrmsg{Text: err.Error()})