a little more flexibility in api
Ted Unangst tedu@tedunangst.com
Sun, 26 Apr 2020 15:03:23 -0400
2 files changed,
56 insertions(+),
9 deletions(-)
M
docs/honk.3
→
docs/honk.3
@@ -123,6 +123,41 @@ If there are no results, wait this many seconds for something to appear.
.El .Pp The result will be returned as json. +.Ss zonkit +The +.Dq zonkit +action began life as a delete function, but has since evolved some other +powers as specified by the +.Fa wherefore +parameter. +The target of the action is specified by the +.Fa what +parameter and is generally the XID of a honk. +.Pp +Wherefore must be one of the following. +.Bl -tag -width zonvoy +.It bonk +Share honk with others. +.It unbonk +Undo share. +.It save +Mark honk as saved. +.It unsave +Unmark honk as saved. +.It react +Post an emoji reaction. +A custom reaction may be specified with +.Fa reaction . +.It ack +Mark honk as read. +.It deack +Unmark honk as read. +.It zonk +Delete this honk. +.It zonvoy +Mute this thread. +What should identify a convoy. +.El .Ss sendactivity Send anything. No limits, no error checking.
M
web.go
→
web.go
@@ -1163,14 +1163,10 @@
http.Redirect(w, r, "/account", http.StatusSeeOther) } -func submitbonk(w http.ResponseWriter, r *http.Request) { - xid := r.FormValue("xid") - userinfo := login.GetUserInfo(r) - user, _ := butwhatabout(userinfo.Username) - +func bonkit(xid string, user *WhatAbout) { log.Printf("bonking %s", xid) - xonk := getxonk(userinfo.UserID, xid) + xonk := getxonk(user.ID, xid) if xonk == nil { return }@@ -1193,8 +1189,8 @@ oonker = xonk.Honker
} dt := time.Now().UTC() bonk := &Honk{ - UserID: userinfo.UserID, - Username: userinfo.Username, + UserID: user.ID, + Username: user.Name, What: "bonk", Honker: user.URL, Oonker: oonker,@@ -1222,11 +1218,19 @@ return
} go honkworldwide(user, bonk) +} + +func submitbonk(w http.ResponseWriter, r *http.Request) { + xid := r.FormValue("xid") + userinfo := login.GetUserInfo(r) + user, _ := butwhatabout(userinfo.Username) + + bonkit(xid, user) if r.FormValue("js") != "1" { templinfo := getInfo(r) templinfo["ServerMessage"] = "Bonked!" - err = readviews.Execute(w, "msg.html", templinfo) + err := readviews.Execute(w, "msg.html", templinfo) if err != nil { log.Print(err) }@@ -1318,6 +1322,12 @@ log.Printf("error deacking: %s", err)
} sendzonkofsorts(xonk, user, "deack", "") } + return + } + + if wherefore == "bonk" { + user, _ := butwhatabout(userinfo.Username) + bonkit(what, user) return }@@ -2237,6 +2247,8 @@ }
return } w.Write([]byte(d.XID)) + case "zonkit": + zonkit(w, r) case "gethonks": var honks []*Honk wanted, _ := strconv.ParseInt(r.FormValue("after"), 10, 0)