diff options
author | FChannel <> | 2022-05-01 10:50:48 -0700 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | 2af4a39ac16c6245f0e87ddf3cc137339f6c604f (patch) | |
tree | cec86f25fd4bcd7cc1efd0bd01cfe8524b41c42c /routes/actor.go | |
parent | 503a6637b8294aeb8e5e5546f8acbd2b3d6c4744 (diff) |
creating new post and replying to post working
Diffstat (limited to 'routes/actor.go')
-rw-r--r-- | routes/actor.go | 24 |
1 files changed, 12 insertions, 12 deletions
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), }) } |