allow hashtags as honkers with combos

This commit is contained in:
Ted Unangst 2019-10-26 18:55:39 -04:00
parent 58292a808c
commit 8c1d7ea5a2
2 changed files with 19 additions and 2 deletions

View File

@ -231,7 +231,7 @@ func gethonksbyxonker(userid int64, xonker string, wanted int64) []*Honk {
} }
func gethonksbycombo(userid int64, combo string, wanted int64) []*Honk { func gethonksbycombo(userid int64, combo string, wanted int64) []*Honk {
combo = "% " + combo + " %" combo = "% " + combo + " %"
rows, err := stmtHonksByCombo.Query(wanted, userid, combo, userid) rows, err := stmtHonksByCombo.Query(wanted, userid, combo, userid, wanted, userid, combo, userid)
return getsomehonks(rows, err) return getsomehonks(rows, err)
} }
func gethonksbyconvoy(userid int64, convoy string, wanted int64) []*Honk { func gethonksbyconvoy(userid int64, convoy string, wanted int64) []*Honk {
@ -719,7 +719,9 @@ func prepareStatements(db *sql.DB) {
stmtHonksISaved = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and flags & 4 order by honks.honkid desc") stmtHonksISaved = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and flags & 4 order by honks.honkid desc")
stmtHonksByHonker = preparetodie(db, selecthonks+"join honkers on (honkers.xid = honks.honker or honkers.xid = honks.oonker) where honks.honkid > ? and honks.userid = ? and honkers.name = ?"+butnotthose+limit) stmtHonksByHonker = preparetodie(db, selecthonks+"join honkers on (honkers.xid = honks.honker or honkers.xid = honks.oonker) where honks.honkid > ? and honks.userid = ? and honkers.name = ?"+butnotthose+limit)
stmtHonksByXonker = preparetodie(db, selecthonks+" where honks.honkid > ? and honks.userid = ? and (honker = ? or oonker = ?)"+butnotthose+limit) stmtHonksByXonker = preparetodie(db, selecthonks+" where honks.honkid > ? and honks.userid = ? and (honker = ? or oonker = ?)"+butnotthose+limit)
stmtHonksByCombo = preparetodie(db, selecthonks+"join honkers on honkers.xid = honks.honker where honks.honkid > ? and honks.userid = ? and honkers.combos like ?"+butnotthose+limit) stmtHonksByCombo = preparetodie(db, selecthonks+"join honkers on honkers.xid = honks.honker where honks.honkid > ? and honks.userid = ? and honkers.combos like ?"+butnotthose+ " union "+selecthonks+"join onts on honks.honkid = onts.honkid where honks.honkid > ? and honks.userid = ? and onts.ontology in (select xid from honkers where combos like ?)"+butnotthose+limit)
stmtHonksBySearch = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and (? = 0 or xid like ?) and (? = 0 or honks.honker = ? or honks.oonker = ?) and noise like ?"+butnotthose+limit) stmtHonksBySearch = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and (? = 0 or xid like ?) and (? = 0 or honks.honker = ? or honks.oonker = ?) and noise like ?"+butnotthose+limit)
stmtHonksByConvoy = preparetodie(db, selecthonks+"where honks.honkid > ? and (honks.userid = ? or (? = -1 and whofore = 2)) and convoy = ?"+limit) stmtHonksByConvoy = preparetodie(db, selecthonks+"where honks.honkid > ? and (honks.userid = ? or (? = -1 and whofore = 2)) and convoy = ?"+limit)
stmtHonksByOntology = preparetodie(db, selecthonks+"join onts on honks.honkid = onts.honkid where honks.honkid > ? and onts.ontology = ? and (honks.userid = ? or (? = -1 and honks.whofore = 2))"+limit) stmtHonksByOntology = preparetodie(db, selecthonks+"join onts on honks.honkid = onts.honkid where honks.honkid > ? and onts.ontology = ? and (honks.userid = ? or (? = -1 and honks.whofore = 2))"+limit)

15
web.go
View File

@ -1527,6 +1527,21 @@ func submithonker(w http.ResponseWriter, r *http.Request) {
if peep == "peep" { if peep == "peep" {
flavor = "peep" flavor = "peep"
} }
// incomplete
if url[0] == '#' {
flavor = "peep"
if name == "" {
name = url
}
_, err := stmtSaveHonker.Exec(u.UserID, name, url, flavor, combos)
if err != nil {
log.Print(err)
return
}
http.Redirect(w, r, "/honkers", http.StatusSeeOther)
}
info, err := investigate(url) info, err := investigate(url)
if err != nil { if err != nil {
http.Error(w, "error investigating: "+err.Error(), http.StatusInternalServerError) http.Error(w, "error investigating: "+err.Error(), http.StatusInternalServerError)