a little more flexibility in api
This commit is contained in:
parent
12183bb0f7
commit
d121a83b54
35
docs/honk.3
35
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.
|
||||
|
|
30
web.go
30
web.go
|
@ -1163,14 +1163,10 @@ func saveuser(w http.ResponseWriter, r *http.Request) {
|
|||
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 @@ func submitbonk(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
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 @@ func submitbonk(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
@ -1321,6 +1325,12 @@ func zonkit(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
if wherefore == "bonk" {
|
||||
user, _ := butwhatabout(userinfo.Username)
|
||||
bonkit(what, user)
|
||||
return
|
||||
}
|
||||
|
||||
if wherefore == "unbonk" {
|
||||
xonk := getbonk(userinfo.UserID, what)
|
||||
if xonk != nil {
|
||||
|
@ -2237,6 +2247,8 @@ func apihandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
w.Write([]byte(d.XID))
|
||||
case "zonkit":
|
||||
zonkit(w, r)
|
||||
case "gethonks":
|
||||
var honks []*Honk
|
||||
wanted, _ := strconv.ParseInt(r.FormValue("after"), 10, 0)
|
||||
|
|
Loading…
Reference in New Issue