From 2af4a39ac16c6245f0e87ddf3cc137339f6c604f Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Sun, 1 May 2022 10:50:48 -0700 Subject: creating new post and replying to post working --- routes/actor.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'routes') diff --git a/routes/actor.go b/routes/actor.go index 6e5955e..7b57309 100644 --- a/routes/actor.go +++ b/routes/actor.go @@ -42,18 +42,19 @@ func ActorOutbox(ctx *fiber.Ctx) error { valid, err := post.CheckCaptcha(ctx.FormValue("captcha")) if err == nil && hasCaptcha && valid { header, _ := ctx.FormFile("file") - if header != nil { f, _ := header.Open() defer f.Close() if header.Size > (7 << 20) { - return ctx.Render("403", fiber.Map{ - "message": "7MB max file size", - }) - } else if res, err := post.IsMediaBanned(f); err == nil && res { + ctx.Response().Header.SetStatusCode(403) + _, err := ctx.Write([]byte("7MB max file size")) + return err + } else if isBanned, err := post.IsMediaBanned(f); err == nil && isBanned { //Todo add logging fmt.Println("media banned") - return ctx.Redirect("/", 301) + ctx.Response().Header.SetStatusCode(403) + _, err := ctx.Write([]byte("media banned")) + return err } else if err != nil { return err } @@ -61,9 +62,9 @@ func ActorOutbox(ctx *fiber.Ctx) error { contentType, _ := util.GetFileContentType(f) if !post.SupportedMIMEType(contentType) { - return ctx.Render("403", fiber.Map{ - "message": "file type not supported", - }) + ctx.Response().Header.SetStatusCode(403) + _, err := ctx.Write([]byte("file type not supported")) + return err } } @@ -381,11 +382,10 @@ func ActorPost(ctx *fiber.Ctx) error { } defer resp.Body.Close() + body, _ := ioutil.ReadAll(resp.Body) if resp.StatusCode == 200 { - body, _ := ioutil.ReadAll(resp.Body) - var obj activitypub.ObjectBase obj = post.ParseOptions(ctx, obj) @@ -404,7 +404,7 @@ func ActorPost(ctx *fiber.Ctx) error { if resp.StatusCode == 403 { return ctx.Render("403", fiber.Map{ - "message": "Incorrect Captcha", + "message": string(body), }) } -- cgit v1.2.3