allow resubscribing
This commit is contained in:
parent
029287af30
commit
d5b99e2b9a
|
@ -922,6 +922,10 @@ func itakeitallback(user *WhatAbout, xid string) {
|
|||
}
|
||||
|
||||
func subsub(user *WhatAbout, xid string) {
|
||||
if xid == "" {
|
||||
log.Printf("can't subscribe to empty")
|
||||
return
|
||||
}
|
||||
j := junk.New()
|
||||
j["@context"] = itiswhatitis
|
||||
j["id"] = user.URL + "/sub/" + url.QueryEscape(xid)
|
||||
|
|
|
@ -39,7 +39,11 @@ function expandstuff() {
|
|||
<input type="hidden" name="CSRF" value="{{ $honkercsrf }}">
|
||||
<input type="hidden" name="honkerid" value="{{ .ID }}">
|
||||
<p>combos: <input type="text" name="combos" value="{{ range .Combos }}{{ . }} {{end}}">
|
||||
<p>depart: <input type="text" name="goodbye" placeholder="press F" value="" autocomplete=off>
|
||||
{{ if eq .Flavor "sub" }}
|
||||
<p>unsub: <input type="text" name="goodbye" placeholder="press F" value="" autocomplete=off>
|
||||
{{ else }}
|
||||
<p>resub: <input type="text" name="goodbye" placeholder="press X" value="" autocomplete=off>
|
||||
{{ end }}
|
||||
<p><button name="save" value="save">save</button>
|
||||
</form>
|
||||
</details>
|
||||
|
|
33
web.go
33
web.go
|
@ -1183,20 +1183,43 @@ func submithonker(w http.ResponseWriter, r *http.Request) {
|
|||
db := opendatabase()
|
||||
row := db.QueryRow("select xid from honkers where honkerid = ? and userid = ?",
|
||||
honkerid, u.UserID)
|
||||
var xid string
|
||||
err := row.Scan(&xid)
|
||||
err := row.Scan(&url)
|
||||
if err != nil {
|
||||
log.Printf("can't get honker xid: %s", err)
|
||||
return
|
||||
}
|
||||
log.Printf("unsubscribing from %s", xid)
|
||||
log.Printf("unsubscribing from %s", url)
|
||||
user, _ := butwhatabout(u.Username)
|
||||
go itakeitallback(user, xid)
|
||||
_, err = stmtUpdateFlavor.Exec("unsub", u.UserID, xid, "sub")
|
||||
_, err = stmtUpdateFlavor.Exec("unsub", u.UserID, url, "sub")
|
||||
if err != nil {
|
||||
log.Printf("error updating honker: %s", err)
|
||||
return
|
||||
}
|
||||
go itakeitallback(user, url)
|
||||
|
||||
http.Redirect(w, r, "/honkers", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
if goodbye == "X" {
|
||||
db := opendatabase()
|
||||
row := db.QueryRow("select xid from honkers where honkerid = ? and userid = ?",
|
||||
honkerid, u.UserID)
|
||||
err := row.Scan(&url)
|
||||
if err != nil {
|
||||
log.Printf("can't get honker xid: %s", err)
|
||||
return
|
||||
}
|
||||
log.Printf("resubscribing to %s", url)
|
||||
user, _ := butwhatabout(u.Username)
|
||||
_, err = stmtUpdateFlavor.Exec("presub", u.UserID, url, "unsub")
|
||||
if err == nil {
|
||||
_, err = stmtUpdateFlavor.Exec("presub", u.UserID, url, "peep")
|
||||
}
|
||||
if err != nil {
|
||||
log.Printf("error updating honker: %s", err)
|
||||
return
|
||||
}
|
||||
go subsub(user, url)
|
||||
|
||||
http.Redirect(w, r, "/honkers", http.StatusSeeOther)
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue