rename some zonk stuff

This commit is contained in:
Ted Unangst 2019-06-23 22:21:59 -04:00
parent bbe2045c8a
commit 9149144a2b
7 changed files with 27 additions and 23 deletions

View File

@ -53,7 +53,7 @@ those of others that you're tired of seeing. Be advised that deletion
works poorly in a federated environment. It's more like please disregard. works poorly in a federated environment. It's more like please disregard.
The zonkzone supports muting unwanted contacts. One may mute an actor The zonkzone supports muting unwanted contacts. One may mute an actor
(zonker), a domain (zurl), thread (zonvoy), or word (zword). (zonker), a domain (zomain), thread (zonvoy), or word (zord).
-- privacy -- privacy

View File

@ -62,7 +62,7 @@ The xonkers table stores info about external accounts that we may interact
with. Their keys, their inboxes, etc. Not user visible. with. Their keys, their inboxes, etc. Not user visible.
The zonkers table stores things we do not wish to see, per the wherefore The zonkers table stores things we do not wish to see, per the wherefore
column. zonkers are bad people, zurls are bad hosts, zonvoys are bad threads. column. Also used for tombstones for deleted honks to prevent refetching.
The xid column generally corresponds to ActivityPub id. The xid column generally corresponds to ActivityPub id.

24
fun.go
View File

@ -54,7 +54,7 @@ func reverbolate(honks []*Honk) {
zap := make(map[*Donk]bool) zap := make(map[*Donk]bool)
h.Noise = unpucker(h.Noise) h.Noise = unpucker(h.Noise)
precis := h.Precis precis := h.Precis
if strings.HasPrefix(h.Noise, "<p>" + precis) { if strings.HasPrefix(h.Noise, "<p>"+precis) {
precis = "" precis = ""
} }
if precis != "" { if precis != "" {
@ -86,11 +86,11 @@ func reverbolate(honks []*Honk) {
} }
func osmosis(honks []*Honk, userid int64) []*Honk { func osmosis(honks []*Honk, userid int64) []*Honk {
zwords := getzwords(userid) zords := getzords(userid)
j := 0 j := 0
outer: outer:
for _, h := range honks { for _, h := range honks {
for _, z := range zwords { for _, z := range zords {
if z.MatchString(h.Precis) || z.MatchString(h.Noise) { if z.MatchString(h.Precis) || z.MatchString(h.Noise) {
continue outer continue outer
} }
@ -469,7 +469,7 @@ func makeitworksomehowwithoutregardforkeycontinuity(keyname string, r *http.Requ
} }
var thumbbiters map[int64]map[string]bool var thumbbiters map[int64]map[string]bool
var zwordses map[int64][]*regexp.Regexp var zordses map[int64][]*regexp.Regexp
var thumblock sync.Mutex var thumblock sync.Mutex
func bitethethumbs() { func bitethethumbs() {
@ -483,7 +483,7 @@ func bitethethumbs() {
thumblock.Lock() thumblock.Lock()
defer thumblock.Unlock() defer thumblock.Unlock()
thumbbiters = make(map[int64]map[string]bool) thumbbiters = make(map[int64]map[string]bool)
zwordses = make(map[int64][]*regexp.Regexp) zordses = make(map[int64][]*regexp.Regexp)
for rows.Next() { for rows.Next() {
var userid int64 var userid int64
var name, wherefore string var name, wherefore string
@ -492,13 +492,13 @@ func bitethethumbs() {
log.Printf("error scanning zonker: %s", err) log.Printf("error scanning zonker: %s", err)
continue continue
} }
if wherefore == "zword" { if wherefore == "zord" {
zword := "\\b(?i:" + name + ")\\b" zord := "\\b(?i:" + name + ")\\b"
re, err := regexp.Compile(zword) re, err := regexp.Compile(zord)
if err != nil { if err != nil {
log.Printf("error compiling zword: %s", err) log.Printf("error compiling zord: %s", err)
} else { } else {
zwordses[userid] = append(zwordses[userid], re) zordses[userid] = append(zordses[userid], re)
} }
continue continue
} }
@ -511,10 +511,10 @@ func bitethethumbs() {
} }
} }
func getzwords(userid int64) []*regexp.Regexp { func getzords(userid int64) []*regexp.Regexp {
thumblock.Lock() thumblock.Lock()
defer thumblock.Unlock() defer thumblock.Unlock()
return zwordses[userid] return zordses[userid]
} }
func thoudostbitethythumb(userid int64, who []string, objid string) bool { func thoudostbitethythumb(userid int64, who []string, objid string) bool {

View File

@ -1178,16 +1178,16 @@ func zonkzonk(w http.ResponseWriter, r *http.Request) {
} }
switch wherefore { switch wherefore {
case "zonker": case "zonker":
case "zurl": case "zomain":
case "zonvoy": case "zonvoy":
case "zword": case "zord":
default: default:
return return
} }
db := opendatabase() db := opendatabase()
db.Exec("insert into zonkers (userid, name, wherefore) values (?, ?, ?)", db.Exec("insert into zonkers (userid, name, wherefore) values (?, ?, ?)",
userinfo.UserID, name, wherefore) userinfo.UserID, name, wherefore)
if wherefore == "zonker" || wherefore == "zurl" || wherefore == "zword" { if wherefore == "zonker" || wherefore == "zomain" || wherefore == "zord" {
bitethethumbs() bitethethumbs()
} }
@ -1481,7 +1481,7 @@ func prepareStatements(db *sql.DB) {
stmtGetDoovers = preparetodie(db, "select dooverid, dt from doovers") stmtGetDoovers = preparetodie(db, "select dooverid, dt from doovers")
stmtLoadDoover = preparetodie(db, "select tries, username, rcpt, msg from doovers where dooverid = ?") stmtLoadDoover = preparetodie(db, "select tries, username, rcpt, msg from doovers where dooverid = ?")
stmtZapDoover = preparetodie(db, "delete from doovers where dooverid = ?") stmtZapDoover = preparetodie(db, "delete from doovers where dooverid = ?")
stmtThumbBiters = preparetodie(db, "select userid, name, wherefore from zonkers where (wherefore = 'zonker' or wherefore = 'zurl' or wherefore = 'zword')") stmtThumbBiters = preparetodie(db, "select userid, name, wherefore from zonkers where (wherefore = 'zonker' or wherefore = 'zomain' or wherefore = 'zord')")
stmtFindZonk = preparetodie(db, "select zonkerid from zonkers where userid = ? and name = ? and wherefore = 'zonk'") stmtFindZonk = preparetodie(db, "select zonkerid from zonkers where userid = ? and name = ? and wherefore = 'zonk'")
stmtGetZonkers = preparetodie(db, "select zonkerid, name, wherefore from zonkers where userid = ? and wherefore <> 'zonk'") stmtGetZonkers = preparetodie(db, "select zonkerid, name, wherefore from zonkers where userid = ? and wherefore <> 'zonk'")
stmtSaveZonker = preparetodie(db, "insert into zonkers (userid, name, wherefore) values (?, ?, ?)") stmtSaveZonker = preparetodie(db, "insert into zonkers (userid, name, wherefore) values (?, ?, ?)")

View File

@ -98,6 +98,10 @@ func upgradedb() {
doordie(db, "create index idx_xonkername on xonkers(name)") doordie(db, "create index idx_xonkername on xonkers(name)")
doordie(db, "update config set value = 10 where key = 'dbversion'") doordie(db, "update config set value = 10 where key = 'dbversion'")
case 10: case 10:
doordie(db, "update zonkers set wherefore = 'zomain' where wherefore = 'zurl'")
doordie(db, "update zonkers set wherefore = 'zord' where wherefore = 'zword'")
doordie(db, "update config set value = 11 where key = 'dbversion'")
case 11:
default: default:
log.Fatalf("can't upgrade unknown version %d", dbversion) log.Fatalf("can't upgrade unknown version %d", dbversion)
} }

View File

@ -71,7 +71,7 @@ var dbtimeformat = "2006-01-02 15:04:05"
var alreadyopendb *sql.DB var alreadyopendb *sql.DB
var dbname = "honk.db" var dbname = "honk.db"
var stmtConfig *sql.Stmt var stmtConfig *sql.Stmt
var myVersion = 10 var myVersion = 11
func initdb() { func initdb() {
schema, err := ioutil.ReadFile("schema.sql") schema, err := ioutil.ReadFile("schema.sql")

View File

@ -11,14 +11,14 @@
<input type="radio" id="iszonker" name="wherefore" value="zonker"> <input type="radio" id="iszonker" name="wherefore" value="zonker">
<label for="iszonker">Zonker</label> <label for="iszonker">Zonker</label>
<p> <p>
<input type="radio" id="iszurl" name="wherefore" value="zurl"> <input type="radio" id="iszomain" name="wherefore" value="zomain">
<label for="iszurl">Zurl</label> <label for="iszomain">Zomain</label>
<p> <p>
<input type="radio" id="iszonvoy" name="wherefore" value="zonvoy"> <input type="radio" id="iszonvoy" name="wherefore" value="zonvoy">
<label for="iszonvoy">Zonvoy</label> <label for="iszonvoy">Zonvoy</label>
<p> <p>
<input type="radio" id="iszword" name="wherefore" value="zword"> <input type="radio" id="iszord" name="wherefore" value="zord">
<label for="iszword">Zword</label> <label for="iszord">Zord</label>
<p><br><input tabindex=1 type="submit" name="zonk" value="zonk!"> <p><br><input tabindex=1 type="submit" name="zonk" value="zonk!">
</form> </form>
</div> </div>