dost thou bite thy thumb at me?

This commit is contained in:
Ted Unangst 2019-04-19 22:35:21 -04:00
parent b2b21b9ba6
commit 6d18b97b62
2 changed files with 21 additions and 1 deletions

15
fun.go
View File

@ -296,6 +296,21 @@ func zaggy(keyname string) (key *rsa.PublicKey) {
return
}
func thoudostbitethythumb(userid int64, who string) bool {
where := ""
m := re_unurl.FindStringSubmatch(who)
if len(m) > 2 {
where = m[1]
}
row := stmtThumbBiter.QueryRow(who, where, userid)
var id int64
err := row.Scan(&id)
if err != nil {
return false
}
return true
}
func keymatch(keyname string, actor string) bool {
return strings.HasPrefix(keyname, actor)
}

View File

@ -313,6 +313,10 @@ func inbox(w http.ResponseWriter, r *http.Request) {
log.Printf("keyname actor mismatch: %s <> %s", keyname, who)
return
}
if thoudostbitethythumb(user.ID, who) {
log.Printf("ignoring thumb sucker %s", who)
return
}
fd, _ := os.OpenFile("savedinbox.json", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
WriteJunk(fd, j)
io.WriteString(fd, "\n")
@ -1047,7 +1051,7 @@ var stmtHonksForUser, stmtDeleteHonk, stmtSaveDub *sql.Stmt
var stmtHonksByHonker, stmtSaveHonk, stmtFileData, stmtWhatAbout *sql.Stmt
var stmtFindXonk, stmtSaveDonk, stmtFindFile, stmtSaveFile *sql.Stmt
var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover *sql.Stmt
var stmtZonkIt *sql.Stmt
var stmtThumbBiter, stmtZonkIt *sql.Stmt
func preparetodie(db *sql.DB, s string) *sql.Stmt {
stmt, err := db.Prepare(s)
@ -1079,6 +1083,7 @@ func prepareStatements(db *sql.DB) {
stmtLoadDoover = preparetodie(db, "select tries, username, rcpt, msg from doovers where dooverid = ?")
stmtZapDoover = preparetodie(db, "delete from doovers where dooverid = ?")
stmtZonkIt = preparetodie(db, "update honks set what = 'zonk' where userid = ? and xid = ?")
stmtThumbBiter = preparetodie(db, "select zonkerid from zonkers where ((name = ? and wherefore = 'zonker') or (name = ? and wherefore = 'zurl')) and userid = ?")
}
func ElaborateUnitTests() {