all repos — honk @ 40cbaec63a2409a3d187c3746a859ab0e8e21e98

my fork of honk

take me off this list!!!
Ted Unangst tedu@tedunangst.com
Fri, 26 Apr 2019 15:31:42 -0400
commit

40cbaec63a2409a3d187c3746a859ab0e8e21e98

parent

c2429397f835803ebcf6797ff21728c341b2c50a

3 files changed, 52 insertions(+), 1 deletions(-)

jump to
M activity.goactivity.go

@@ -597,6 +597,33 @@ }

stmtSaveDub.Exec(user.ID, actor, actor, "dub") } +func itakeitallback(user *WhatAbout, xid string) error { + j := NewJunk() + j["@context"] = itiswhatitis + j["id"] = user.URL + "/unsub/" + xid + j["type"] = "Undo" + j["actor"] = user.URL + j["to"] = xid + f := NewJunk() + f["id"] = user.URL + "/sub/" + xid + f["type"] = "Follow" + f["actor"] = user.URL + f["to"] = xid + j["object"] = f + j["published"] = time.Now().UTC().Format(time.RFC3339) + + box, err := getboxes(xid) + if err != nil { + return err + } + keyname, key := ziggy(user.Name) + err = PostJunk(keyname, key, box.In, j) + if err != nil { + return err + } + return nil +} + func subsub(user *WhatAbout, xid string) { j := NewJunk() j["@context"] = itiswhatitis
M honk.gohonk.go

@@ -1017,6 +1017,29 @@ combos := r.FormValue("combos")

honkerid, _ := strconv.ParseInt(r.FormValue("honkerid"), 10, 0) if honkerid > 0 { + goodbye := r.FormValue("goodbye") + if goodbye == "goodbye" { + db := opendatabase() + row := db.QueryRow("select xid from honkers where honkerid = ? and userid = ?", + honkerid, u.UserID) + var xid string + err := row.Scan(&xid) + if err != nil { + log.Printf("can't get honker xid: %s", err) + return + } + log.Printf("unsubscribing from %s", xid) + user, _ := butwhatabout(u.Username) + err = itakeitallback(user, xid) + if err != nil { + log.Printf("can't take it back: %s", err) + } else { + db.Exec("update honkers set flavor = 'unsub' where honkerid = ?", honkerid) + } + + http.Redirect(w, r, "/honkers", http.StatusSeeOther) + return + } combos = " " + strings.TrimSpace(combos) + " " _, err := stmtUpdateHonker.Exec(combos, honkerid, u.UserID) if err != nil {

@@ -1254,7 +1277,7 @@ return stmt

} func prepareStatements(db *sql.DB) { - stmtHonkers = preparetodie(db, "select honkerid, userid, name, xid, flavor, combos from honkers where userid = ? and flavor = 'sub' or flavor = 'peep'") + stmtHonkers = preparetodie(db, "select honkerid, userid, name, xid, flavor, combos from honkers where userid = ? and (flavor = 'sub' or flavor = 'peep' or flavor = 'unsub') order by name") stmtSaveHonker = preparetodie(db, "insert into honkers (userid, name, xid, flavor, combos) values (?, ?, ?, ?, ?)") stmtUpdateHonker = preparetodie(db, "update honkers set combos = ? where honkerid = ? and userid = ?") stmtHasHonker = preparetodie(db, "select honkerid from honkers where xid = ? and userid = ?")
M views/honkers.htmlviews/honkers.html

@@ -27,6 +27,7 @@ <form action="/savehonker" method="POST">

<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" value="" autocomplete=off> (say "goodbye") <p><input type="submit" name="save" value="save"> </form> </div>