diff options
author | FChannel <> | 2021-07-25 13:25:47 -0700 |
---|---|---|
committer | FChannel <> | 2021-07-25 13:25:47 -0700 |
commit | def81637bc3d9f7ff73fed2786dbaa7a78086799 (patch) | |
tree | d8a2ad427596a9a03bc83be2de03fe068f5dfecd /outboxPost.go | |
parent | 8f7386f2906716d40099fb50f029d48796dd1bbd (diff) |
fixed auto follow logic as well as out of sync following
Diffstat (limited to 'outboxPost.go')
-rw-r--r-- | outboxPost.go | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/outboxPost.go b/outboxPost.go index 1d658ea..88b9927 100644 --- a/outboxPost.go +++ b/outboxPost.go @@ -101,7 +101,7 @@ func ParseOutboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) { var rActivity Activity if validActor && validLocalActor { rActivity = AcceptFollow(activity) - SetActorFollowingDB(db, rActivity) + rActivity = SetActorFollowingDB(db, rActivity) MakeActivityRequest(db, activity) } @@ -565,16 +565,26 @@ func ParseInboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) { MakeActivityRequest(db, response) alreadyFollow := false + alreadyFollowing := false autoSub := GetActorAutoSubscribeDB(db, response.Actor.Id) following := GetActorFollowingDB(db, response.Actor.Id) for _, e := range following { - if e.Id == activity.Actor.Id { + if e.Id == response.Object.Id { alreadyFollow = true } } - if autoSub && !alreadyFollow { + actor := FingerActor(response.Object.Actor) + remoteActorFollowingCol := GetCollectionFromReq(actor.Following) + + for _, e := range remoteActorFollowingCol.Items { + if e.Id == response.Actor.Id { + alreadyFollowing = true + } + } + + if autoSub && !alreadyFollow && alreadyFollowing { followActivity := MakeFollowActivity(db, response.Actor.Id, response.Object.Actor) if FingerActor(response.Object.Actor).Id != "" { @@ -597,7 +607,6 @@ func ParseInboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) { } break } - } func MakeActivityFollowingReq(w http.ResponseWriter, r *http.Request, activity Activity) bool { |