allow deacking a post as well
This commit is contained in:
parent
e9c5b28217
commit
34f2844ffe
19
honk.go
19
honk.go
|
@ -83,8 +83,8 @@ const (
|
||||||
flagIsAcked = 1
|
flagIsAcked = 1
|
||||||
)
|
)
|
||||||
|
|
||||||
func honkIsAcked(flags int64) bool {
|
func (honk *Honk) IsAcked() bool {
|
||||||
return flags&flagIsAcked != 0
|
return honk.Flags&flagIsAcked != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
type Donk struct {
|
type Donk struct {
|
||||||
|
@ -639,7 +639,7 @@ func showhonk(w http.ResponseWriter, r *http.Request) {
|
||||||
rawhonks := gethonksbyconvoy(honk.UserID, honk.Convoy)
|
rawhonks := gethonksbyconvoy(honk.UserID, honk.Convoy)
|
||||||
if friendorfoe(r.Header.Get("Accept")) {
|
if friendorfoe(r.Header.Get("Accept")) {
|
||||||
for _, h := range rawhonks {
|
for _, h := range rawhonks {
|
||||||
if h.RID == honk.XID && h.Public && (h.Whofore == 2 || honkIsAcked(h.Flags)) {
|
if h.RID == honk.XID && h.Public && (h.Whofore == 2 || h.IsAcked()) {
|
||||||
honk.Replies = append(honk.Replies, h)
|
honk.Replies = append(honk.Replies, h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -652,7 +652,7 @@ func showhonk(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
var honks []*Honk
|
var honks []*Honk
|
||||||
for _, h := range rawhonks {
|
for _, h := range rawhonks {
|
||||||
if h.Public && (h.Whofore == 2 || honkIsAcked(h.Flags)) {
|
if h.Public && (h.Whofore == 2 || h.IsAcked()) {
|
||||||
honks = append(honks, h)
|
honks = append(honks, h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -942,6 +942,14 @@ func zonkit(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if wherefore == "deack" {
|
||||||
|
_, err := stmtClearFlags.Exec(flagIsAcked, what)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("error deacking: %s", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
log.Printf("zonking %s %s", wherefore, what)
|
log.Printf("zonking %s %s", wherefore, what)
|
||||||
userinfo := login.GetUserInfo(r)
|
userinfo := login.GetUserInfo(r)
|
||||||
if wherefore == "zonk" {
|
if wherefore == "zonk" {
|
||||||
|
@ -1611,7 +1619,7 @@ var stmtFindZonk, stmtFindXonk, stmtSaveDonk, stmtFindFile, stmtSaveFile *sql.St
|
||||||
var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover *sql.Stmt
|
var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover *sql.Stmt
|
||||||
var stmtHasHonker, stmtThumbBiters, stmtZonkIt, stmtZonkDonks, stmtSaveZonker *sql.Stmt
|
var stmtHasHonker, stmtThumbBiters, stmtZonkIt, stmtZonkDonks, stmtSaveZonker *sql.Stmt
|
||||||
var stmtGetZonkers, stmtRecentHonkers, stmtGetXonker, stmtSaveXonker, stmtDeleteXonker *sql.Stmt
|
var stmtGetZonkers, stmtRecentHonkers, stmtGetXonker, stmtSaveXonker, stmtDeleteXonker *sql.Stmt
|
||||||
var stmtUpdateFlags *sql.Stmt
|
var stmtUpdateFlags, stmtClearFlags *sql.Stmt
|
||||||
|
|
||||||
func preparetodie(db *sql.DB, s string) *sql.Stmt {
|
func preparetodie(db *sql.DB, s string) *sql.Stmt {
|
||||||
stmt, err := db.Prepare(s)
|
stmt, err := db.Prepare(s)
|
||||||
|
@ -1665,6 +1673,7 @@ func prepareStatements(db *sql.DB) {
|
||||||
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 = ?")
|
||||||
|
stmtClearFlags = preparetodie(db, "update honks set flags = flags & ~ ? where xid = ?")
|
||||||
}
|
}
|
||||||
|
|
||||||
func ElaborateUnitTests() {
|
func ElaborateUnitTests() {
|
||||||
|
|
|
@ -78,7 +78,11 @@ in reply to: <a href="{{ .RID }}" rel=noreferrer>{{ .RID }}</a>
|
||||||
<button onclick="showhonkform(this, '{{ .Honk.XID }}', '{{ .Honk.Handle }}');">honk back</button>
|
<button onclick="showhonkform(this, '{{ .Honk.XID }}', '{{ .Honk.Handle }}');">honk back</button>
|
||||||
<button onclick="muteit(this, '{{ .Honk.Convoy }}');">mute</button>
|
<button onclick="muteit(this, '{{ .Honk.Convoy }}');">mute</button>
|
||||||
<button onclick="zonkit(this, '{{ .Honk.XID }}');">zonk</button>
|
<button onclick="zonkit(this, '{{ .Honk.XID }}');">zonk</button>
|
||||||
|
{{ if .Honk.IsAcked }}
|
||||||
|
<button onclick="deackit(this, '{{ .Honk.XID }}');">deack</button>
|
||||||
|
{{ else }}
|
||||||
<button onclick="ackit(this, '{{ .Honk.XID }}');">ack</button>
|
<button onclick="ackit(this, '{{ .Honk.XID }}');">ack</button>
|
||||||
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -65,5 +65,10 @@ function ackit(el, xid) {
|
||||||
el.disabled = true
|
el.disabled = true
|
||||||
post("/zonkit", "CSRF={{ $BonkCSRF }}&wherefore=ack&what=" + escape(xid))
|
post("/zonkit", "CSRF={{ $BonkCSRF }}&wherefore=ack&what=" + escape(xid))
|
||||||
}
|
}
|
||||||
|
function deackit(el, xid) {
|
||||||
|
el.innerHTML = "deacked"
|
||||||
|
el.disabled = true
|
||||||
|
post("/zonkit", "CSRF={{ $BonkCSRF }}&wherefore=deack&what=" + escape(xid))
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Reference in New Issue