aboutsummaryrefslogtreecommitdiff
path: root/follow.go
diff options
context:
space:
mode:
Diffstat (limited to 'follow.go')
-rw-r--r--follow.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/follow.go b/follow.go
index 7c56136..b0f0515 100644
--- a/follow.go
+++ b/follow.go
@@ -217,3 +217,49 @@ func SetActorFollowingDB(db *sql.DB, activity Activity) Activity {
activity.Type = "Accept"
return activity
}
+
+func AutoFollow(db *sql.DB, actor string) {
+ following := GetActorFollowingDB(db, actor)
+ follower := GetActorFollowDB(db, actor)
+
+ isFollowing := false
+
+ for _, e := range follower {
+ for _, k := range following {
+ if e.Id == k.Id {
+ isFollowing = true
+ }
+ }
+
+ if !isFollowing && e.Id != Domain {
+ followActivity := MakeFollowActivity(db, actor, e.Id)
+
+ if FingerActor(e.Id).Id != "" {
+ MakeActivityRequestOutbox(db, followActivity)
+ }
+ }
+ }
+}
+
+func MakeFollowActivity(db *sql.DB, actor string, follow string) Activity {
+ var followActivity Activity
+
+ followActivity.AtContext.Context = "https://www.w3.org/ns/activitystreams"
+ followActivity.Type = "Follow"
+
+ var obj ObjectBase
+ var nactor Actor
+ if actor == Domain {
+ nactor = GetActorFromDB(db, actor)
+ } else {
+ nactor = FingerActor(actor)
+ }
+
+ followActivity.Actor = &nactor
+ followActivity.Object = &obj
+
+ followActivity.Object.Actor = follow
+ followActivity.To = append(followActivity.To, follow)
+
+ return followActivity
+}