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.
This commit is contained in:
Acbox
2026-04-04 21:50:40 +08:00
parent a91d6304c6
commit c172699466
+5 -4
View File
@@ -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: