From 9e726bde40b79cf09bbe43d381b7d94445d7cee8 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Fri, 26 Apr 2019 09:35:22 -0400 Subject: [PATCH] few more improvements to blocking --- activity.go | 6 +++++- fun.go | 8 ++++---- honk.go | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/activity.go b/activity.go index 0fc81c3..3a718c4 100644 --- a/activity.go +++ b/activity.go @@ -233,6 +233,10 @@ func needxonk(user *WhatAbout, x *Honk) bool { if x.What == "eradicate" { return true } + if thoudostbitethythumb(user.ID, x.Honker, x.XID) { + log.Printf("not saving thumb biter %s\n", x.Honker) + return false + } return needxonkid(user, x.XID) } func needxonkid(user *WhatAbout, xid string) bool { @@ -370,7 +374,6 @@ func peeppeep() { for _, item := range items { xonk := xonkxonk(user, item) if needxonk(user, xonk) { - xonk.UserID = user.ID savexonk(user, xonk) } } @@ -548,6 +551,7 @@ func xonkxonk(user *WhatAbout, item interface{}) *Honk { audience = oneofakind(audience) + xonk.UserID = user.ID xonk.What = what xonk.Honker = who xonk.XID = xid diff --git a/fun.go b/fun.go index 8be5d56..ff0de17 100644 --- a/fun.go +++ b/fun.go @@ -324,7 +324,7 @@ func makeitworksomehowwithoutregardforkeycontinuity(keyname string, r *http.Requ return zag(r, payload) } -func thoudostbitethythumb(userid int64, who string) bool { +func thoudostbitethythumb(userid int64, who string, objid string) bool { where := "" m := re_unurl.FindStringSubmatch(who) if len(m) > 2 { @@ -333,10 +333,10 @@ func thoudostbitethythumb(userid int64, who string) bool { row := stmtThumbBiter.QueryRow(who, where, userid) var id int64 err := row.Scan(&id) - if err != nil { - return false + if err == nil { + return true } - return true + return false } func keymatch(keyname string, actor string, userid int64) bool { diff --git a/honk.go b/honk.go index 49cdaa5..091a8bd 100644 --- a/honk.go +++ b/honk.go @@ -320,7 +320,8 @@ func inbox(w http.ResponseWriter, r *http.Request) { log.Printf("keyname actor mismatch: %s <> %s", keyname, who) return } - if thoudostbitethythumb(user.ID, who) { + objid, _ := jsongetstring(j, "id") + if thoudostbitethythumb(user.ID, who, objid) { log.Printf("ignoring thumb sucker %s", who) return } @@ -367,7 +368,6 @@ func inbox(w http.ResponseWriter, r *http.Request) { default: xonk := xonkxonk(user, j) if needxonk(user, xonk) { - xonk.UserID = user.ID savexonk(user, xonk) } }