Cleanup of old comments
This commit is contained in:
parent
a6e7e134e0
commit
bce94cc999
@ -75,7 +75,6 @@ func check_activity(uri string) {
|
|||||||
// Ignore banned
|
// Ignore banned
|
||||||
for _, banned := range settings.Banned {
|
for _, banned := range settings.Banned {
|
||||||
if strings.Index(uri, "https://"+banned+"/") == 0 {
|
if strings.Index(uri, "https://"+banned+"/") == 0 {
|
||||||
//return activityjson, errors.New("Banned instance")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,7 +82,6 @@ func check_activity(uri string) {
|
|||||||
// Ignore invalid URIs
|
// Ignore invalid URIs
|
||||||
endslash := strings.Index(uri[8:], "/")
|
endslash := strings.Index(uri[8:], "/")
|
||||||
if endslash == -1 {
|
if endslash == -1 {
|
||||||
//return activityjson, errors.New("Invalid URI " + uri)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
activityjson.instance = uri[8 : endslash+8]
|
activityjson.instance = uri[8 : endslash+8]
|
||||||
@ -94,19 +92,15 @@ func check_activity(uri string) {
|
|||||||
o.recentactivities.Mu.Lock()
|
o.recentactivities.Mu.Lock()
|
||||||
if o.recentactivities.Add(uri) == true {
|
if o.recentactivities.Add(uri) == true {
|
||||||
o.recentactivities.Mu.Unlock()
|
o.recentactivities.Mu.Unlock()
|
||||||
//return activityjson, errors.New("Recently requested within local cache")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
o.recentactivities.Mu.Unlock()
|
o.recentactivities.Mu.Unlock()
|
||||||
var jsondocument string
|
var jsondocument string
|
||||||
// jsonmap := make(map[string]interface{})
|
|
||||||
|
|
||||||
selectRet := pool.QueryRow(context.Background(), "SELECT FROM activities WHERE document->>'id' = $1", uri)
|
selectRet := pool.QueryRow(context.Background(), "SELECT FROM activities WHERE document->>'id' = $1", uri)
|
||||||
err := selectRet.Scan()
|
err := selectRet.Scan()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
/////////// BETTER RETURN VALUES!!!!!
|
|
||||||
//return activityjson, nil
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,13 +110,11 @@ func check_activity(uri string) {
|
|||||||
|
|
||||||
resp, err := DoTries(&o, req)
|
resp, err := DoTries(&o, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//return activityjson, errors.New("Connection error to " + uri)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//return activityjson, errors.New("Read error on " + uri)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
@ -130,7 +122,6 @@ func check_activity(uri string) {
|
|||||||
err = json.Unmarshal(body, &activityjson)
|
err = json.Unmarshal(body, &activityjson)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
//return activityjson, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if activityjson.InReplyTo != "" && activityjson.InReplyTo != uri {
|
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
|
// If AttributedTo is blank, this is likely an authentication failure
|
||||||
// For now, skip it...
|
// For now, skip it...
|
||||||
if activityjson.AttributedTo == "" {
|
if activityjson.AttributedTo == "" {
|
||||||
//return activityjson, errors.New("Invalid AttributedTo value on " + uri)
|
|
||||||
return
|
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 = removeHTMLReg.ReplaceAllString(activityjson.Content, " ")
|
||||||
activityjson.normalized = html.UnescapeString(strings.ToLower(p.Sanitize(activityjson.normalized)))
|
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)
|
_, err = pool.Exec(context.Background(), "INSERT INTO activities (document, normalized, instance) VALUES($1, $2, $3)", jsondocument, activityjson.normalized, activityjson.instance)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logWarn("Error inserting %s into `activities`: "+ uri, err)
|
logWarn("Error inserting %s into `activities`: "+ uri, err)
|
||||||
//return activityjson, err
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,20 +160,17 @@ func check_activity(uri string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//return activityjson, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func check_actor(uri string) {
|
func check_actor(uri string) {
|
||||||
var actorjson ActorJson
|
var actorjson ActorJson
|
||||||
endslash := strings.Index(uri[8:], "/")
|
endslash := strings.Index(uri[8:], "/")
|
||||||
if endslash == -1 {
|
if endslash == -1 {
|
||||||
// return actorjson, errors.New("Invalid user: " + uri)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
actorjson.instance = uri[8 : endslash+8]
|
actorjson.instance = uri[8 : endslash+8]
|
||||||
for _, banned := range settings.Banned {
|
for _, banned := range settings.Banned {
|
||||||
if strings.Index(uri, "https://"+banned+"/") == 0 {
|
if strings.Index(uri, "https://"+banned+"/") == 0 {
|
||||||
// return actorjson, errors.New("Banned instance")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,16 +181,12 @@ func check_actor(uri string) {
|
|||||||
if o.recentactors.Add(uri) == true {
|
if o.recentactors.Add(uri) == true {
|
||||||
o.recentactors.Mu.Unlock()
|
o.recentactors.Mu.Unlock()
|
||||||
return
|
return
|
||||||
// return actorjson, errors.New("Recently requested actor within local cache")
|
|
||||||
}
|
}
|
||||||
o.recentactors.Mu.Unlock()
|
o.recentactors.Mu.Unlock()
|
||||||
|
|
||||||
// jsonmap := make(map[string]interface{})
|
|
||||||
selectRet := pool.QueryRow(context.Background(), "SELECT FROM actors WHERE document->>'id' = $1", uri)
|
selectRet := pool.QueryRow(context.Background(), "SELECT FROM actors WHERE document->>'id' = $1", uri)
|
||||||
err := selectRet.Scan()
|
err := selectRet.Scan()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
///////// BETTER RETURN VALUES ////////
|
|
||||||
// return actorjson, nil
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +201,6 @@ func check_actor(uri string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if tries > 10 {
|
if tries > 10 {
|
||||||
logErr("Unable to connect to "+uri+" attempt 10/10, giving up.")
|
logErr("Unable to connect to "+uri+" attempt 10/10, giving up.")
|
||||||
// return actorjson, err
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logWarn("Unable to connect to "+uri+", attempt ",tries+1,"+/10 sleeping for 30 seconds.")
|
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)
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// return actorjson, errors.New("Read error on " + uri)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
@ -240,16 +221,13 @@ func check_actor(uri string) {
|
|||||||
|
|
||||||
err = json.Unmarshal(body, &actorjson)
|
err = json.Unmarshal(body, &actorjson)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// return actorjson, err
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = pool.Exec(context.Background(), "INSERT INTO actors (document, instance) VALUES($1, $2)", jsondocument, actorjson.instance)
|
_, err = pool.Exec(context.Background(), "INSERT INTO actors (document, instance) VALUES($1, $2)", jsondocument, actorjson.instance)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logWarn("Error inserting %s into `actors`: "+uri, err)
|
logWarn("Error inserting %s into `actors`: "+uri, err)
|
||||||
// return actorjson, err
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// return actorjson, nil
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user