diff options
author | FChannel <> | 2022-06-05 11:19:18 -0700 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | 5e4f829b9c26e40bc3931226d4fa0872c150e43a (patch) | |
tree | bfe833f7d085c667574448963737b0d100cc77df /route/routes | |
parent | 8b1a7fa5e37e4c8c4b0df3d83067079a081e32d3 (diff) |
auto subscribe in place. still have to do some logic changes for bugs
Diffstat (limited to 'route/routes')
-rw-r--r-- | route/routes/boardmgmt.go | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/route/routes/boardmgmt.go b/route/routes/boardmgmt.go index 5d6dd93..04c01b5 100644 --- a/route/routes/boardmgmt.go +++ b/route/routes/boardmgmt.go @@ -347,9 +347,34 @@ func BoardPopArchive(ctx *fiber.Ctx) error { return ctx.SendString("board pop archive") } -// TODO routes/BoardAutoSubscribe func BoardAutoSubscribe(ctx *fiber.Ctx) error { - return ctx.SendString("board auto subscribe") + actor, err := activitypub.GetActorFromDB(config.Domain) + + if err != nil { + return util.MakeError(err, "BoardAutoSubscribe") + } + + if has := actor.HasValidation(ctx); !has { + return util.MakeError(err, "BoardAutoSubscribe") + } + + board := ctx.Query("board") + + if actor, err = activitypub.GetActorByNameFromDB(board); err != nil { + return util.MakeError(err, "BoardAutoSubscribe") + } + + if err := actor.SetAutoSubscribe(); err != nil { + return util.MakeError(err, "BoardAutoSubscribe") + } + + if autoSub, _ := actor.GetAutoSubscribe(); autoSub { + if err := actor.AutoFollow(); err != nil { + return util.MakeError(err, "BoardAutoSubscribe") + } + } + + return ctx.Redirect("/"+config.Key+"/"+board, http.StatusSeeOther) } func BoardBlacklist(ctx *fiber.Ctx) error { |