From 97ce6d91545ec10f35d692ccbf60536d83f5debf Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Fri, 2 Jul 2021 02:05:58 -0700 Subject: added anchor links for index.html and public instance indexing tweak --- main.go | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'main.go') 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 } + -- cgit v1.2.3