all repos — honk @ a9844c17a67dc44247c69bfe9b54ecb3eb7e9abc

my fork of honk

don't drop the donk! sometimes preview would find the wrong one on resubmit.
Ted Unangst tedu@tedunangst.com
Thu, 09 Mar 2023 01:57:20 -0500
commit

a9844c17a67dc44247c69bfe9b54ecb3eb7e9abc

parent

94b5284cfe206a006e3f57f69720c0aca8145624

3 files changed, 28 insertions(+), 4 deletions(-)

jump to
M database.godatabase.go

@@ -574,6 +574,20 @@ fileid, _ := res.LastInsertId()

return fileid, xid, nil } +func finddonkid(fileid int64, url string) *Donk { + donk := new(Donk) + row := stmtFindFileId.QueryRow(fileid, url) + err := row.Scan(&donk.XID, &donk.Local, &donk.Desc) + if err == nil { + donk.FileID = fileid + return donk + } + if err != sql.ErrNoRows { + elog.Printf("error finding file: %s", err) + } + return nil +} + func finddonk(url string) *Donk { donk := new(Donk) row := stmtFindFile.QueryRow(url)

@@ -1079,7 +1093,7 @@ var stmtHonksByOntology, stmtHonksForUser, stmtHonksForMe, stmtSaveDub, stmtHonksByXonker *sql.Stmt

var stmtHonksFromLongAgo *sql.Stmt var stmtHonksByHonker, stmtSaveHonk, stmtUserByName, stmtUserByNumber *sql.Stmt var stmtEventHonks, stmtOneBonk, stmtFindZonk, stmtFindXonk, stmtSaveDonk *sql.Stmt -var stmtFindFile, stmtGetFileData, stmtSaveFileData, stmtSaveFile *sql.Stmt +var stmtFindFile, stmtFindFileId, stmtGetFileData, stmtSaveFileData, stmtSaveFile *sql.Stmt var stmtCheckFileData *sql.Stmt var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover, stmtOneHonker *sql.Stmt var stmtUntagged, stmtDeleteHonk, stmtDeleteDonks, stmtDeleteOnts, stmtSaveZonker *sql.Stmt

@@ -1149,6 +1163,7 @@ stmtCheckFileData = preparetodie(blobdb, "select xid from filedata where hash = ?")

stmtGetFileData = preparetodie(blobdb, "select media, content from filedata where xid = ?") stmtFindXonk = preparetodie(db, "select honkid from honks where userid = ? and xid = ?") stmtFindFile = preparetodie(db, "select fileid, xid from filemeta where url = ? and local = 1") + stmtFindFileId = preparetodie(db, "select xid, local, description from filemeta where fileid = ? and url = ? and local = 1") stmtUserByName = preparetodie(db, "select userid, username, displayname, about, pubkey, seckey, options from users where username = ? and userid > 0") stmtUserByNumber = preparetodie(db, "select userid, username, displayname, about, pubkey, seckey, options from users where userid = ?") stmtSaveDub = preparetodie(db, "insert into honkers (userid, name, xid, flavor, combos, owner, meta, folxid) values (?, ?, ?, ?, '', '', '', ?)")
M docs/changelog.txtdocs/changelog.txt

@@ -2,6 +2,8 @@ changelog

=== next ++ Some fixes for image descriptions. + + Fix double htmlization of subject lines. + Remove the wonk support. Fun's over, back to work.
M web.goweb.go

@@ -1678,12 +1678,19 @@ return nil

} if d != nil { honk.Donks = append(honk.Donks, d) - donkxid = d.XID + donkxid = fmt.Sprintf("%s:%d", d.XID, d.FileID) } } else { - xid := donkxid + p := strings.Split(donkxid, ":") + xid := p[0] url := fmt.Sprintf("https://%s/d/%s", serverName, xid) - donk := finddonk(url) + var donk *Donk + if len(p) > 1 { + fileid, _ := strconv.ParseInt(p[1], 10, 0) + donk = finddonkid(fileid, url) + } else { + donk = finddonk(url) + } if donk != nil { honk.Donks = append(honk.Donks, donk) } else {