From bce94cc999d56b6d332fe9e5462a43698cbaa7fc Mon Sep 17 00:00:00 2001 From: Farhan Khan Date: Wed, 29 Sep 2021 15:05:17 +0000 Subject: [PATCH] Cleanup of old comments --- fedilogue/retrieve.go | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/fedilogue/retrieve.go b/fedilogue/retrieve.go index baa52c7..6594945 100644 --- a/fedilogue/retrieve.go +++ b/fedilogue/retrieve.go @@ -75,7 +75,6 @@ func check_activity(uri string) { // Ignore banned for _, banned := range settings.Banned { if strings.Index(uri, "https://"+banned+"/") == 0 { - //return activityjson, errors.New("Banned instance") return } } @@ -83,7 +82,6 @@ func check_activity(uri string) { // Ignore invalid URIs endslash := strings.Index(uri[8:], "/") if endslash == -1 { - //return activityjson, errors.New("Invalid URI " + uri) return } activityjson.instance = uri[8 : endslash+8] @@ -94,19 +92,15 @@ func check_activity(uri string) { o.recentactivities.Mu.Lock() if o.recentactivities.Add(uri) == true { o.recentactivities.Mu.Unlock() - //return activityjson, errors.New("Recently requested within local cache") return } o.recentactivities.Mu.Unlock() var jsondocument string -// jsonmap := make(map[string]interface{}) selectRet := pool.QueryRow(context.Background(), "SELECT FROM activities WHERE document->>'id' = $1", uri) err := selectRet.Scan() if err == nil { - /////////// BETTER RETURN VALUES!!!!! - //return activityjson, nil return } @@ -116,13 +110,11 @@ func check_activity(uri string) { resp, err := DoTries(&o, req) if err != nil { - //return activityjson, errors.New("Connection error to " + uri) return } body, err := ioutil.ReadAll(resp.Body) if err != nil { - //return activityjson, errors.New("Read error on " + uri) return } resp.Body.Close() @@ -130,7 +122,6 @@ func check_activity(uri string) { err = json.Unmarshal(body, &activityjson) if err != nil { return - //return activityjson, err } if activityjson.InReplyTo != "" && activityjson.InReplyTo != uri { @@ -142,11 +133,11 @@ func check_activity(uri string) { // If AttributedTo is blank, this is likely an authentication failure // For now, skip it... if activityjson.AttributedTo == "" { - //return activityjson, errors.New("Invalid AttributedTo value on " + uri) return } - go check_actor(activityjson.AttributedTo) // This must be done BEFORE the `INSERT INTO activities'` below + // This must be done BEFORE the `INSERT INTO activities'` below + go check_actor(activityjson.AttributedTo) activityjson.normalized = removeHTMLReg.ReplaceAllString(activityjson.Content, " ") activityjson.normalized = html.UnescapeString(strings.ToLower(p.Sanitize(activityjson.normalized))) @@ -156,7 +147,6 @@ func check_activity(uri string) { _, err = pool.Exec(context.Background(), "INSERT INTO activities (document, normalized, instance) VALUES($1, $2, $3)", jsondocument, activityjson.normalized, activityjson.instance) if err != nil { logWarn("Error inserting %s into `activities`: "+ uri, err) - //return activityjson, err return } @@ -170,20 +160,17 @@ func check_activity(uri string) { } } - //return activityjson, nil } func check_actor(uri string) { var actorjson ActorJson endslash := strings.Index(uri[8:], "/") if endslash == -1 { -// return actorjson, errors.New("Invalid user: " + uri) return } actorjson.instance = uri[8 : endslash+8] for _, banned := range settings.Banned { if strings.Index(uri, "https://"+banned+"/") == 0 { -// return actorjson, errors.New("Banned instance") return } } @@ -194,16 +181,12 @@ func check_actor(uri string) { if o.recentactors.Add(uri) == true { o.recentactors.Mu.Unlock() return -// return actorjson, errors.New("Recently requested actor within local cache") } o.recentactors.Mu.Unlock() -// jsonmap := make(map[string]interface{}) selectRet := pool.QueryRow(context.Background(), "SELECT FROM actors WHERE document->>'id' = $1", uri) err := selectRet.Scan() if err == nil { - ///////// BETTER RETURN VALUES //////// -// return actorjson, nil return } @@ -218,7 +201,6 @@ func check_actor(uri string) { if err != nil { if tries > 10 { logErr("Unable to connect to "+uri+" attempt 10/10, giving up.") -// return actorjson, err return } logWarn("Unable to connect to "+uri+", attempt ",tries+1,"+/10 sleeping for 30 seconds.") @@ -231,7 +213,6 @@ func check_actor(uri string) { body, err := ioutil.ReadAll(resp.Body) if err != nil { -// return actorjson, errors.New("Read error on " + uri) return } resp.Body.Close() @@ -240,16 +221,13 @@ func check_actor(uri string) { err = json.Unmarshal(body, &actorjson) if err != nil { -// return actorjson, err return } _, err = pool.Exec(context.Background(), "INSERT INTO actors (document, instance) VALUES($1, $2)", jsondocument, actorjson.instance) if err != nil { logWarn("Error inserting %s into `actors`: "+uri, err) -// return actorjson, err return } -// return actorjson, nil }