Skip to content

Commit

Permalink
🐛 Fix validation bug and remove test code
Browse files Browse the repository at this point in the history
  • Loading branch information
펜타곤 authored and 펜타곤 committed Apr 1, 2024
1 parent 6ce2bd8 commit c455f18
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions controllers/reportctrl/send.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package reportctrl

import (
"log"

"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/log"
"github.com/kamva/mgm/v3"
"pentag.kr/dimimonster/middleware"
"pentag.kr/dimimonster/models"
"pentag.kr/dimimonster/utils/crypt"
"pentag.kr/dimimonster/utils/validator"
)

type ReportRequest struct {
TargetID string `json:"target-id" validate:"required"`
Reason string `json:"reason" validate:"required, max=300"`
Reason string `json:"reason" validate:"required,max=300"`
Token string `json:"token" validate:"required"`
}

Expand All @@ -28,23 +28,23 @@ func SendReportCtrl(c *fiber.Ctx) error {
if !validator.IsHex(body.TargetID) {
return c.Status(400).SendString("Bad Request")
}
// if !crypt.RecaptchaCheck(body.Token, "image_report") {
// return c.Status(425).SendString("Recaptcha Failed")
// }
if !crypt.RecaptchaCheck(body.Token, "image_report") {
return c.Status(425).SendString("Recaptcha Failed")
}

newReport, err := models.NewReport(
body.TargetID,
userID,
body.Reason,
)
if err != nil {
log.Println(err)
log.Error(err)
return c.Status(500).SendString("Internal Server Error")
}

err = mgm.Coll(newReport).Create(newReport)
if err != nil {
log.Println(err)
log.Error(err)
return c.Status(500).SendString("Internal Server Error")
}

Expand Down

0 comments on commit c455f18

Please sign in to comment.