aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go49
1 files changed, 28 insertions, 21 deletions
diff --git a/main.go b/main.go
index 9dac9e2..2874396 100644
--- a/main.go
+++ b/main.go
@@ -1115,29 +1115,9 @@ func main() {
return
}
- followers := GetCollectionFromID("https://fchan.xyz/followers")
- var alreadyIndex = false
- for _, e := range followers.Items {
- if e.Id == actor {
- alreadyIndex = true
- }
- }
-
- // delay to give instance time to boot up
- time.Sleep(15 * time.Second)
-
- checkActor := GetActor(actor)
- if checkActor.Id == actor {
- if !alreadyIndex {
- query := `insert into follower (id, follower) values ($1, $2)`
-
- _, err := db.Exec(query, "https://fchan.xyz", actor)
-
- CheckError(err, "Error with add to index query")
- }
- }
+ go AddInstanceToIndexDB(db, actor)
})
fmt.Println("Server for " + Domain + " running on port " + Port)
@@ -2449,6 +2429,32 @@ func AddInstanceToIndex(actor string) {
}
}
+func AddInstanceToIndexDB(db *sql.DB, actor string) {
+
+ time.Sleep(15 * time.Second)
+
+ followers := GetCollectionFromID("https://fchan.xyz/followers")
+
+ var alreadyIndex = false
+ for _, e := range followers.Items {
+ if e.Id == actor {
+ alreadyIndex = true
+ }
+ }
+
+ checkActor := GetActor(actor)
+
+ if checkActor.Id == actor {
+ if !alreadyIndex {
+ query := `insert into follower (id, follower) values ($1, $2)`
+
+ _, err := db.Exec(query, "https://fchan.xyz", actor)
+
+ CheckError(err, "Error with add to index query")
+ }
+ }
+}
+
func GetCollectionFromReq(path string) Collection {
req, err := http.NewRequest("GET", path, nil)
@@ -2474,3 +2480,4 @@ func GetCollectionFromReq(path string) Collection {
return respCollection
}
+