From fd611d7f671aa3667a7f4dc8307fc359c56b6adc Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 6 Apr 2024 23:44:09 +0800 Subject: [PATCH] :sparkles: Allow only attachment message exists --- pkg/server/messages_api.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/server/messages_api.go b/pkg/server/messages_api.go index 9ccc8e1..71d7b8b 100644 --- a/pkg/server/messages_api.go +++ b/pkg/server/messages_api.go @@ -35,13 +35,15 @@ func newTextMessage(c *fiber.Ctx) error { alias := c.Params("channel") var data struct { - Content string `json:"content" validate:"required"` + Content string `json:"content"` Attachments []models.Attachment `json:"attachments"` ReplyTo *uint `json:"reply_to"` } if err := BindAndValidate(c, &data); err != nil { return err + } else if len(data.Attachments) == 0 && len(data.Content) == 0 { + return fmt.Errorf("you must write or upload some content in a single message") } channel, member, err := services.GetAvailableChannelWithAlias(alias, user)