aboutsummaryrefslogtreecommitdiff
path: root/follow.go
diff options
context:
space:
mode:
Diffstat (limited to 'follow.go')
-rw-r--r--follow.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/follow.go b/follow.go
index b0f0515..5fb7017 100644
--- a/follow.go
+++ b/follow.go
@@ -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