rework how sub/unsub works, and add delete to honkers
This commit is contained in:
parent
7eaa6e3519
commit
a176bbb2f0
|
@ -901,6 +901,7 @@ func cleanupdb(arg string) {
|
|||
}
|
||||
|
||||
var stmtHonkers, stmtDubbers, stmtNamedDubbers, stmtSaveHonker, stmtUpdateFlavor, stmtUpdateHonker *sql.Stmt
|
||||
var stmtDeleteHonker *sql.Stmt
|
||||
var stmtAnyXonk, stmtOneXonk, stmtPublicHonks, stmtUserHonks, stmtHonksByCombo, stmtHonksByConvoy *sql.Stmt
|
||||
var stmtHonksByOntology, stmtHonksForUser, stmtHonksForMe, stmtSaveDub, stmtHonksByXonker *sql.Stmt
|
||||
var stmtHonksFromLongAgo *sql.Stmt
|
||||
|
@ -931,6 +932,7 @@ func prepareStatements(db *sql.DB) {
|
|||
stmtSaveHonker = preparetodie(db, "insert into honkers (userid, name, xid, flavor, combos, owner, meta, folxid) values (?, ?, ?, ?, ?, ?, ?, '')")
|
||||
stmtUpdateFlavor = preparetodie(db, "update honkers set flavor = ?, folxid = ? where userid = ? and name = ? and xid = ? and flavor = ?")
|
||||
stmtUpdateHonker = preparetodie(db, "update honkers set name = ?, combos = ?, meta = ? where honkerid = ? and userid = ?")
|
||||
stmtDeleteHonker = preparetodie(db, "delete from honkers where honkerid = ?")
|
||||
stmtOneHonker = preparetodie(db, "select xid from honkers where name = ? and userid = ?")
|
||||
stmtDubbers = preparetodie(db, "select honkerid, userid, name, xid, flavor from honkers where userid = ? and flavor = 'dub'")
|
||||
stmtNamedDubbers = preparetodie(db, "select honkerid, userid, name, xid, flavor from honkers where userid = ? and name = ? and flavor = 'dub'")
|
||||
|
|
|
@ -48,12 +48,11 @@ function expandstuff() {
|
|||
<p><label for="notes">notes:</label><br>
|
||||
<textarea name="notes">{{ .Meta.Notes }}</textarea>
|
||||
<p>combos: <input type="text" name="combos" value="{{ range .Combos }}{{ . }} {{end}}">
|
||||
{{ if eq .Flavor "sub" }}
|
||||
<p>unsub: <input type="text" name="goodbye" placeholder="press F" value="" autocomplete=off>
|
||||
{{ else }}
|
||||
<p>(re)sub: <input type="text" name="goodbye" placeholder="press X" value="" autocomplete=off>
|
||||
{{ end }}
|
||||
<p><button name="save" value="save">save</button>
|
||||
<p>
|
||||
<button name="save" value="save">save</button>
|
||||
<button name="sub" value="sub">(re)sub</button>
|
||||
<button name="unsub" value="unsub">unsub</button>
|
||||
<button name="delete" value="delete">delete</button>
|
||||
</form>
|
||||
</details>
|
||||
<p>
|
||||
|
|
11
web.go
11
web.go
|
@ -1852,16 +1852,17 @@ func submithonker(w http.ResponseWriter, r *http.Request) {
|
|||
defer honkerinvalidator.Clear(u.UserID)
|
||||
|
||||
if honkerid > 0 {
|
||||
goodbye := r.FormValue("goodbye")
|
||||
if goodbye == "F" {
|
||||
if r.FormValue("delete") == "delete" {
|
||||
unfollowyou(user, honkerid)
|
||||
stmtDeleteHonker.Exec(honkerid)
|
||||
http.Redirect(w, r, "/honkers", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
if goodbye == "X" {
|
||||
if r.FormValue("unsub") == "unsub" {
|
||||
unfollowyou(user, honkerid)
|
||||
}
|
||||
if r.FormValue("sub") == "sub" {
|
||||
followyou(user, honkerid)
|
||||
http.Redirect(w, r, "/honkers", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
_, err := stmtUpdateHonker.Exec(name, combos, mj, honkerid, u.UserID)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue