aboutsummaryrefslogtreecommitdiff
path: root/route/routes/boardmgmt.go
diff options
context:
space:
mode:
Diffstat (limited to 'route/routes/boardmgmt.go')
-rw-r--r--route/routes/boardmgmt.go29
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 {