diff --git a/changelog.md b/changelog.md index 5a34253..6421a7e 100644 --- a/changelog.md +++ b/changelog.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Update to [charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea) v0.26.4 to fix Windows resizing - Remove unnecessary alt-screen commands +- Server messages from admin commands ### Security diff --git a/server/main.go b/server/main.go index b23334b..cebec1b 100644 --- a/server/main.go +++ b/server/main.go @@ -183,7 +183,7 @@ func (s server) ServeHTTP(w http.ResponseWriter, r *http.Request) { if smsg.Id == s.admin { cmd := strings.Split(cmsg.Msg, " ") if len(cmd) == 2 { - if cmd[0] == "mk" { + if cmd[0] == "mk" && cmd[1] != "rooms" { if _, ok := s.rooms[cmd[1]]; ok { wsjson.Write(ctx, conn, c.SMsg{Tim: time.Now(), Id: "system", Msg: fmt.Sprintf("Room exists: %v", cmd)}) } else { @@ -207,9 +207,9 @@ func (s server) ServeHTTP(w http.ResponseWriter, r *http.Request) { } } s.conns.sm.Unlock() - wsjson.Write(ctx, conn, c.SMsg{Tim: time.Now(), Id: "system", Msg: fmt.Sprintf("Deleted room: %v", cmd)}) + wsjson.Write(ctx, conn, c.SMsg{Tim: time.Now(), Id: "system", Msg: fmt.Sprintf("Deleted room: %v", cmd[1])}) } else { - wsjson.Write(ctx, conn, c.SMsg{Tim: time.Now(), Id: "system", Msg: fmt.Sprintf("Room does not exist: %v", cmd)}) + wsjson.Write(ctx, conn, c.SMsg{Tim: time.Now(), Id: "system", Msg: fmt.Sprintf("Room does not exist: %v", cmd[1])}) } } else if cmd[0] == "yeet" { found := false @@ -300,8 +300,7 @@ func (s server) ServeHTTP(w http.ResponseWriter, r *http.Request) { s.conns.cm[conn] = u s.conns.sm.Unlock() wsjson.Write(ctx, conn, c.SMsg{Tim: time.Now(), Id: "system", Msg: fmt.Sprintf("connected to: %v", u.room)}) - rhistSize := max(len(s.rhist[u.room])-10, 0) - recentHistory := s.rhist[u.room][rhistSize:] + recentHistory := s.rhist[u.room] for i := range recentHistory { wsjson.Write(ctx, conn, recentHistory[i]) }