see what happens if we start saving badonks

This commit is contained in:
Ted Unangst 2021-02-09 08:18:22 -05:00
parent 471620429b
commit 988f2176fa
3 changed files with 28 additions and 1 deletions

View File

@ -798,6 +798,20 @@ func saveextras(tx *sql.Tx, h *Honk) error {
return nil return nil
} }
func addreaction(user *WhatAbout, xid string, who, react string) {
h := getxonk(user.ID, xid)
if h == nil {
return
}
h.Badonks = append(h.Badonks, Badonk{Who: who, What: react})
j, _ := jsonify(h.Badonks)
db := opendatabase()
tx, _ := db.Begin()
_, _ = tx.Stmt(stmtDeleteOneMeta).Exec(h.ID, "badonks")
_, _ = tx.Stmt(stmtSaveMeta).Exec(h.ID, "badonks", j)
tx.Commit()
}
func deleteextras(tx *sql.Tx, honkid int64, everything bool) error { func deleteextras(tx *sql.Tx, honkid int64, everything bool) error {
_, err := tx.Stmt(stmtDeleteDonks).Exec(honkid) _, err := tx.Stmt(stmtDeleteDonks).Exec(honkid)
if err != nil { if err != nil {
@ -914,7 +928,7 @@ var stmtUntagged, stmtDeleteHonk, stmtDeleteDonks, stmtDeleteOnts, stmtSaveZonke
var stmtGetZonkers, stmtRecentHonkers, stmtGetXonker, stmtSaveXonker, stmtDeleteXonker *sql.Stmt var stmtGetZonkers, stmtRecentHonkers, stmtGetXonker, stmtSaveXonker, stmtDeleteXonker *sql.Stmt
var stmtAllOnts, stmtSaveOnt, stmtUpdateFlags, stmtClearFlags *sql.Stmt var stmtAllOnts, stmtSaveOnt, stmtUpdateFlags, stmtClearFlags *sql.Stmt
var stmtHonksForUserFirstClass *sql.Stmt var stmtHonksForUserFirstClass *sql.Stmt
var stmtSaveMeta, stmtDeleteAllMeta, stmtDeleteSomeMeta, stmtUpdateHonk *sql.Stmt var stmtSaveMeta, stmtDeleteAllMeta, stmtDeleteOneMeta, stmtDeleteSomeMeta, stmtUpdateHonk *sql.Stmt
var stmtHonksISaved, stmtGetFilters, stmtSaveFilter, stmtDeleteFilter *sql.Stmt var stmtHonksISaved, stmtGetFilters, stmtSaveFilter, stmtDeleteFilter *sql.Stmt
var stmtGetTracks *sql.Stmt var stmtGetTracks *sql.Stmt
var stmtSaveChonk, stmtLoadChonks, stmtGetChatters *sql.Stmt var stmtSaveChonk, stmtLoadChonks, stmtGetChatters *sql.Stmt
@ -962,6 +976,7 @@ func prepareStatements(db *sql.DB) {
stmtSaveMeta = preparetodie(db, "insert into honkmeta (honkid, genus, json) values (?, ?, ?)") stmtSaveMeta = preparetodie(db, "insert into honkmeta (honkid, genus, json) values (?, ?, ?)")
stmtDeleteAllMeta = preparetodie(db, "delete from honkmeta where honkid = ?") stmtDeleteAllMeta = preparetodie(db, "delete from honkmeta where honkid = ?")
stmtDeleteSomeMeta = preparetodie(db, "delete from honkmeta where honkid = ? and genus not in ('oldrev')") stmtDeleteSomeMeta = preparetodie(db, "delete from honkmeta where honkid = ? and genus not in ('oldrev')")
stmtDeleteOneMeta = preparetodie(db, "delete from honkmeta where honkid = ? and genus = ?")
stmtSaveHonk = preparetodie(db, "insert into honks (userid, what, honker, xid, rid, dt, url, audience, noise, convoy, whofore, format, precis, oonker, flags) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") stmtSaveHonk = preparetodie(db, "insert into honks (userid, what, honker, xid, rid, dt, url, audience, noise, convoy, whofore, format, precis, oonker, flags) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
stmtDeleteHonk = preparetodie(db, "delete from honks where honkid = ?") stmtDeleteHonk = preparetodie(db, "delete from honks where honkid = ?")
stmtUpdateHonk = preparetodie(db, "update honks set precis = ?, noise = ?, format = ?, whofore = ?, dt = ? where honkid = ?") stmtUpdateHonk = preparetodie(db, "update honks set precis = ?, noise = ?, format = ?, whofore = ?, dt = ? where honkid = ?")

View File

@ -96,6 +96,12 @@ type Honk struct {
Place *Place Place *Place
Time *Time Time *Time
Mentions []Mention Mentions []Mention
Badonks []Badonk
}
type Badonk struct {
Who string
What string
} }
type Chonk struct { type Chonk struct {

6
web.go
View File

@ -429,6 +429,12 @@ func inbox(w http.ResponseWriter, r *http.Request) {
default: default:
log.Printf("unknown undo: %s", what) log.Printf("unknown undo: %s", what)
} }
case "EmojiReact":
obj, ok := j.GetString("object")
if ok {
content, _ := j.GetString("content")
addreaction(user, obj, who, content)
}
default: default:
go xonksaver(user, j, origin) go xonksaver(user, j, origin)
} }