all repos — honk @ 669d5fd446365e7a0f90a7d3aca5d5b40a90920c

my fork of honk

media skipping for naughty people
Ted Unangst tedu@tedunangst.com
Sat, 28 Sep 2019 17:40:24 -0400
commit

669d5fd446365e7a0f90a7d3aca5d5b40a90920c

parent

797d5230f3b0c8a6d7f5ddc0df695fee2dd948ef

6 files changed, 60 insertions(+), 9 deletions(-)

jump to
M activity.goactivity.go

@@ -542,6 +542,7 @@ }

var xonk Honk // early init + xonk.UserID = user.ID xonk.Honker, _ = item.GetString("actor") if obj != nil { if xonk.Honker == "" {

@@ -655,6 +656,9 @@ }

} else { log.Printf("unknown attachment: %s", at) } + if skipMedia(&xonk) { + localize = false + } donk := savedonk(u, name, desc, mt, localize) if donk != nil { xonk.Donks = append(xonk.Donks, donk)

@@ -713,7 +717,6 @@ currenttid = convoy

} // init xonk - xonk.UserID = user.ID xonk.What = what xonk.XID = xid xonk.RID = rid
M database.godatabase.go

@@ -435,7 +435,7 @@ stmtAddDoover = preparetodie(db, "insert into doovers (dt, tries, username, rcpt, msg) values (?, ?, ?, ?, ?)")

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 = 'zomain' or wherefore = 'zord' or wherefore = 'zilence')") + stmtThumbBiters = preparetodie(db, "select userid, name, wherefore from zonkers") 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 (?, ?, ?)")
M fun.gofun.go

@@ -659,6 +659,7 @@ return httpsig.VerifyRequest(r, payload, zaggy)

} var thumbbiters map[int64]map[string]bool +var zoggles map[int64]map[string]bool var zordses map[int64][]*regexp.Regexp var zilences map[int64][]*regexp.Regexp var thumblock sync.Mutex

@@ -674,6 +675,7 @@

thumblock.Lock() defer thumblock.Unlock() thumbbiters = make(map[int64]map[string]bool) + zoggles = make(map[int64]map[string]bool) zordses = make(map[int64][]*regexp.Regexp) zilences = make(map[int64][]*regexp.Regexp) for rows.Next() {

@@ -696,14 +698,23 @@ } else {

zilences[userid] = append(zilences[userid], re) } } - continue } - m := thumbbiters[userid] - if m == nil { - m = make(map[string]bool) - thumbbiters[userid] = m + if wherefore == "zoggle" { + m := zoggles[userid] + if m == nil { + m = make(map[string]bool) + zoggles[userid] = m + } + m[name] = true + } + if wherefore == "zonker" || wherefore == "zomain" { + m := thumbbiters[userid] + if m == nil { + m = make(map[string]bool) + thumbbiters[userid] = m + } + m[name] = true } - m[name] = true } }
A hfcs.go

@@ -0,0 +1,32 @@

+// +// Copyright (c) 2019 Ted Unangst <tedu@tedunangst.com> +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +package main + +import ( + "log" +) + +func skipMedia(xonk *Honk) bool { + thumblock.Lock() + goggles := zoggles[xonk.UserID] + thumblock.Unlock() + + if goggles[xonk.Honker] || goggles[xonk.Oonker] { + log.Printf("skipping media") + return true + } + return false +}
M views/zonkers.htmlviews/zonkers.html

@@ -22,6 +22,9 @@ <label for="iszord">Zord</label>

<p> <input type="radio" id="iszilence" name="wherefore" value="zilence"> <label for="iszilence">Zilence</label> +<p> +<input type="radio" id="iszoggle" name="wherefore" value="zoggle"> +<label for="iszoggle">Zoggle</label> <p><br><input tabindex=1 type="submit" name="zonk" value="zonk!"> </form> </div>
M web.goweb.go

@@ -1265,13 +1265,15 @@ case "zomain":

case "zonvoy": case "zord": case "zilence": + case "zoggle": default: return } db := opendatabase() db.Exec("insert into zonkers (userid, name, wherefore) values (?, ?, ?)", userinfo.UserID, name, wherefore) - if wherefore == "zonker" || wherefore == "zomain" || wherefore == "zord" || wherefore == "zilence" { + + if wherefore != "zonvoy" { bitethethumbs() }