aboutsummaryrefslogtreecommitdiff
path: root/routes/admin.go
diff options
context:
space:
mode:
authorFChannel <>2022-05-22 13:02:48 -0700
committerFChannel <>2022-06-19 12:53:29 -0700
commit6a0f664b565716ad08301e7699d6c0393dbba977 (patch)
treef760adc388604486b9660682c629f44e6db61694 /routes/admin.go
parent580dec5b89215310ce34341e11ff17fe38bdb63a (diff)
following pass through
Diffstat (limited to 'routes/admin.go')
-rw-r--r--routes/admin.go72
1 files changed, 12 insertions, 60 deletions
diff --git a/routes/admin.go b/routes/admin.go
index 24c1479..d837a2f 100644
--- a/routes/admin.go
+++ b/routes/admin.go
@@ -5,7 +5,6 @@ import (
"encoding/json"
"io/ioutil"
"net/http"
- "regexp"
"time"
"github.com/FChannel0/FChannel-Server/activitypub"
@@ -138,77 +137,30 @@ func AdminIndex(ctx *fiber.Ctx) error {
}
func AdminFollow(ctx *fiber.Ctx) error {
- actor, _ := webfinger.GetActorFromPath(ctx.Path(), "/"+config.Key+"/")
-
- following := regexp.MustCompile(`(.+)\/following`)
- followers := regexp.MustCompile(`(.+)\/followers`)
-
follow := ctx.FormValue("follow")
actorId := ctx.FormValue("actor")
- //follow all of boards following
- if following.MatchString(follow) {
- followingActor, _ := activitypub.FingerActor(follow)
- reqActivity := activitypub.Activity{Id: followingActor.Following}
- col, _ := reqActivity.GetCollection()
-
- var nObj activitypub.ObjectBase
- nObj.Id = followingActor.Id
-
- col.Items = append(col.Items, nObj)
-
- for _, e := range col.Items {
- if isFollowing, _ := actor.IsAlreadyFollowing(e.Id); !isFollowing && e.Id != config.Domain && e.Id != actorId {
- actor := activitypub.Actor{Id: actorId}
- followActivity, _ := actor.MakeFollowActivity(e.Id)
-
- if actor, _ := activitypub.FingerActor(e.Id); actor.Id != "" {
- followActivity.MakeRequestOutbox()
- }
- }
- }
-
- //follow all of boards followers
- } else if followers.MatchString(follow) {
- followersActor, _ := activitypub.FingerActor(follow)
- reqActivity := activitypub.Activity{Id: followersActor.Followers}
- col, _ := reqActivity.GetCollection()
-
- var nObj activitypub.ObjectBase
- nObj.Id = followersActor.Id
-
- col.Items = append(col.Items, nObj)
-
- for _, e := range col.Items {
- if isFollowing, _ := actor.IsAlreadyFollowing(e.Id); !isFollowing && e.Id != config.Domain && e.Id != actorId {
- actor := activitypub.Actor{Id: actorId}
- followActivity, _ := actor.MakeFollowActivity(e.Id)
- if actor, _ := activitypub.FingerActor(e.Id); actor.Id != "" {
- followActivity.MakeRequestOutbox()
- }
- }
- }
+ actor := activitypub.Actor{Id: actorId}
+ followActivity, _ := actor.MakeFollowActivity(follow)
- //do a normal follow to a single board
- } else {
- actor := activitypub.Actor{Id: actorId}
- followActivity, _ := actor.MakeFollowActivity(follow)
+ objActor := activitypub.Actor{Id: followActivity.Object.Actor}
- actor = activitypub.Actor{Id: followActivity.Object.Actor}
- if isLocal, _ := actor.IsLocal(); !isLocal && followActivity.Actor.Id == config.Domain {
- _, err := ctx.Write([]byte("main board can only follow local boards. Create a new board and then follow outside boards from it."))
- return util.MakeError(err, "AdminIndex")
- }
+ if isLocal, _ := objActor.IsLocal(); !isLocal && followActivity.Actor.Id == config.Domain {
+ _, err := ctx.Write([]byte("main board can only follow local boards. Create a new board and then follow outside boards from it."))
+ return util.MakeError(err, "AdminIndex")
+ }
- if actor, _ := activitypub.FingerActor(follow); actor.Id != "" {
- followActivity.MakeRequestOutbox()
+ if actor, _ := activitypub.FingerActor(follow); actor.Id != "" {
+ if err := followActivity.MakeRequestOutbox(); err != nil {
+ return util.MakeError(err, "AdminFollow")
}
}
var redirect string
+ actor, _ = webfinger.GetActorFromPath(ctx.Path(), "/"+config.Key+"/")
if actor.Name != "main" {
- redirect = "/" + actor.Name
+ redirect = actor.Name
}
return ctx.Redirect("/"+config.Key+"/"+redirect, http.StatusSeeOther)