File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -54,9 +54,17 @@ func createMessageHandler(c fiber.Ctx) error {
5454 }
5555 }
5656 for _ , email := range msg .Emails {
57+ // Validate email address
5758 if _ , err := mail .ParseAddress (email ); err != nil {
5859 return c .Status (fiber .StatusBadRequest ).JSON (fiber.Map {"error" : fmt .Sprintf ("invalid email: %s" , email )})
5960 }
61+ // Validate essential message fields
62+ if strings .TrimSpace (msg .Subject ) == "" {
63+ return c .Status (fiber .StatusBadRequest ).JSON (fiber.Map {"error" : "Subject cannot be empty" })
64+ }
65+ if strings .TrimSpace (msg .Content ) == "" {
66+ return c .Status (fiber .StatusBadRequest ).JSON (fiber.Map {"error" : "Content cannot be empty" })
67+ }
6068 req := & model.Request {
6169 TopicId : msg .TopicId ,
6270 To : email ,
You can’t perform that action at this time.
0 commit comments