diff options
author | FChannel <> | 2021-07-15 14:47:22 -0700 |
---|---|---|
committer | FChannel <> | 2021-07-15 14:47:22 -0700 |
commit | e97c3e9d2d1bedf63a7d341eb199c9500bcd8cd9 (patch) | |
tree | 809ed7c01e51e3ef7beb746b3dc77f17fdca3936 /follow.go | |
parent | 22ee823b6e9200317337941c2ad41ca9df9dd855 (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 'follow.go')
-rw-r--r-- | follow.go | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -152,17 +152,22 @@ func RejectActivity(activity Activity) Activity { return accept } -func SetActorFollowerDB(db *sql.DB, activity Activity) Activity { - var query string - alreadyFollow := false - followers := GetActorFollowDB(db, activity.Actor.Id) +func IsAlreadyFollowing(db *sql.DB, actor string, follow string) bool { + followers := GetActorFollowingDB(db, actor) for _, e := range followers { - if e.Id == activity.Object.Actor { - alreadyFollow = true + if e.Id == follow { + return true } } + return false; +} + +func SetActorFollowerDB(db *sql.DB, activity Activity) Activity { + var query string + alreadyFollow := IsAlreadyFollowing(db, activity.Actor.Id, activity.Object.Actor) + if alreadyFollow { query = `delete from follower where id=$1 and follower=$2` activity.Summary = activity.Object.Actor + " Unfollow " + activity.Actor.Id |