From d06bb5334acb2872360f090d89e429558264996b Mon Sep 17 00:00:00 2001 From: clawbot Date: Tue, 10 Feb 2026 17:53:13 -0800 Subject: [PATCH] feat(cli): update client to use unified command endpoint - JoinChannel/PartChannel now send via POST /messages with command field - ListChannels uses /channels instead of /channels/all - gofmt whitespace fixes --- cmd/chat-cli/api/client.go | 12 +++++------- cmd/chat-cli/main.go | 12 ++++++------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/cmd/chat-cli/api/client.go b/cmd/chat-cli/api/client.go index c2efaec..a20298c 100644 --- a/cmd/chat-cli/api/client.go +++ b/cmd/chat-cli/api/client.go @@ -148,21 +148,19 @@ func (c *Client) PollMessages(afterID string, timeout int) ([]Message, error) { return msgs, nil } -// JoinChannel joins a channel. +// JoinChannel joins a channel via the unified command endpoint. func (c *Client) JoinChannel(channel string) error { - _, err := c.do("POST", "/api/v1/channels/join", map[string]string{"channel": channel}) - return err + return c.SendMessage(&Message{Command: "JOIN", To: channel}) } -// PartChannel leaves a channel. +// PartChannel leaves a channel via the unified command endpoint. func (c *Client) PartChannel(channel string) error { - _, err := c.do("DELETE", "/api/v1/channels/"+url.PathEscape(channel), nil) - return err + return c.SendMessage(&Message{Command: "PART", To: channel}) } // ListChannels returns all channels on the server. func (c *Client) ListChannels() ([]Channel, error) { - data, err := c.do("GET", "/api/v1/channels/all", nil) + data, err := c.do("GET", "/api/v1/channels", nil) if err != nil { return nil, err } diff --git a/cmd/chat-cli/main.go b/cmd/chat-cli/main.go index d0bd2a9..6dfa1f3 100644 --- a/cmd/chat-cli/main.go +++ b/cmd/chat-cli/main.go @@ -15,12 +15,12 @@ type App struct { ui *UI client *api.Client - mu sync.Mutex - nick string - target string // current target (#channel or nick for DM) - connected bool - lastMsgID string - stopPoll chan struct{} + mu sync.Mutex + nick string + target string // current target (#channel or nick for DM) + connected bool + lastMsgID string + stopPoll chan struct{} } func main() {