From 7219332e0a3ee527f450e69e586b4fd6271bc2bd Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Fri, 19 Apr 2019 11:50:35 -0400 Subject: [PATCH] a convoy is a whole fleet of honks, coming at ya --- activity.go | 16 +++++++++++----- honk.go | 15 ++++++++++----- views/honk.html | 4 ++++ 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/activity.go b/activity.go index 729e303..93e2dae 100644 --- a/activity.go +++ b/activity.go @@ -312,7 +312,7 @@ func getboxes(ident string) (*Box, error) { } func peeppeep() { - user, _ := butwhatabout("") + user, _ := butwhatabout("htest") honkers := gethonkers(user.ID) for _, f := range honkers { if f.Flavor != "peep" { @@ -354,13 +354,14 @@ func peeppeep() { } } -func whosthere(xid string) []string { +func whosthere(xid string) ([]string, string) { obj, err := GetJunk(xid) if err != nil { log.Printf("error getting remote xonk: %s", err) - return nil + return nil, "" } - return newphone(nil, obj) + convoy, _ := jsongetstring(obj, "conversation") + return newphone(nil, obj), convoy } func newphone(a []string, obj map[string]interface{}) []string { @@ -387,7 +388,7 @@ func xonkxonk(item interface{}) *Honk { var audience []string var err error - var xid, rid, url, content string + var xid, rid, url, content, convoy string var obj map[string]interface{} switch what { case "Announce": @@ -424,6 +425,7 @@ func xonkxonk(item interface{}) *Honk { content = "

summary: " + summary + content } rid, _ = jsongetstring(obj, "inReplyTo") + convoy, _ = jsongetstring(obj, "conversation") if what == "honk" && rid != "" { what = "tonk" } @@ -476,6 +478,7 @@ func xonkxonk(item interface{}) *Honk { xonk.URL = url xonk.Noise = content xonk.Audience = audience + xonk.Convoy = convoy return &xonk } @@ -567,6 +570,9 @@ func jonkjonk(user *WhatAbout, h *Honk) (map[string]interface{}, map[string]inte if h.RID != "" { jo["inReplyTo"] = h.RID } + if h.Convoy != "" { + jo["conversation"] = h.Convoy + } jo["to"] = h.Audience[0] if len(h.Audience) > 1 { jo["cc"] = h.Audience[1:] diff --git a/honk.go b/honk.go index e14f07a..f983ffa 100644 --- a/honk.go +++ b/honk.go @@ -663,7 +663,7 @@ func savebonk(w http.ResponseWriter, r *http.Request) { if xonk.Honker == "" { xonk.XID = fmt.Sprintf("https://%s/u/%s/h/%s", serverName, xonk.Username, xonk.XID) } - convoy := "" + convoy := xonk.Convoy userinfo := GetUserInfo(r) @@ -676,7 +676,7 @@ func savebonk(w http.ResponseWriter, r *http.Request) { XID: xonk.XID, Date: dt, Noise: xonk.Noise, - Convoy: convoy, + Convoy: convoy, Donks: xonk.Donks, Audience: oneofakind(prepend(thewholeworld, xonk.Audience)), } @@ -723,7 +723,6 @@ func savehonk(w http.ResponseWriter, r *http.Request) { if rid != "" { what = "tonk" } - convoy := "" honk := Honk{ UserID: userinfo.UserID, Username: userinfo.Username, @@ -731,25 +730,31 @@ func savehonk(w http.ResponseWriter, r *http.Request) { XID: xid, RID: rid, Date: dt, - Convoy: convoy, } if noise[0] == '@' { honk.Audience = append(grapevine(noise), thewholeworld) } else { honk.Audience = prepend(thewholeworld, grapevine(noise)) } + var convoy string if rid != "" { xonk := getxonk("", rid) if xonk != nil { honk.Audience = append(honk.Audience, xonk.Audience...) + convoy = xonk.Convoy } else { - xonkaud := whosthere(rid) + xonkaud, c := whosthere(rid) honk.Audience = append(honk.Audience, xonkaud...) + convoy = c } } + if convoy == "" { + convoy = "data:,electrichonkytonk-" + xfiltrate() + } honk.Audience = oneofakind(honk.Audience) noise = obfusbreak(noise) honk.Noise = noise + honk.Convoy = convoy file, filehdr, err := r.FormFile("donk") if err == nil { diff --git a/views/honk.html b/views/honk.html index 30807ee..4b73157 100644 --- a/views/honk.html +++ b/views/honk.html @@ -9,6 +9,10 @@ in reply to: {{ .RID }} {{ end }} +
+ +convoy: {{ .Convoy }} +

{{ .HTML }}