unbonking should work now

This commit is contained in:
Ted Unangst 2019-08-27 22:15:53 -04:00
parent d12b5f7421
commit 03e948fe3c
4 changed files with 18 additions and 5 deletions

View File

@ -234,7 +234,7 @@ func savexonk(user *WhatAbout, x *Honk) {
if err != nil { if err != nil {
log.Printf("error eradicating: %s", err) log.Printf("error eradicating: %s", err)
} }
_, err = stmtZonkIt.Exec(user.ID, x.XID) _, err = stmtZonkIt.Exec(xonk.ID)
if err != nil { if err != nil {
log.Printf("error eradicating: %s", err) log.Printf("error eradicating: %s", err)
} }

View File

@ -2,6 +2,8 @@ changelog
-- next -- next
+ Unbonking.
++ Hashtags that work? ++ Hashtags that work?
+ Dynamic refresh. + Dynamic refresh.

2
fun.go
View File

@ -49,6 +49,8 @@ func reverbolate(userid int64, honks []*Honk) {
if h.What != "bonked" { if h.What != "bonked" {
h.Noise = mentionize(h.Noise) h.Noise = mentionize(h.Noise)
h.Noise = ontologize(h.Noise) h.Noise = ontologize(h.Noise)
} else {
h.Flags |= flagIsBonked
} }
h.Username, h.Handle = handles(h.Honker) h.Username, h.Handle = handles(h.Honker)
} else { } else {

17
honk.go
View File

@ -850,7 +850,7 @@ func getxonk(userid int64, xid string) *Honk {
func getbonk(userid int64, xid string) *Honk { func getbonk(userid int64, xid string) *Honk {
h := new(Honk) h := new(Honk)
var dt, aud string var dt, aud string
row := stmtOneXonk.QueryRow(userid, xid) row := stmtOneBonk.QueryRow(userid, xid)
err := row.Scan(&h.ID, &h.UserID, &h.Username, &h.What, &h.Honker, &h.Oonker, &h.XID, &h.RID, err := row.Scan(&h.ID, &h.UserID, &h.Username, &h.What, &h.Honker, &h.Oonker, &h.XID, &h.RID,
&dt, &h.URL, &aud, &h.Noise, &h.Precis, &h.Convoy, &h.Whofore, &h.Flags) &dt, &h.URL, &aud, &h.Noise, &h.Precis, &h.Convoy, &h.Whofore, &h.Flags)
if err != nil { if err != nil {
@ -1083,7 +1083,16 @@ func zonkit(w http.ResponseWriter, r *http.Request) {
if wherefore == "unbonk" { if wherefore == "unbonk" {
xonk := getbonk(userinfo.UserID, what) xonk := getbonk(userinfo.UserID, what)
if xonk != nil { if xonk != nil {
_, err := stmtClearFlags.Exec(flagIsBonked, xonk.ID) _, err := stmtZonkDonks.Exec(xonk.ID)
if err != nil {
log.Printf("error zonking: %s", err)
}
_, err = stmtZonkIt.Exec(xonk.ID)
if err != nil {
log.Printf("error zonking: %s", err)
}
xonk = getxonk(userinfo.UserID, what)
_, err = stmtClearFlags.Exec(flagIsBonked, xonk.ID)
if err != nil { if err != nil {
log.Printf("error unbonking: %s", err) log.Printf("error unbonking: %s", err)
} }
@ -1100,7 +1109,7 @@ func zonkit(w http.ResponseWriter, r *http.Request) {
if err != nil { if err != nil {
log.Printf("error zonking: %s", err) log.Printf("error zonking: %s", err)
} }
_, err = stmtZonkIt.Exec(userinfo.UserID, what) _, err = stmtZonkIt.Exec(xonk.ID)
if err != nil { if err != nil {
log.Printf("error zonking: %s", err) log.Printf("error zonking: %s", err)
} }
@ -1799,7 +1808,7 @@ func prepareStatements(db *sql.DB) {
stmtFileData = preparetodie(db, "select media, content from files where xid = ?") stmtFileData = preparetodie(db, "select media, content from files where xid = ?")
stmtFindXonk = preparetodie(db, "select honkid from honks where userid = ? and xid = ?") stmtFindXonk = preparetodie(db, "select honkid from honks where userid = ? and xid = ?")
stmtSaveDonk = preparetodie(db, "insert into donks (honkid, fileid) values (?, ?)") stmtSaveDonk = preparetodie(db, "insert into donks (honkid, fileid) values (?, ?)")
stmtZonkIt = preparetodie(db, "delete from honks where userid = ? and xid = ?") stmtZonkIt = preparetodie(db, "delete from honks where honkid = ?")
stmtZonkDonks = preparetodie(db, "delete from donks where honkid = ?") stmtZonkDonks = preparetodie(db, "delete from donks where honkid = ?")
stmtFindFile = preparetodie(db, "select fileid from files where url = ? and local = 1") stmtFindFile = preparetodie(db, "select fileid from files where url = ? and local = 1")
stmtSaveFile = preparetodie(db, "insert into files (xid, name, url, media, local, content) values (?, ?, ?, ?, ?, ?)") stmtSaveFile = preparetodie(db, "insert into files (xid, name, url, media, local, content) values (?, ?, ?, ?, ?, ?)")