a convoy is a whole fleet of honks, coming at ya

This commit is contained in:
Ted Unangst 2019-04-19 11:50:35 -04:00
parent f5cbf4cadc
commit 7219332e0a
3 changed files with 25 additions and 10 deletions

View File

@ -312,7 +312,7 @@ func getboxes(ident string) (*Box, error) {
} }
func peeppeep() { func peeppeep() {
user, _ := butwhatabout("") user, _ := butwhatabout("htest")
honkers := gethonkers(user.ID) honkers := gethonkers(user.ID)
for _, f := range honkers { for _, f := range honkers {
if f.Flavor != "peep" { 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) obj, err := GetJunk(xid)
if err != nil { if err != nil {
log.Printf("error getting remote xonk: %s", err) 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 { func newphone(a []string, obj map[string]interface{}) []string {
@ -387,7 +388,7 @@ func xonkxonk(item interface{}) *Honk {
var audience []string var audience []string
var err error var err error
var xid, rid, url, content string var xid, rid, url, content, convoy string
var obj map[string]interface{} var obj map[string]interface{}
switch what { switch what {
case "Announce": case "Announce":
@ -424,6 +425,7 @@ func xonkxonk(item interface{}) *Honk {
content = "<p>summary: " + summary + content content = "<p>summary: " + summary + content
} }
rid, _ = jsongetstring(obj, "inReplyTo") rid, _ = jsongetstring(obj, "inReplyTo")
convoy, _ = jsongetstring(obj, "conversation")
if what == "honk" && rid != "" { if what == "honk" && rid != "" {
what = "tonk" what = "tonk"
} }
@ -476,6 +478,7 @@ func xonkxonk(item interface{}) *Honk {
xonk.URL = url xonk.URL = url
xonk.Noise = content xonk.Noise = content
xonk.Audience = audience xonk.Audience = audience
xonk.Convoy = convoy
return &xonk return &xonk
} }
@ -567,6 +570,9 @@ func jonkjonk(user *WhatAbout, h *Honk) (map[string]interface{}, map[string]inte
if h.RID != "" { if h.RID != "" {
jo["inReplyTo"] = h.RID jo["inReplyTo"] = h.RID
} }
if h.Convoy != "" {
jo["conversation"] = h.Convoy
}
jo["to"] = h.Audience[0] jo["to"] = h.Audience[0]
if len(h.Audience) > 1 { if len(h.Audience) > 1 {
jo["cc"] = h.Audience[1:] jo["cc"] = h.Audience[1:]

15
honk.go
View File

@ -663,7 +663,7 @@ func savebonk(w http.ResponseWriter, r *http.Request) {
if xonk.Honker == "" { if xonk.Honker == "" {
xonk.XID = fmt.Sprintf("https://%s/u/%s/h/%s", serverName, xonk.Username, xonk.XID) xonk.XID = fmt.Sprintf("https://%s/u/%s/h/%s", serverName, xonk.Username, xonk.XID)
} }
convoy := "" convoy := xonk.Convoy
userinfo := GetUserInfo(r) userinfo := GetUserInfo(r)
@ -676,7 +676,7 @@ func savebonk(w http.ResponseWriter, r *http.Request) {
XID: xonk.XID, XID: xonk.XID,
Date: dt, Date: dt,
Noise: xonk.Noise, Noise: xonk.Noise,
Convoy: convoy, Convoy: convoy,
Donks: xonk.Donks, Donks: xonk.Donks,
Audience: oneofakind(prepend(thewholeworld, xonk.Audience)), Audience: oneofakind(prepend(thewholeworld, xonk.Audience)),
} }
@ -723,7 +723,6 @@ func savehonk(w http.ResponseWriter, r *http.Request) {
if rid != "" { if rid != "" {
what = "tonk" what = "tonk"
} }
convoy := ""
honk := Honk{ honk := Honk{
UserID: userinfo.UserID, UserID: userinfo.UserID,
Username: userinfo.Username, Username: userinfo.Username,
@ -731,25 +730,31 @@ func savehonk(w http.ResponseWriter, r *http.Request) {
XID: xid, XID: xid,
RID: rid, RID: rid,
Date: dt, Date: dt,
Convoy: convoy,
} }
if noise[0] == '@' { if noise[0] == '@' {
honk.Audience = append(grapevine(noise), thewholeworld) honk.Audience = append(grapevine(noise), thewholeworld)
} else { } else {
honk.Audience = prepend(thewholeworld, grapevine(noise)) honk.Audience = prepend(thewholeworld, grapevine(noise))
} }
var convoy string
if rid != "" { if rid != "" {
xonk := getxonk("", rid) xonk := getxonk("", rid)
if xonk != nil { if xonk != nil {
honk.Audience = append(honk.Audience, xonk.Audience...) honk.Audience = append(honk.Audience, xonk.Audience...)
convoy = xonk.Convoy
} else { } else {
xonkaud := whosthere(rid) xonkaud, c := whosthere(rid)
honk.Audience = append(honk.Audience, xonkaud...) honk.Audience = append(honk.Audience, xonkaud...)
convoy = c
} }
} }
if convoy == "" {
convoy = "data:,electrichonkytonk-" + xfiltrate()
}
honk.Audience = oneofakind(honk.Audience) honk.Audience = oneofakind(honk.Audience)
noise = obfusbreak(noise) noise = obfusbreak(noise)
honk.Noise = noise honk.Noise = noise
honk.Convoy = convoy
file, filehdr, err := r.FormFile("donk") file, filehdr, err := r.FormFile("donk")
if err == nil { if err == nil {

View File

@ -9,6 +9,10 @@
in reply to: <a href="{{ .RID }}" rel=noreferrer>{{ .RID }}</a> in reply to: <a href="{{ .RID }}" rel=noreferrer>{{ .RID }}</a>
</span> </span>
{{ end }} {{ end }}
<br>
<span style="margin-left: 4em;" class="clip">
convoy: {{ .Convoy }}
</span>
</div> </div>
<div class="noise"> <div class="noise">
<p>{{ .HTML }} <p>{{ .HTML }}