diff --git a/database.go b/database.go index 99bd8ad..cbbedc8 100644 --- a/database.go +++ b/database.go @@ -574,6 +574,20 @@ func savefileandxid(name string, desc string, url string, media string, local bo 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, stmtHonk 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 @@ func prepareStatements(db *sql.DB) { 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 (?, ?, ?, ?, '', '', '', ?)") diff --git a/docs/changelog.txt b/docs/changelog.txt index 5f76b58..328b75c 100644 --- a/docs/changelog.txt +++ b/docs/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. diff --git a/web.go b/web.go index 65e113c..e883f73 100644 --- a/web.go +++ b/web.go @@ -1678,12 +1678,19 @@ func submithonk(w http.ResponseWriter, r *http.Request) *Honk { } 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 {