Fixing activities cached mechanism, actors still broken

This commit is contained in:
Farhan Khan 2023-07-13 16:36:19 +00:00
parent 0b38f818d3
commit 731c2b7ac9
Signed by untrusted user who does not match committer: farhan
GPG Key ID: 45FE45AD7E54F59B

View File

@ -96,11 +96,12 @@ func check_activity(uri string) {
o.Recentactivities.Mu.Lock() o.Recentactivities.Mu.Lock()
i, _ := o.Recentactivities.Contains(uri) i, _ := o.Recentactivities.Contains(uri)
if i != -1 { if i != -1 {
logDebug("Ignoring recent request: ", uri) logDebug("Ignoring cached recent request: ", uri)
o.Recentactivities.Mu.Unlock() o.Recentactivities.Mu.Unlock()
return return
} }
o.Recentactivities.Add(uri, "") // Added blank entry
o.Recentactivities.Mu.Unlock() o.Recentactivities.Mu.Unlock()
var jsondocument string var jsondocument string
@ -149,6 +150,7 @@ 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 == "" {
logDebug("AttributedTo field is blank, dropping for ", uri)
return return
} }
@ -208,6 +210,7 @@ func check_actor(uri string) *ActorJson {
// Check if there were any recent requests on this // Check if there were any recent requests on this
o, _ := GetRunner(actorjson.instance) o, _ := GetRunner(actorjson.instance)
if o.Banned { if o.Banned {
logDebug("Banned actor: ", uri)
return nil // Banned actor return nil // Banned actor
} }
o.Recentactors.Mu.Lock() o.Recentactors.Mu.Lock()
@ -248,6 +251,7 @@ func check_actor(uri string) *ActorJson {
body, err := ioutil.ReadAll(resp.Body) body, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
logWarn("Unable to read body from ", uri)
return nil // Unable to read body of message return nil // Unable to read body of message
} }
resp.Body.Close() resp.Body.Close()
@ -256,8 +260,10 @@ func check_actor(uri string) *ActorJson {
err = json.Unmarshal(body, &actorjson) err = json.Unmarshal(body, &actorjson)
if err != nil { if err != nil {
logWarn("Unable to unmarshal body from ", uri)
return nil // Unable to unmarshal body of message return nil // Unable to unmarshal body of message
} }
o.Recentactors.Add(uri, actorjson)
var bot bool var bot bool
if actorjson.Type == "Service" { if actorjson.Type == "Service" {