rename some zonk stuff
This commit is contained in:
parent
bbe2045c8a
commit
9149144a2b
|
@ -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.
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
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.
|
||||
|
||||
|
|
22
fun.go
22
fun.go
|
@ -86,11 +86,11 @@ func reverbolate(honks []*Honk) {
|
|||
}
|
||||
|
||||
func osmosis(honks []*Honk, userid int64) []*Honk {
|
||||
zwords := getzwords(userid)
|
||||
zords := getzords(userid)
|
||||
j := 0
|
||||
outer:
|
||||
for _, h := range honks {
|
||||
for _, z := range zwords {
|
||||
for _, z := range zords {
|
||||
if z.MatchString(h.Precis) || z.MatchString(h.Noise) {
|
||||
continue outer
|
||||
}
|
||||
|
@ -469,7 +469,7 @@ func makeitworksomehowwithoutregardforkeycontinuity(keyname string, r *http.Requ
|
|||
}
|
||||
|
||||
var thumbbiters map[int64]map[string]bool
|
||||
var zwordses map[int64][]*regexp.Regexp
|
||||
var zordses map[int64][]*regexp.Regexp
|
||||
var thumblock sync.Mutex
|
||||
|
||||
func bitethethumbs() {
|
||||
|
@ -483,7 +483,7 @@ func bitethethumbs() {
|
|||
thumblock.Lock()
|
||||
defer thumblock.Unlock()
|
||||
thumbbiters = make(map[int64]map[string]bool)
|
||||
zwordses = make(map[int64][]*regexp.Regexp)
|
||||
zordses = make(map[int64][]*regexp.Regexp)
|
||||
for rows.Next() {
|
||||
var userid int64
|
||||
var name, wherefore string
|
||||
|
@ -492,13 +492,13 @@ func bitethethumbs() {
|
|||
log.Printf("error scanning zonker: %s", err)
|
||||
continue
|
||||
}
|
||||
if wherefore == "zword" {
|
||||
zword := "\\b(?i:" + name + ")\\b"
|
||||
re, err := regexp.Compile(zword)
|
||||
if wherefore == "zord" {
|
||||
zord := "\\b(?i:" + name + ")\\b"
|
||||
re, err := regexp.Compile(zord)
|
||||
if err != nil {
|
||||
log.Printf("error compiling zword: %s", err)
|
||||
log.Printf("error compiling zord: %s", err)
|
||||
} else {
|
||||
zwordses[userid] = append(zwordses[userid], re)
|
||||
zordses[userid] = append(zordses[userid], re)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
@ -511,10 +511,10 @@ func bitethethumbs() {
|
|||
}
|
||||
}
|
||||
|
||||
func getzwords(userid int64) []*regexp.Regexp {
|
||||
func getzords(userid int64) []*regexp.Regexp {
|
||||
thumblock.Lock()
|
||||
defer thumblock.Unlock()
|
||||
return zwordses[userid]
|
||||
return zordses[userid]
|
||||
}
|
||||
|
||||
func thoudostbitethythumb(userid int64, who []string, objid string) bool {
|
||||
|
|
8
honk.go
8
honk.go
|
@ -1178,16 +1178,16 @@ func zonkzonk(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
switch wherefore {
|
||||
case "zonker":
|
||||
case "zurl":
|
||||
case "zomain":
|
||||
case "zonvoy":
|
||||
case "zword":
|
||||
case "zord":
|
||||
default:
|
||||
return
|
||||
}
|
||||
db := opendatabase()
|
||||
db.Exec("insert into zonkers (userid, name, wherefore) values (?, ?, ?)",
|
||||
userinfo.UserID, name, wherefore)
|
||||
if wherefore == "zonker" || wherefore == "zurl" || wherefore == "zword" {
|
||||
if wherefore == "zonker" || wherefore == "zomain" || wherefore == "zord" {
|
||||
bitethethumbs()
|
||||
}
|
||||
|
||||
|
@ -1481,7 +1481,7 @@ func prepareStatements(db *sql.DB) {
|
|||
stmtGetDoovers = preparetodie(db, "select dooverid, dt from doovers")
|
||||
stmtLoadDoover = preparetodie(db, "select tries, username, rcpt, msg 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'")
|
||||
stmtGetZonkers = preparetodie(db, "select zonkerid, name, wherefore from zonkers where userid = ? and wherefore <> 'zonk'")
|
||||
stmtSaveZonker = preparetodie(db, "insert into zonkers (userid, name, wherefore) values (?, ?, ?)")
|
||||
|
|
|
@ -98,6 +98,10 @@ func upgradedb() {
|
|||
doordie(db, "create index idx_xonkername on xonkers(name)")
|
||||
doordie(db, "update config set value = 10 where key = 'dbversion'")
|
||||
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:
|
||||
log.Fatalf("can't upgrade unknown version %d", dbversion)
|
||||
}
|
||||
|
|
2
util.go
2
util.go
|
@ -71,7 +71,7 @@ var dbtimeformat = "2006-01-02 15:04:05"
|
|||
var alreadyopendb *sql.DB
|
||||
var dbname = "honk.db"
|
||||
var stmtConfig *sql.Stmt
|
||||
var myVersion = 10
|
||||
var myVersion = 11
|
||||
|
||||
func initdb() {
|
||||
schema, err := ioutil.ReadFile("schema.sql")
|
||||
|
|
|
@ -11,14 +11,14 @@
|
|||
<input type="radio" id="iszonker" name="wherefore" value="zonker">
|
||||
<label for="iszonker">Zonker</label>
|
||||
<p>
|
||||
<input type="radio" id="iszurl" name="wherefore" value="zurl">
|
||||
<label for="iszurl">Zurl</label>
|
||||
<input type="radio" id="iszomain" name="wherefore" value="zomain">
|
||||
<label for="iszomain">Zomain</label>
|
||||
<p>
|
||||
<input type="radio" id="iszonvoy" name="wherefore" value="zonvoy">
|
||||
<label for="iszonvoy">Zonvoy</label>
|
||||
<p>
|
||||
<input type="radio" id="iszword" name="wherefore" value="zword">
|
||||
<label for="iszword">Zword</label>
|
||||
<input type="radio" id="iszord" name="wherefore" value="zord">
|
||||
<label for="iszord">Zord</label>
|
||||
<p><br><input tabindex=1 type="submit" name="zonk" value="zonk!">
|
||||
</form>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue