aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorFChannel <>2021-07-15 14:47:22 -0700
committerFChannel <>2021-07-15 14:47:22 -0700
commite97c3e9d2d1bedf63a7d341eb199c9500bcd8cd9 (patch)
tree809ed7c01e51e3ef7beb746b3dc77f17fdca3936 /main.go
parent22ee823b6e9200317337941c2ad41ca9df9dd855 (diff)
can follow other boards followers or following by passing in the url you want to follow eg https://fchan.xyz/b/following and your board will follow all the boards that board is following or https://fchan.xyz/b/followers to follow all that boards followers
Diffstat (limited to 'main.go')
-rw-r--r--main.go50
1 files changed, 43 insertions, 7 deletions
diff --git a/main.go b/main.go
index d36fec5..68daf39 100644
--- a/main.go
+++ b/main.go
@@ -474,15 +474,51 @@ func main() {
if follow || adminFollow {
r.ParseForm()
- followActivity := MakeFollowActivity(db, r.FormValue("actor"), r.FormValue("follow"))
+ following := regexp.MustCompile(`(.+)\/following`)
+ followers := regexp.MustCompile(`(.+)\/followers`)
+
+ follow := r.FormValue("follow")
+ actorId := r.FormValue("actor")
+
+ //follow all of boards following
+ if following.MatchString(follow) {
+ followingActor := FingerActor(follow)
+ col := GetActorCollection(followingActor.Following)
+ for _, e := range col.Items {
+ if !IsAlreadyFollowing(db, actorId, e.Id) && e.Id != Domain {
+ followActivity := MakeFollowActivity(db, actorId, e.Id)
+
+ if FingerActor(e.Id).Id != "" {
+ MakeActivityRequestOutbox(db, followActivity)
+ }
+ }
+ }
+
+ //follow all of boards followers
+ } else if followers.MatchString(follow){
+ followersActor := FingerActor(follow)
+ col := GetActorCollection(followersActor.Followers)
+ for _, e := range col.Items {
+ if !IsAlreadyFollowing(db, actorId, e.Id) && e.Id != Domain {
+ followActivity := MakeFollowActivity(db, actorId, e.Id)
+ if FingerActor(e.Id).Id != "" {
+ MakeActivityRequestOutbox(db, followActivity)
+ }
+ }
+ }
+
+ //do a normal follow to a single board
+ } else {
+ followActivity := MakeFollowActivity(db, actorId, follow)
- if followActivity.Actor.Id == Domain && !IsActorLocal(db, followActivity.Object.Actor) {
- w.Write([]byte("main board can only follow local boards. Create a new board and then follow outside boards from it."))
- return
- }
+ if followActivity.Actor.Id == Domain && !IsActorLocal(db, followActivity.Object.Actor) {
+ w.Write([]byte("main board can only follow local boards. Create a new board and then follow outside boards from it."))
+ return
+ }
- if FingerActor(r.FormValue("follow")).Id != "" {
- MakeActivityRequestOutbox(db, followActivity)
+ if FingerActor(follow).Id != "" {
+ MakeActivityRequestOutbox(db, followActivity)
+ }
}
var redirect string