🐛 Block empty message

This commit is contained in:
LittleSheep 2024-06-27 22:54:35 +08:00
parent 57f2aa518e
commit ba974b13be

View File

@ -28,6 +28,10 @@ func newMessageEvent(c *fiber.Ctx) error {
return fiber.NewError(fiber.StatusBadRequest, "message uuid was not valid") 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 err error
var channel models.Channel var channel models.Channel
var member models.ChannelMember var member models.ChannelMember
@ -84,6 +88,10 @@ func editMessageEvent(c *fiber.Ctx) error {
return err 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 err error
var channel models.Channel var channel models.Channel
var member models.ChannelMember var member models.ChannelMember