From 81b06d64e8cf059f1c6699c8daa3d431639d8ff6 Mon Sep 17 00:00:00 2001 From: Farhan Khan Date: Mon, 4 Jan 2021 18:40:11 +0000 Subject: [PATCH] hack around ignoring 'to' URIs that end in /followers may remove the entire associated for-loop... --- retrieve.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/retrieve.go b/retrieve.go index e4647fc..c3fcf96 100644 --- a/retrieve.go +++ b/retrieve.go @@ -7,7 +7,7 @@ import ( "html" "io/ioutil" "log" -"io" + "io" "net/http" "strings" "time" @@ -143,12 +143,15 @@ func check_post(uri string) (PostJson, error) { _, err = pool.Exec(context.Background(), "INSERT INTO posts (id, inreplyto, published, summary, content, normalized, attributedto, posthash, instance) VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9)", postjson.ID, postjson.InReplyTo, postjson.Published, postjson.Summary, postjson.Content, postjson.normalized, postjson.AttributedTo, postjson.posthash, postjson.instance) if err != nil { - // log.Print("INSERT posts error of " + uri + ": ", err) return postjson, err } for _, to := range postjson.To { if to != "https://www.w3.org/ns/activitystreams#Public" && to != "" { + if strings.HasSuffix(to, "/followers") == true { + // This check is very much a bad solution, may consider removing the entire for-loop + continue + } go check_user(to) } } @@ -191,7 +194,7 @@ func check_user(uri string) (UserJson, error) { return userjson, err } -io.Copy(ioutil.Discard, resp.Body) + io.Copy(ioutil.Discard, resp.Body) resp.Body.Close()