zword zonking
This commit is contained in:
parent
6e9a2308a0
commit
d3e480d6fc
42
fun.go
42
fun.go
|
@ -76,6 +76,31 @@ func reverbolate(honks []*Honk) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func osmosis(honks []*Honk, userid int64) []*Honk {
|
||||||
|
zwords := getzwords(userid)
|
||||||
|
collapse := false
|
||||||
|
for i, h := range honks {
|
||||||
|
for _, z := range zwords {
|
||||||
|
if z.MatchString(h.Noise) {
|
||||||
|
honks[i] = nil
|
||||||
|
collapse = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if collapse {
|
||||||
|
j := 0
|
||||||
|
for i := 0; i < len(honks); i++ {
|
||||||
|
if honks[i] != nil {
|
||||||
|
honks[j] = honks[i]
|
||||||
|
j++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return honks[0:j]
|
||||||
|
}
|
||||||
|
return honks
|
||||||
|
}
|
||||||
|
|
||||||
func shortxid(xid string) string {
|
func shortxid(xid string) string {
|
||||||
idx := strings.LastIndexByte(xid, '/')
|
idx := strings.LastIndexByte(xid, '/')
|
||||||
if idx == -1 {
|
if idx == -1 {
|
||||||
|
@ -396,6 +421,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 thumblock sync.Mutex
|
var thumblock sync.Mutex
|
||||||
|
|
||||||
func bitethethumbs() {
|
func bitethethumbs() {
|
||||||
|
@ -408,6 +434,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)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var userid int64
|
var userid int64
|
||||||
var name, wherefore string
|
var name, wherefore string
|
||||||
|
@ -416,6 +443,15 @@ func bitethethumbs() {
|
||||||
log.Printf("error scanning zonker: %s", err)
|
log.Printf("error scanning zonker: %s", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if wherefore == "zword" {
|
||||||
|
re, err := regexp.Compile("\\b" + name + "\\b")
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("error compiling zword: %s", err)
|
||||||
|
} else {
|
||||||
|
zwordses[userid] = append(zwordses[userid], re)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
m := thumbbiters[userid]
|
m := thumbbiters[userid]
|
||||||
if m == nil {
|
if m == nil {
|
||||||
m = make(map[string]bool)
|
m = make(map[string]bool)
|
||||||
|
@ -425,6 +461,12 @@ func bitethethumbs() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getzwords(userid int64) []*regexp.Regexp {
|
||||||
|
thumblock.Lock()
|
||||||
|
defer thumblock.Unlock()
|
||||||
|
return zwordses[userid]
|
||||||
|
}
|
||||||
|
|
||||||
func thoudostbitethythumb(userid int64, who []string, objid string) bool {
|
func thoudostbitethythumb(userid int64, who []string, objid string) bool {
|
||||||
thumblock.Lock()
|
thumblock.Lock()
|
||||||
biters := thumbbiters[userid]
|
biters := thumbbiters[userid]
|
||||||
|
|
7
honk.go
7
honk.go
|
@ -112,6 +112,7 @@ func homepage(w http.ResponseWriter, r *http.Request) {
|
||||||
honks = gethonksforme(u.UserID)
|
honks = gethonksforme(u.UserID)
|
||||||
} else {
|
} else {
|
||||||
honks = gethonksforuser(u.UserID)
|
honks = gethonksforuser(u.UserID)
|
||||||
|
honks = osmosis(honks, u.UserID)
|
||||||
}
|
}
|
||||||
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
||||||
} else {
|
} else {
|
||||||
|
@ -486,6 +487,7 @@ func honkpage(w http.ResponseWriter, r *http.Request, u *login.UserInfo, user *W
|
||||||
reverbolate(honks)
|
reverbolate(honks)
|
||||||
templinfo := getInfo(r)
|
templinfo := getInfo(r)
|
||||||
if u != nil {
|
if u != nil {
|
||||||
|
honks = osmosis(honks, u.UserID)
|
||||||
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
||||||
}
|
}
|
||||||
if u == nil {
|
if u == nil {
|
||||||
|
@ -1096,13 +1098,14 @@ func killitwithfire(w http.ResponseWriter, r *http.Request) {
|
||||||
case "zonker":
|
case "zonker":
|
||||||
case "zurl":
|
case "zurl":
|
||||||
case "zonvoy":
|
case "zonvoy":
|
||||||
|
case "zword":
|
||||||
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" {
|
if wherefore == "zonker" || wherefore == "zurl" || wherefore == "zword" {
|
||||||
bitethethumbs()
|
bitethethumbs()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1380,7 +1383,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')")
|
stmtThumbBiters = preparetodie(db, "select userid, name, wherefore from zonkers where (wherefore = 'zonker' or wherefore = 'zurl' or wherefore = 'zword')")
|
||||||
stmtSaveZonker = preparetodie(db, "insert into zonkers (userid, name, wherefore) values (?, ?, ?)")
|
stmtSaveZonker = preparetodie(db, "insert into zonkers (userid, name, wherefore) values (?, ?, ?)")
|
||||||
stmtGetBoxes = preparetodie(db, "select ibox, obox, sbox from xonkers where xid = ?")
|
stmtGetBoxes = preparetodie(db, "select ibox, obox, sbox from xonkers where xid = ?")
|
||||||
stmtSaveBoxes = preparetodie(db, "insert into xonkers (xid, ibox, obox, sbox, pubkey) values (?, ?, ?, ?, ?)")
|
stmtSaveBoxes = preparetodie(db, "insert into xonkers (xid, ibox, obox, sbox, pubkey) values (?, ?, ?, ?, ?)")
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
<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>
|
||||||
|
<input type="radio" id="iszword" name="wherefore" value="zword">
|
||||||
|
<label for="iszword">Zword</label>
|
||||||
<p><input tabindex=1 type="submit" name="kill" value="kill">
|
<p><input tabindex=1 type="submit" name="kill" value="kill">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue