stepping stone for unbonk
This commit is contained in:
parent
a9f0fad050
commit
9f9facba97
23
honk.go
23
honk.go
|
@ -81,12 +81,17 @@ type Honk struct {
|
||||||
|
|
||||||
const (
|
const (
|
||||||
flagIsAcked = 1
|
flagIsAcked = 1
|
||||||
|
flagIsBonked = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
func (honk *Honk) IsAcked() bool {
|
func (honk *Honk) IsAcked() bool {
|
||||||
return honk.Flags&flagIsAcked != 0
|
return honk.Flags&flagIsAcked != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (honk *Honk) IsBonked() bool {
|
||||||
|
return honk.Flags&flagIsBonked != 0
|
||||||
|
}
|
||||||
|
|
||||||
type Donk struct {
|
type Donk struct {
|
||||||
FileID int64
|
FileID int64
|
||||||
XID string
|
XID string
|
||||||
|
@ -911,6 +916,11 @@ func savebonk(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
donksforhonks([]*Honk{xonk})
|
donksforhonks([]*Honk{xonk})
|
||||||
|
|
||||||
|
_, err := stmtUpdateFlags.Exec(flagIsBonked, xonk.XID, userinfo.UserID)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("error acking bonk: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
oonker := xonk.Oonker
|
oonker := xonk.Oonker
|
||||||
if oonker == "" {
|
if oonker == "" {
|
||||||
oonker = xonk.Honker
|
oonker = xonk.Honker
|
||||||
|
@ -970,7 +980,7 @@ func zonkit(w http.ResponseWriter, r *http.Request) {
|
||||||
user, _ := butwhatabout(userinfo.Username)
|
user, _ := butwhatabout(userinfo.Username)
|
||||||
|
|
||||||
if wherefore == "ack" {
|
if wherefore == "ack" {
|
||||||
_, err := stmtUpdateFlags.Exec(flagIsAcked, what)
|
_, err := stmtUpdateFlags.Exec(flagIsAcked, what, userinfo.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error acking: %s", err)
|
log.Printf("error acking: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -982,7 +992,7 @@ func zonkit(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if wherefore == "deack" {
|
if wherefore == "deack" {
|
||||||
_, err := stmtClearFlags.Exec(flagIsAcked, what)
|
_, err := stmtClearFlags.Exec(flagIsAcked, what, userinfo.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error deacking: %s", err)
|
log.Printf("error deacking: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -993,6 +1003,11 @@ func zonkit(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if wherefore == "unbonk" {
|
||||||
|
// todo
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
log.Printf("zonking %s %s", wherefore, what)
|
log.Printf("zonking %s %s", wherefore, what)
|
||||||
if wherefore == "zonk" {
|
if wherefore == "zonk" {
|
||||||
xonk := getxonk(userinfo.UserID, what)
|
xonk := getxonk(userinfo.UserID, what)
|
||||||
|
@ -1705,8 +1720,8 @@ func prepareStatements(db *sql.DB) {
|
||||||
stmtSaveXonker = preparetodie(db, "insert into xonkers (name, info, flavor) values (?, ?, ?)")
|
stmtSaveXonker = preparetodie(db, "insert into xonkers (name, info, flavor) values (?, ?, ?)")
|
||||||
stmtDeleteXonker = preparetodie(db, "delete from xonkers where name = ? and flavor = ?")
|
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")
|
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 = ?")
|
stmtUpdateFlags = preparetodie(db, "update honks set flags = flags | ? where xid = ? and userid = ?")
|
||||||
stmtClearFlags = preparetodie(db, "update honks set flags = flags & ~ ? where xid = ?")
|
stmtClearFlags = preparetodie(db, "update honks set flags = flags & ~ ? where xid = ? and userid = ?")
|
||||||
}
|
}
|
||||||
|
|
||||||
func ElaborateUnitTests() {
|
func ElaborateUnitTests() {
|
||||||
|
|
|
@ -71,7 +71,11 @@ in reply to: <a href="{{ .RID }}" rel=noreferrer>{{ .RID }}</a>
|
||||||
<div>
|
<div>
|
||||||
<p>
|
<p>
|
||||||
{{ if .Honk.Public }}
|
{{ if .Honk.Public }}
|
||||||
|
{{ if .Honk.IsBonked }}
|
||||||
|
<button onclick="unbonk(this, '{{ .Honk.XID }}');">unbonk</button>
|
||||||
|
{{ else }}
|
||||||
<button onclick="bonk(this, '{{ .Honk.XID }}');">bonk</button>
|
<button onclick="bonk(this, '{{ .Honk.XID }}');">bonk</button>
|
||||||
|
{{ end }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<button disabled>nope</button>
|
<button disabled>nope</button>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -68,6 +68,11 @@ function bonk(el, xid) {
|
||||||
el.disabled = true
|
el.disabled = true
|
||||||
post("/bonk", "CSRF={{ $BonkCSRF }}&xid=" + escape(xid))
|
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) {
|
function muteit(el, convoy) {
|
||||||
el.innerHTML = "muted"
|
el.innerHTML = "muted"
|
||||||
el.disabled = true
|
el.disabled = true
|
||||||
|
|
Loading…
Reference in New Issue