all repos — honk @ c9e59fe5f556516671ac31814026c395fc7297d8

my fork of honk

option to desub part of a thread. somewhat suspect implementation...
Ted Unangst tedu@tedunangst.com
Mon, 28 Oct 2019 23:09:37 -0400
commit

c9e59fe5f556516671ac31814026c395fc7297d8

parent

80d720115661b404ac9e9b10716654ae0fd920b3

6 files changed, 58 insertions(+), 12 deletions(-)

jump to
M database.godatabase.go

@@ -680,7 +680,7 @@ var stmtHonksBySearch, stmtHonksByHonker, stmtSaveHonk, stmtUserByName, stmtUserByNumber *sql.Stmt

var stmtEventHonks, stmtOneBonk, stmtFindZonk, stmtFindXonk, stmtSaveDonk *sql.Stmt var stmtFindFile, stmtGetFileData, stmtSaveFileData, stmtSaveFile *sql.Stmt var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover, stmtOneHonker *sql.Stmt -var stmtThumbBiters, stmtDeleteHonk, stmtDeleteDonks, stmtDeleteOnts, stmtSaveZonker *sql.Stmt +var stmtDesubbed, stmtDeleteHonk, stmtDeleteDonks, stmtDeleteOnts, stmtSaveZonker *sql.Stmt var stmtGetZonkers, stmtRecentHonkers, stmtGetXonker, stmtSaveXonker, stmtDeleteXonker *sql.Stmt var stmtAllOnts, stmtSaveOnt, stmtUpdateFlags, stmtClearFlags *sql.Stmt var stmtHonksForUserFirstClass, stmtSaveMeta, stmtDeleteMeta, stmtUpdateHonk *sql.Stmt

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

stmtGetDoovers = preparetodie(db, "select dooverid, dt from doovers") stmtLoadDoover = preparetodie(db, "select tries, userid, rcpt, msg from doovers where dooverid = ?") stmtZapDoover = preparetodie(db, "delete from doovers where dooverid = ?") - stmtThumbBiters = preparetodie(db, "select userid, name, wherefore from zonkers") + stmtDesubbed = preparetodie(db, "select name from zonkers where userid = ? and wherefore = 'desub'") 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 go.modgo.mod

@@ -10,7 +10,7 @@ github.com/rivo/uniseg v0.0.0-20190313204849-f699dde9c340 // indirect

golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4 golang.org/x/net v0.0.0-20190620200207-3b0461eec859 humungus.tedunangst.com/r/go-sqlite3 v1.1.3 - humungus.tedunangst.com/r/webs v0.6.19 + humungus.tedunangst.com/r/webs v0.6.20 ) go 1.11
M go.sumgo.sum

@@ -36,3 +36,5 @@ humungus.tedunangst.com/r/go-sqlite3 v1.1.3 h1:G2N4wzDS0NbuvrZtQJhh4F+3X+s7BF8b9ga8k38geUI=

humungus.tedunangst.com/r/go-sqlite3 v1.1.3/go.mod h1:FtEEmQM7U2Ey1TuEEOyY1BmphTZnmiEjPsNLEAkpf/M= humungus.tedunangst.com/r/webs v0.6.19 h1:0cxR4JmHDMQmMwboRlycRO+67OPtgtCwLX8fuDu9IRo= humungus.tedunangst.com/r/webs v0.6.19/go.mod h1:S9sXpVSbgAIa24yYhnMN0C94LKHG+2rioS+NsiDimps= +humungus.tedunangst.com/r/webs v0.6.20 h1:fKTjJ+EQUlxj8vWBtFMhX7aYbMwAnUWbDhY7hotkXq0= +humungus.tedunangst.com/r/webs v0.6.20/go.mod h1:S9sXpVSbgAIa24yYhnMN0C94LKHG+2rioS+NsiDimps=
M hfcs.gohfcs.go

@@ -302,9 +302,48 @@ }

} } -func osmosis(honks []*Honk, userid int64) []*Honk { +var desubbed = cache.New(cache.Options{Filler: func(userid int64) (map[string]bool, bool) { + rows, err := stmtDesubbed.Query(userid) + if err != nil { + log.Printf("error query desubbed: %s", err) + return nil, false + } + defer rows.Close() + m := make(map[string]bool) + for rows.Next() { + var xid string + err = rows.Scan(&xid) + if err != nil { + log.Printf("error scanning desub: %s", err) + continue + } + log.Printf("bad parent: %s", xid) + m[xid] = true + } + return m, true +}}) + +func osmosis(honks []*Honk, userid int64, withfilt bool) []*Honk { + var badparents map[string]bool + desubbed.GetAndLock(userid, &badparents) + j := 0 + reversehonks(honks) + for _, h := range honks { + if badparents[h.RID] { + badparents[h.XID] = true + continue + } + honks[j] = h + j++ + } + desubbed.Unlock() + honks = honks[0:j] + reversehonks(honks) + if !withfilt { + return honks + } filts := getfilters(userid, filtHide) - j := 0 + j = 0 outer: for _, h := range honks { for _, f := range filts {
M views/honk.htmlviews/honk.html

@@ -112,6 +112,7 @@ <button onclick="return flogit(this, 'unsave', '{{ .Honk.XID }}');">unsave</button>

{{ else }} <button onclick="return flogit(this, 'save', '{{ .Honk.XID }}');">save</button> {{ end }} +<button onclick="return flogit(this, 'desub', '{{ .Honk.XID }}');">desub</button> <button><a href="/edit?xid={{ .Honk.XID }}">edit</a></button> </div> </details>
M web.goweb.go

@@ -101,15 +101,16 @@ case "/atme":

templinfo["ServerMessage"] = "at me!" templinfo["PageName"] = "atme" honks = gethonksforme(userid, 0) + honks = osmosis(honks, userid, false) case "/events": templinfo["ServerMessage"] = "some recent and upcoming events" templinfo["PageName"] = "events" honks = geteventhonks(userid) - honks = osmosis(honks, userid) + honks = osmosis(honks, userid, true) case "/first": templinfo["PageName"] = "first" honks = gethonksforuser(userid, 0) - honks = osmosis(honks, userid) + honks = osmosis(honks, userid, true) case "/saved": templinfo["ServerMessage"] = "saved honks" templinfo["PageName"] = "saved"

@@ -117,7 +118,7 @@ honks = getsavedhonks(userid, 0)

default: templinfo["PageName"] = "home" honks = gethonksforuser(userid, 0) - honks = osmosis(honks, userid) + honks = osmosis(honks, userid, true) } templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r) }

@@ -723,7 +724,7 @@ func showcombo(w http.ResponseWriter, r *http.Request) {

name := mux.Vars(r)["name"] u := login.GetUserInfo(r) honks := gethonksbycombo(u.UserID, name, 0) - honks = osmosis(honks, u.UserID) + honks = osmosis(honks, u.UserID, true) templinfo := getInfo(r) templinfo["PageName"] = "combo" templinfo["PageArg"] = name

@@ -739,6 +740,7 @@ templinfo := getInfo(r)

if len(honks) > 0 { templinfo["TopHID"] = honks[0].ID } + honks = osmosis(honks, u.UserID, false) reversehonks(honks) templinfo["PageName"] = "convoy" templinfo["PageArg"] = c

@@ -1822,14 +1824,15 @@ var honks []*Honk

switch page { case "atme": honks = gethonksforme(userid, wanted) + honks = osmosis(honks, userid, false) templinfo["ServerMessage"] = "at me!" case "home": honks = gethonksforuser(userid, wanted) - honks = osmosis(honks, userid) + honks = osmosis(honks, userid, true) templinfo["ServerMessage"] = serverMsg case "first": honks = gethonksforuserfirstclass(userid, wanted) - honks = osmosis(honks, userid) + honks = osmosis(honks, userid, true) templinfo["ServerMessage"] = "first class only" case "saved": honks = getsavedhonks(userid, wanted)

@@ -1838,11 +1841,12 @@ templinfo["ServerMessage"] = "saved honks"

case "combo": c := r.FormValue("c") honks = gethonksbycombo(userid, c, wanted) - honks = osmosis(honks, userid) + honks = osmosis(honks, userid, false) templinfo["ServerMessage"] = "honks by combo: " + c case "convoy": c := r.FormValue("c") honks = gethonksbyconvoy(userid, c, wanted) + honks = osmosis(honks, userid, false) templinfo["ServerMessage"] = "honks in convoy: " + c case "honker": xid := r.FormValue("xid")