From 12183bb0f74d90c0d242d9d4ba5e2aae565c0947 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sun, 26 Apr 2020 14:36:11 -0400 Subject: [PATCH] more control over reaction in web backend --- activity.go | 2 +- web.go | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/activity.go b/activity.go index 54a009c..02053a8 100644 --- a/activity.go +++ b/activity.go @@ -1145,7 +1145,7 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) { if h.Convoy != "" { j["context"] = h.Convoy } - j["content"] = user.Options.Reaction + j["content"] = h.Noise case "deack": b := junk.New() b["id"] = user.URL + "/" + "ack" + "/" + shortxid(h.XID) diff --git a/web.go b/web.go index 806278b..7becb38 100644 --- a/web.go +++ b/web.go @@ -1233,12 +1233,13 @@ func submitbonk(w http.ResponseWriter, r *http.Request) { } } -func sendzonkofsorts(xonk *Honk, user *WhatAbout, what string) { +func sendzonkofsorts(xonk *Honk, user *WhatAbout, what string, aux string) { zonk := &Honk{ What: what, XID: xonk.XID, Date: time.Now().UTC(), Audience: oneofakind(xonk.Audience), + Noise: aux, } zonk.Public = loudandproud(zonk.Audience) @@ -1275,7 +1276,11 @@ func zonkit(w http.ResponseWriter, r *http.Request) { } if wherefore == "react" { - if user.Options.Reaction == "none" { + reaction := user.Options.Reaction + if r2 := r.FormValue("reaction"); r2 != "" { + reaction = r2 + } + if reaction == "none" { return } xonk := getxonk(userinfo.UserID, what) @@ -1284,7 +1289,7 @@ func zonkit(w http.ResponseWriter, r *http.Request) { if err != nil { log.Printf("error saving: %s", err) } - sendzonkofsorts(xonk, user, "react") + sendzonkofsorts(xonk, user, "react", reaction) } return } @@ -1299,7 +1304,7 @@ func zonkit(w http.ResponseWriter, r *http.Request) { if err != nil { log.Printf("error acking: %s", err) } - sendzonkofsorts(xonk, user, "ack") + sendzonkofsorts(xonk, user, "ack", "") } return } @@ -1311,7 +1316,7 @@ func zonkit(w http.ResponseWriter, r *http.Request) { if err != nil { log.Printf("error deacking: %s", err) } - sendzonkofsorts(xonk, user, "deack") + sendzonkofsorts(xonk, user, "deack", "") } return } @@ -1325,7 +1330,7 @@ func zonkit(w http.ResponseWriter, r *http.Request) { if err != nil { log.Printf("error unbonking: %s", err) } - sendzonkofsorts(xonk, user, "unbonk") + sendzonkofsorts(xonk, user, "unbonk", "") } return } @@ -1351,7 +1356,7 @@ func zonkit(w http.ResponseWriter, r *http.Request) { if xonk != nil { deletehonk(xonk.ID) if xonk.Whofore == 2 || xonk.Whofore == 3 { - sendzonkofsorts(xonk, user, "zonk") + sendzonkofsorts(xonk, user, "zonk", "") } } }