see what happens if we start saving badonks
This commit is contained in:
parent
471620429b
commit
988f2176fa
17
database.go
17
database.go
|
@ -798,6 +798,20 @@ func saveextras(tx *sql.Tx, h *Honk) error {
|
|||
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 {
|
||||
_, err := tx.Stmt(stmtDeleteDonks).Exec(honkid)
|
||||
if err != nil {
|
||||
|
@ -914,7 +928,7 @@ var stmtUntagged, stmtDeleteHonk, stmtDeleteDonks, stmtDeleteOnts, stmtSaveZonke
|
|||
var stmtGetZonkers, stmtRecentHonkers, stmtGetXonker, stmtSaveXonker, stmtDeleteXonker *sql.Stmt
|
||||
var stmtAllOnts, stmtSaveOnt, stmtUpdateFlags, stmtClearFlags *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 stmtGetTracks *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 (?, ?, ?)")
|
||||
stmtDeleteAllMeta = preparetodie(db, "delete from honkmeta where honkid = ?")
|
||||
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
||||
stmtDeleteHonk = preparetodie(db, "delete from honks where honkid = ?")
|
||||
stmtUpdateHonk = preparetodie(db, "update honks set precis = ?, noise = ?, format = ?, whofore = ?, dt = ? where honkid = ?")
|
||||
|
|
6
honk.go
6
honk.go
|
@ -96,6 +96,12 @@ type Honk struct {
|
|||
Place *Place
|
||||
Time *Time
|
||||
Mentions []Mention
|
||||
Badonks []Badonk
|
||||
}
|
||||
|
||||
type Badonk struct {
|
||||
Who string
|
||||
What string
|
||||
}
|
||||
|
||||
type Chonk struct {
|
||||
|
|
6
web.go
6
web.go
|
@ -429,6 +429,12 @@ func inbox(w http.ResponseWriter, r *http.Request) {
|
|||
default:
|
||||
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:
|
||||
go xonksaver(user, j, origin)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue