From c172699466761406b85d09a37a86cdaae2f6faab Mon Sep 17 00:00:00 2001 From: Acbox Date: Sat, 4 Apr 2026 21:50:40 +0800 Subject: [PATCH] fix(channel): allow attachment-only messages via WebSocket (#331) The WebSocket handler rejected messages with empty text even when attachments were present, while the HTTP POST endpoint correctly used Message.IsEmpty(). Move the empty-check after attachment parsing so only truly empty messages are rejected. --- internal/handlers/local_channel.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/handlers/local_channel.go b/internal/handlers/local_channel.go index a1c3559c..4bc59e81 100644 --- a/internal/handlers/local_channel.go +++ b/internal/handlers/local_channel.go @@ -392,10 +392,6 @@ func (h *LocalChannelHandler) HandleWebSocket(c echo.Context) error { case "message": text := strings.TrimSpace(msg.Text) - if text == "" { - writer.SendJSON(map[string]string{"type": "error", "message": "message text is required"}) - continue - } chatAttachments := make([]conversation.ChatAttachment, 0, len(msg.Attachments)) for _, rawAtt := range msg.Attachments { @@ -405,6 +401,11 @@ func (h *LocalChannelHandler) HandleWebSocket(c echo.Context) error { } } + if text == "" && len(chatAttachments) == 0 { + writer.SendJSON(map[string]string{"type": "error", "message": "message text or attachments required"}) + continue + } + // Drain any previous abort signal. select { case <-abortCh: