aboutsummaryrefslogtreecommitdiff
path: root/webfinger
diff options
context:
space:
mode:
authorFChannel <>2022-05-02 12:07:00 -0700
committerFChannel <>2022-06-19 12:53:29 -0700
commit733f911fadc872933481bcbe087d519ce00372df (patch)
tree54788da4f730bd11934401c1eca48a3c87f08027 /webfinger
parente80fe14f7985f9e85bfb9582926acd7891455786 (diff)
cleaned up main
Diffstat (limited to 'webfinger')
-rw-r--r--webfinger/webfinger.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/webfinger/webfinger.go b/webfinger/webfinger.go
index 7e58d00..a58c9ab 100644
--- a/webfinger/webfinger.go
+++ b/webfinger/webfinger.go
@@ -6,6 +6,7 @@ import (
"net/http"
"regexp"
"strings"
+ "time"
"github.com/FChannel0/FChannel-Server/activitypub"
"github.com/FChannel0/FChannel-Server/config"
@@ -239,3 +240,46 @@ func AddFollowersToActivity(activity activitypub.Activity) (activitypub.Activity
return activity, nil
}
+
+func IsValidActor(id string) (activitypub.Actor, bool, error) {
+ actor, err := FingerActor(id)
+ return actor, actor.Id != "", err
+}
+
+func AddInstanceToIndexDB(actor string) error {
+ // TODO: completely disabling this until it is actually reasonable to turn it on
+ // only actually allow this when it more or less works, i.e. can post, make threads, manage boards, etc
+ return nil
+
+ //sleep to be sure the webserver is fully initialized
+ //before making finger request
+ time.Sleep(15 * time.Second)
+
+ nActor, err := FingerActor(actor)
+ if err != nil {
+ return err
+ }
+
+ if nActor.Id == "" {
+ return nil
+ }
+
+ // TODO: maybe allow different indexes?
+ followers, err := activitypub.GetCollectionFromID("https://fchan.xyz/followers")
+ if err != nil {
+ return err
+ }
+
+ var alreadyIndex = false
+ for _, e := range followers.Items {
+ if e.Id == nActor.Id {
+ alreadyIndex = true
+ }
+ }
+
+ if !alreadyIndex {
+ return activitypub.AddFollower("https://fchan.xyz", nActor.Id)
+ }
+
+ return nil
+}