From ba974b13be8ebe9e9fe67ef1c1cc4d9f04b41596 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 27 Jun 2024 22:54:35 +0800 Subject: [PATCH] :bug: Block empty message --- pkg/internal/server/api/events_message_api.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/internal/server/api/events_message_api.go b/pkg/internal/server/api/events_message_api.go index 084cbb2..690c63c 100644 --- a/pkg/internal/server/api/events_message_api.go +++ b/pkg/internal/server/api/events_message_api.go @@ -28,6 +28,10 @@ func newMessageEvent(c *fiber.Ctx) error { return fiber.NewError(fiber.StatusBadRequest, "message uuid was not valid") } + if len(data.Body.Text) == 0 && len(data.Body.Attachments) == 0 { + return fiber.NewError(fiber.StatusBadRequest, "you cannot send an empty message") + } + var err error var channel models.Channel var member models.ChannelMember @@ -84,6 +88,10 @@ func editMessageEvent(c *fiber.Ctx) error { return err } + if len(data.Body.Text) == 0 && len(data.Body.Attachments) == 0 { + return fiber.NewError(fiber.StatusBadRequest, "you cannot send an empty message") + } + var err error var channel models.Channel var member models.ChannelMember