diff options
author | Amelia <47868520+knotteye@users.noreply.github.com> | 2021-07-02 12:59:03 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-02 12:59:03 +0000 |
commit | 3a1e1090b31772908ceed43380cd09bc41019270 (patch) | |
tree | eb675714319a0600e521f08cb6ee8c85e6036f43 /main.go | |
parent | d98441da108725a76d697e358d161c06783cb066 (diff) | |
parent | 97ce6d91545ec10f35d692ccbf60536d83f5debf (diff) |
Merge branch 'master' into master
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 49 |
1 files changed, 28 insertions, 21 deletions
@@ -1141,29 +1141,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) @@ -2475,6 +2455,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) @@ -2500,3 +2506,4 @@ func GetCollectionFromReq(path string) Collection { return respCollection } + |