From 84bab001d3bcdca4c540c18d03899af12298e9ce Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Wed, 24 Apr 2019 02:37:36 -0400 Subject: [PATCH] link to get all the honks in a convoy --- honk.go | 14 +++++++++++++- views/honk.html | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/honk.go b/honk.go index 38914a8..12a1366 100644 --- a/honk.go +++ b/honk.go @@ -431,6 +431,12 @@ func viewcombo(w http.ResponseWriter, r *http.Request) { honks := gethonksbycombo(u.UserID, name) honkpage(w, r, u, nil, honks) } +func viewconvoy(w http.ResponseWriter, r *http.Request) { + c := r.FormValue("c") + u := GetUserInfo(r) + honks := gethonksbyconvoy(u.UserID, c) + honkpage(w, r, u, nil, honks) +} func fingerlicker(w http.ResponseWriter, r *http.Request) { orig := r.FormValue("resource") @@ -636,6 +642,10 @@ func gethonksbycombo(userid int64, combo string) []*Honk { rows, err := stmtHonksByCombo.Query(userid, combo) return getsomehonks(rows, err) } +func gethonksbyconvoy(userid int64, convoy string) []*Honk { + rows, err := stmtHonksByConvoy.Query(userid, convoy) + return getsomehonks(rows, err) +} func getsomehonks(rows *sql.Rows, err error) []*Honk { if err != nil { @@ -1147,6 +1157,7 @@ func serve() { loggedin.HandleFunc("/honkers", viewhonkers) loggedin.HandleFunc("/h/{name:[[:alnum:]]+}", viewhonker) loggedin.HandleFunc("/c/{name:[[:alnum:]]+}", viewcombo) + loggedin.HandleFunc("/t", viewconvoy) loggedin.Handle("/savehonker", CSRFWrap("savehonker", http.HandlerFunc(savehonker))) err = http.Serve(listener, mux) @@ -1156,7 +1167,7 @@ func serve() { } var stmtHonkers, stmtDubbers, stmtSaveHonker, stmtUpdateHonker *sql.Stmt -var stmtOneXonk, stmtHonks, stmtUserHonks, stmtHonksByCombo *sql.Stmt +var stmtOneXonk, stmtHonks, stmtUserHonks, stmtHonksByCombo, stmtHonksByConvoy *sql.Stmt var stmtHonksForUser, stmtHonksForMe, stmtDeleteHonk, stmtSaveDub *sql.Stmt var stmtHonksByHonker, stmtSaveHonk, stmtFileData, stmtWhatAbout *sql.Stmt var stmtFindXonk, stmtSaveDonk, stmtFindFile, stmtSaveFile *sql.Stmt @@ -1184,6 +1195,7 @@ func prepareStatements(db *sql.DB) { stmtHonksForMe = preparetodie(db, "select honkid, honks.userid, users.username, what, honker, xid, rid, dt, url, audience, noise, convoy from honks join users on honks.userid = users.userid where honks.userid = ? and dt > ? and whofore = 1 and convoy not in (select name from zonkers where userid = ? and wherefore = 'zonvoy' order by zonkerid desc limit 100) order by honkid desc limit 250") stmtHonksByHonker = preparetodie(db, "select honkid, honks.userid, users.username, what, honker, honks.xid, rid, dt, url, audience, noise, convoy from honks join users on honks.userid = users.userid join honkers on honkers.xid = honks.honker where honks.userid = ? and honkers.name = ? order by honkid desc limit 50") stmtHonksByCombo = preparetodie(db, "select honkid, honks.userid, users.username, what, honker, honks.xid, rid, dt, url, audience, noise, convoy from honks join users on honks.userid = users.userid join honkers on honkers.xid = honks.honker where honks.userid = ? and honkers.combos like ? order by honkid desc limit 50") + stmtHonksByConvoy = preparetodie(db, "select honkid, honks.userid, users.username, what, honker, honks.xid, rid, dt, url, audience, noise, convoy from honks join users on honks.userid = users.userid where honks.userid = ? and convoy = ? order by honkid desc limit 50") stmtSaveHonk = preparetodie(db, "insert into honks (userid, what, honker, xid, rid, dt, url, audience, noise, convoy, whofore) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") stmtFileData = preparetodie(db, "select media, content from files where xid = ?") stmtFindXonk = preparetodie(db, "select honkid from honks where userid = ? and xid = ?") diff --git a/views/honk.html b/views/honk.html index a1595a2..30383ca 100644 --- a/views/honk.html +++ b/views/honk.html @@ -11,7 +11,7 @@ in reply to: {{ .RID }} {{ end }}
-convoy: {{ .Convoy }} +convoy: {{ .Convoy }}