all repos — honk @ f409d2694b6afa51206b3bb7196c4310f16f5478

my fork of honk

stepping stone for unbonk
Ted Unangst tedu@tedunangst.com
Fri, 23 Aug 2019 20:43:30 -0400
commit

f409d2694b6afa51206b3bb7196c4310f16f5478

parent

ab793b88d0e934bf7b621cc82b4d347db98577b6

3 files changed, 29 insertions(+), 5 deletions(-)

jump to
M honk.gohonk.go

@@ -80,11 +80,16 @@ Donks []*Donk

} const ( - flagIsAcked = 1 + flagIsAcked = 1 + flagIsBonked = 2 ) func (honk *Honk) IsAcked() bool { return honk.Flags&flagIsAcked != 0 +} + +func (honk *Honk) IsBonked() bool { + return honk.Flags&flagIsBonked != 0 } type Donk struct {

@@ -911,6 +916,11 @@ return

} donksforhonks([]*Honk{xonk}) + _, err := stmtUpdateFlags.Exec(flagIsBonked, xonk.XID, userinfo.UserID) + if err != nil { + log.Printf("error acking bonk: %s", err) + } + oonker := xonk.Oonker if oonker == "" { oonker = xonk.Honker

@@ -970,7 +980,7 @@ userinfo := login.GetUserInfo(r)

user, _ := butwhatabout(userinfo.Username) if wherefore == "ack" { - _, err := stmtUpdateFlags.Exec(flagIsAcked, what) + _, err := stmtUpdateFlags.Exec(flagIsAcked, what, userinfo.UserID) if err != nil { log.Printf("error acking: %s", err) }

@@ -982,7 +992,7 @@ return

} if wherefore == "deack" { - _, err := stmtClearFlags.Exec(flagIsAcked, what) + _, err := stmtClearFlags.Exec(flagIsAcked, what, userinfo.UserID) if err != nil { log.Printf("error deacking: %s", err) }

@@ -990,6 +1000,11 @@ xonk := getxonk(userinfo.UserID, what)

if xonk != nil { sendzonkofsorts(xonk, user, "deack") } + return + } + + if wherefore == "unbonk" { + // todo return }

@@ -1705,8 +1720,8 @@ stmtGetXonker = preparetodie(db, "select info from xonkers where name = ? and flavor = ?")

stmtSaveXonker = preparetodie(db, "insert into xonkers (name, info, flavor) values (?, ?, ?)") stmtDeleteXonker = preparetodie(db, "delete from xonkers where name = ? and flavor = ?") stmtRecentHonkers = preparetodie(db, "select distinct(honker) from honks where userid = ? and honker not in (select xid from honkers where userid = ? and flavor = 'sub') order by honkid desc limit 100") - stmtUpdateFlags = preparetodie(db, "update honks set flags = flags | ? where xid = ?") - stmtClearFlags = preparetodie(db, "update honks set flags = flags & ~ ? where xid = ?") + stmtUpdateFlags = preparetodie(db, "update honks set flags = flags | ? where xid = ? and userid = ?") + stmtClearFlags = preparetodie(db, "update honks set flags = flags & ~ ? where xid = ? and userid = ?") } func ElaborateUnitTests() {
M views/honk.htmlviews/honk.html

@@ -71,7 +71,11 @@ </summary>

<div> <p> {{ if .Honk.Public }} +{{ if .Honk.IsBonked }} +<button onclick="unbonk(this, '{{ .Honk.XID }}');">unbonk</button> +{{ else }} <button onclick="bonk(this, '{{ .Honk.XID }}');">bonk</button> +{{ end }} {{ else }} <button disabled>nope</button> {{ end }}
M views/honkpage.htmlviews/honkpage.html

@@ -68,6 +68,11 @@ el.innerHTML = "bonked"

el.disabled = true post("/bonk", "CSRF={{ $BonkCSRF }}&xid=" + escape(xid)) } +function bonk(el, xid) { + el.innerHTML = "unbonked" + el.disabled = true + post("/zonkit", "CSRF={{ $BonkCSRF }}&wherefore=unbonk&what=" + escape(xid)) +} function muteit(el, convoy) { el.innerHTML = "muted" el.disabled = true