media skipping for naughty people
This commit is contained in:
parent
42fb29c4e1
commit
409d1e9932
|
@ -542,6 +542,7 @@ func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
|
|
||||||
var xonk Honk
|
var xonk Honk
|
||||||
// early init
|
// early init
|
||||||
|
xonk.UserID = user.ID
|
||||||
xonk.Honker, _ = item.GetString("actor")
|
xonk.Honker, _ = item.GetString("actor")
|
||||||
if obj != nil {
|
if obj != nil {
|
||||||
if xonk.Honker == "" {
|
if xonk.Honker == "" {
|
||||||
|
@ -655,6 +656,9 @@ func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
} else {
|
} else {
|
||||||
log.Printf("unknown attachment: %s", at)
|
log.Printf("unknown attachment: %s", at)
|
||||||
}
|
}
|
||||||
|
if skipMedia(&xonk) {
|
||||||
|
localize = false
|
||||||
|
}
|
||||||
donk := savedonk(u, name, desc, mt, localize)
|
donk := savedonk(u, name, desc, mt, localize)
|
||||||
if donk != nil {
|
if donk != nil {
|
||||||
xonk.Donks = append(xonk.Donks, donk)
|
xonk.Donks = append(xonk.Donks, donk)
|
||||||
|
@ -713,7 +717,6 @@ func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
}
|
}
|
||||||
|
|
||||||
// init xonk
|
// init xonk
|
||||||
xonk.UserID = user.ID
|
|
||||||
xonk.What = what
|
xonk.What = what
|
||||||
xonk.XID = xid
|
xonk.XID = xid
|
||||||
xonk.RID = rid
|
xonk.RID = rid
|
||||||
|
|
|
@ -435,7 +435,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 = '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'")
|
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 (?, ?, ?)")
|
||||||
|
|
13
fun.go
13
fun.go
|
@ -659,6 +659,7 @@ func makeitworksomehowwithoutregardforkeycontinuity(keyname string, r *http.Requ
|
||||||
}
|
}
|
||||||
|
|
||||||
var thumbbiters map[int64]map[string]bool
|
var thumbbiters map[int64]map[string]bool
|
||||||
|
var zoggles map[int64]map[string]bool
|
||||||
var zordses map[int64][]*regexp.Regexp
|
var zordses map[int64][]*regexp.Regexp
|
||||||
var zilences map[int64][]*regexp.Regexp
|
var zilences map[int64][]*regexp.Regexp
|
||||||
var thumblock sync.Mutex
|
var thumblock sync.Mutex
|
||||||
|
@ -674,6 +675,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)
|
||||||
|
zoggles = make(map[int64]map[string]bool)
|
||||||
zordses = make(map[int64][]*regexp.Regexp)
|
zordses = make(map[int64][]*regexp.Regexp)
|
||||||
zilences = make(map[int64][]*regexp.Regexp)
|
zilences = make(map[int64][]*regexp.Regexp)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
|
@ -696,8 +698,16 @@ func bitethethumbs() {
|
||||||
zilences[userid] = append(zilences[userid], re)
|
zilences[userid] = append(zilences[userid], re)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
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]
|
m := thumbbiters[userid]
|
||||||
if m == nil {
|
if m == nil {
|
||||||
m = make(map[string]bool)
|
m = make(map[string]bool)
|
||||||
|
@ -705,6 +715,7 @@ func bitethethumbs() {
|
||||||
}
|
}
|
||||||
m[name] = true
|
m[name] = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getzords(userid int64) []*regexp.Regexp {
|
func getzords(userid int64) []*regexp.Regexp {
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
|
@ -22,6 +22,9 @@
|
||||||
<p>
|
<p>
|
||||||
<input type="radio" id="iszilence" name="wherefore" value="zilence">
|
<input type="radio" id="iszilence" name="wherefore" value="zilence">
|
||||||
<label for="iszilence">Zilence</label>
|
<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!">
|
<p><br><input tabindex=1 type="submit" name="zonk" value="zonk!">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
4
web.go
4
web.go
|
@ -1265,13 +1265,15 @@ func zonkzonk(w http.ResponseWriter, r *http.Request) {
|
||||||
case "zonvoy":
|
case "zonvoy":
|
||||||
case "zord":
|
case "zord":
|
||||||
case "zilence":
|
case "zilence":
|
||||||
|
case "zoggle":
|
||||||
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 == "zomain" || wherefore == "zord" || wherefore == "zilence" {
|
|
||||||
|
if wherefore != "zonvoy" {
|
||||||
bitethethumbs()
|
bitethethumbs()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue