push the junky json code out a little more
This commit is contained in:
parent
d76dc7bf98
commit
889026e80d
259
activity.go
259
activity.go
|
@ -20,43 +20,20 @@ import (
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"humungus.tedunangst.com/r/webs/image"
|
"humungus.tedunangst.com/r/webs/image"
|
||||||
|
"humungus.tedunangst.com/r/webs/junk"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewJunk() map[string]interface{} {
|
|
||||||
return make(map[string]interface{})
|
|
||||||
}
|
|
||||||
|
|
||||||
func WriteJunk(w io.Writer, j map[string]interface{}) error {
|
|
||||||
e := json.NewEncoder(w)
|
|
||||||
e.SetEscapeHTML(false)
|
|
||||||
e.SetIndent("", " ")
|
|
||||||
err := e.Encode(j)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func ReadJunk(r io.Reader) (map[string]interface{}, error) {
|
|
||||||
decoder := json.NewDecoder(r)
|
|
||||||
var j map[string]interface{}
|
|
||||||
err := decoder.Decode(&j)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return j, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var theonetruename = `application/ld+json; profile="https://www.w3.org/ns/activitystreams"`
|
var theonetruename = `application/ld+json; profile="https://www.w3.org/ns/activitystreams"`
|
||||||
var thefakename = `application/activity+json`
|
var thefakename = `application/activity+json`
|
||||||
var falsenames = []string{
|
var falsenames = []string{
|
||||||
|
@ -76,9 +53,9 @@ func friendorfoe(ct string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func PostJunk(keyname string, key *rsa.PrivateKey, url string, j map[string]interface{}) error {
|
func PostJunk(keyname string, key *rsa.PrivateKey, url string, j junk.Junk) error {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
WriteJunk(&buf, j)
|
j.Write(&buf)
|
||||||
return PostMsg(keyname, key, url, buf.Bytes())
|
return PostMsg(keyname, key, url, buf.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +98,7 @@ func (gz *gzCloser) Close() error {
|
||||||
return gz.r.Close()
|
return gz.r.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetJunk(url string) (map[string]interface{}, error) {
|
func GetJunk(url string) (junk.Junk, error) {
|
||||||
client := http.DefaultClient
|
client := http.DefaultClient
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -156,51 +133,10 @@ func GetJunk(url string) (map[string]interface{}, error) {
|
||||||
resp.Body = &gzCloser{r: gz, under: resp.Body}
|
resp.Body = &gzCloser{r: gz, under: resp.Body}
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
j, err := ReadJunk(resp.Body)
|
j, err := junk.Read(resp.Body)
|
||||||
return j, err
|
return j, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func jsonfindinterface(ii interface{}, keys []string) interface{} {
|
|
||||||
for _, key := range keys {
|
|
||||||
idx, err := strconv.Atoi(key)
|
|
||||||
if err == nil {
|
|
||||||
m := ii.([]interface{})
|
|
||||||
if idx >= len(m) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
ii = m[idx]
|
|
||||||
} else {
|
|
||||||
m := ii.(map[string]interface{})
|
|
||||||
ii = m[key]
|
|
||||||
if ii == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ii
|
|
||||||
}
|
|
||||||
func jsonfindstring(j interface{}, keys []string) (string, bool) {
|
|
||||||
s, ok := jsonfindinterface(j, keys).(string)
|
|
||||||
return s, ok
|
|
||||||
}
|
|
||||||
func jsonfindarray(j interface{}, keys []string) ([]interface{}, bool) {
|
|
||||||
a, ok := jsonfindinterface(j, keys).([]interface{})
|
|
||||||
return a, ok
|
|
||||||
}
|
|
||||||
func jsonfindmap(j interface{}, keys []string) (map[string]interface{}, bool) {
|
|
||||||
m, ok := jsonfindinterface(j, keys).(map[string]interface{})
|
|
||||||
return m, ok
|
|
||||||
}
|
|
||||||
func jsongetstring(j interface{}, key string) (string, bool) {
|
|
||||||
return jsonfindstring(j, []string{key})
|
|
||||||
}
|
|
||||||
func jsongetarray(j interface{}, key string) ([]interface{}, bool) {
|
|
||||||
return jsonfindarray(j, []string{key})
|
|
||||||
}
|
|
||||||
func jsongetmap(j interface{}, key string) (map[string]interface{}, bool) {
|
|
||||||
return jsonfindmap(j, []string{key})
|
|
||||||
}
|
|
||||||
|
|
||||||
func savedonk(url string, name, media string, localize bool) *Donk {
|
func savedonk(url string, name, media string, localize bool) *Donk {
|
||||||
if url == "" {
|
if url == "" {
|
||||||
return nil
|
return nil
|
||||||
|
@ -352,9 +288,9 @@ func getboxes(ident string) (*Box, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
inbox, _ := jsongetstring(j, "inbox")
|
inbox, _ := j.GetString("inbox")
|
||||||
outbox, _ := jsongetstring(j, "outbox")
|
outbox, _ := j.GetString("outbox")
|
||||||
sbox, _ := jsonfindstring(j, []string{"endpoints", "sharedInbox"})
|
sbox, _ := j.FindString([]string{"endpoints", "sharedInbox"})
|
||||||
b = &Box{In: inbox, Out: outbox, Shared: sbox}
|
b = &Box{In: inbox, Out: outbox, Shared: sbox}
|
||||||
if inbox != "" {
|
if inbox != "" {
|
||||||
m := strings.Join([]string{inbox, outbox, sbox}, " ")
|
m := strings.Join([]string{inbox, outbox, sbox}, " ")
|
||||||
|
@ -393,22 +329,26 @@ func peeppeep() {
|
||||||
log.Printf("err: %s", err)
|
log.Printf("err: %s", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
t, _ := jsongetstring(j, "type")
|
t, _ := j.GetString("type")
|
||||||
origin := originate(f.XID)
|
origin := originate(f.XID)
|
||||||
if t == "OrderedCollection" {
|
if t == "OrderedCollection" {
|
||||||
items, _ := jsongetarray(j, "orderedItems")
|
items, _ := j.GetArray("orderedItems")
|
||||||
if items == nil {
|
if items == nil {
|
||||||
page1, _ := jsongetstring(j, "first")
|
page1, _ := j.GetString("first")
|
||||||
j, err = GetJunk(page1)
|
j, err = GetJunk(page1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("err: %s", err)
|
log.Printf("err: %s", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
items, _ = jsongetarray(j, "orderedItems")
|
items, _ = j.GetArray("orderedItems")
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
xonk := xonkxonk(user, item, origin)
|
obj, ok := item.(junk.Junk)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
xonk := xonkxonk(user, obj, origin)
|
||||||
if xonk != nil {
|
if xonk != nil {
|
||||||
savexonk(user, xonk)
|
savexonk(user, xonk)
|
||||||
}
|
}
|
||||||
|
@ -423,20 +363,20 @@ func whosthere(xid string) ([]string, string) {
|
||||||
log.Printf("error getting remote xonk: %s", err)
|
log.Printf("error getting remote xonk: %s", err)
|
||||||
return nil, ""
|
return nil, ""
|
||||||
}
|
}
|
||||||
convoy, _ := jsongetstring(obj, "context")
|
convoy, _ := obj.GetString("context")
|
||||||
if convoy == "" {
|
if convoy == "" {
|
||||||
convoy, _ = jsongetstring(obj, "conversation")
|
convoy, _ = obj.GetString("conversation")
|
||||||
}
|
}
|
||||||
return newphone(nil, obj), convoy
|
return newphone(nil, obj), convoy
|
||||||
}
|
}
|
||||||
|
|
||||||
func newphone(a []string, obj map[string]interface{}) []string {
|
func newphone(a []string, obj junk.Junk) []string {
|
||||||
for _, addr := range []string{"to", "cc", "attributedTo"} {
|
for _, addr := range []string{"to", "cc", "attributedTo"} {
|
||||||
who, _ := jsongetstring(obj, addr)
|
who, _ := obj.GetString(addr)
|
||||||
if who != "" {
|
if who != "" {
|
||||||
a = append(a, who)
|
a = append(a, who)
|
||||||
}
|
}
|
||||||
whos, _ := jsongetarray(obj, addr)
|
whos, _ := obj.GetArray(addr)
|
||||||
for _, w := range whos {
|
for _, w := range whos {
|
||||||
who, _ := w.(string)
|
who, _ := w.(string)
|
||||||
if who != "" {
|
if who != "" {
|
||||||
|
@ -447,18 +387,18 @@ func newphone(a []string, obj map[string]interface{}) []string {
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
func consumeactivity(user *WhatAbout, j interface{}, origin string) {
|
func consumeactivity(user *WhatAbout, j junk.Junk, origin string) {
|
||||||
xonk := xonkxonk(user, j, origin)
|
xonk := xonkxonk(user, j, origin)
|
||||||
if xonk != nil {
|
if xonk != nil {
|
||||||
savexonk(user, xonk)
|
savexonk(user, xonk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func xonkxonk(user *WhatAbout, item interface{}, origin string) *Honk {
|
func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
depth := 0
|
depth := 0
|
||||||
maxdepth := 4
|
maxdepth := 4
|
||||||
currenttid := ""
|
currenttid := ""
|
||||||
var xonkxonkfn func(item interface{}, origin string) *Honk
|
var xonkxonkfn func(item junk.Junk, origin string) *Honk
|
||||||
|
|
||||||
saveoneup := func(xid string) {
|
saveoneup := func(xid string) {
|
||||||
log.Printf("getting oneup: %s", xid)
|
log.Printf("getting oneup: %s", xid)
|
||||||
|
@ -479,23 +419,23 @@ func xonkxonk(user *WhatAbout, item interface{}, origin string) *Honk {
|
||||||
depth--
|
depth--
|
||||||
}
|
}
|
||||||
|
|
||||||
xonkxonkfn = func(item interface{}, origin string) *Honk {
|
xonkxonkfn = func(item junk.Junk, origin string) *Honk {
|
||||||
// id, _ := jsongetstring(item, "id")
|
// id, _ := item.GetString( "id")
|
||||||
what, _ := jsongetstring(item, "type")
|
what, _ := item.GetString("type")
|
||||||
dt, _ := jsongetstring(item, "published")
|
dt, _ := item.GetString("published")
|
||||||
|
|
||||||
var audience []string
|
var audience []string
|
||||||
var err error
|
var err error
|
||||||
var xid, rid, url, content, precis, convoy, oonker string
|
var xid, rid, url, content, precis, convoy, oonker string
|
||||||
var obj map[string]interface{}
|
var obj junk.Junk
|
||||||
var ok bool
|
var ok bool
|
||||||
switch what {
|
switch what {
|
||||||
case "Announce":
|
case "Announce":
|
||||||
obj, ok = jsongetmap(item, "object")
|
obj, ok = item.GetMap("object")
|
||||||
if ok {
|
if ok {
|
||||||
xid, _ = jsongetstring(obj, "id")
|
xid, _ = obj.GetString("id")
|
||||||
} else {
|
} else {
|
||||||
xid, _ = jsongetstring(item, "object")
|
xid, _ = item.GetString("object")
|
||||||
}
|
}
|
||||||
if !needxonkid(user, xid) {
|
if !needxonkid(user, xid) {
|
||||||
return nil
|
return nil
|
||||||
|
@ -508,63 +448,67 @@ func xonkxonk(user *WhatAbout, item interface{}, origin string) *Honk {
|
||||||
origin = originate(xid)
|
origin = originate(xid)
|
||||||
what = "bonk"
|
what = "bonk"
|
||||||
case "Create":
|
case "Create":
|
||||||
obj, _ = jsongetmap(item, "object")
|
obj, _ = item.GetMap("object")
|
||||||
what = "honk"
|
what = "honk"
|
||||||
case "Delete":
|
case "Delete":
|
||||||
obj, _ = jsongetmap(item, "object")
|
obj, _ = item.GetMap("object")
|
||||||
xid, _ = jsongetstring(item, "object")
|
xid, _ = item.GetString("object")
|
||||||
what = "eradicate"
|
what = "eradicate"
|
||||||
case "Note":
|
case "Note":
|
||||||
fallthrough
|
fallthrough
|
||||||
case "Article":
|
case "Article":
|
||||||
fallthrough
|
fallthrough
|
||||||
case "Page":
|
case "Page":
|
||||||
obj = item.(map[string]interface{})
|
obj = item
|
||||||
what = "honk"
|
what = "honk"
|
||||||
default:
|
default:
|
||||||
log.Printf("unknown activity: %s", what)
|
log.Printf("unknown activity: %s", what)
|
||||||
fd, _ := os.OpenFile("savedinbox.json", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
|
fd, _ := os.OpenFile("savedinbox.json", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
|
||||||
WriteJunk(fd, item.(map[string]interface{}))
|
item.Write(fd)
|
||||||
io.WriteString(fd, "\n")
|
io.WriteString(fd, "\n")
|
||||||
fd.Close()
|
fd.Close()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var xonk Honk
|
var xonk Honk
|
||||||
who, _ := jsongetstring(item, "actor")
|
who, _ := item.GetString("actor")
|
||||||
if obj != nil {
|
if obj != nil {
|
||||||
if who == "" {
|
if who == "" {
|
||||||
who, _ = jsongetstring(obj, "attributedTo")
|
who, _ = obj.GetString("attributedTo")
|
||||||
}
|
}
|
||||||
oonker, _ = jsongetstring(obj, "attributedTo")
|
oonker, _ = obj.GetString("attributedTo")
|
||||||
ot, _ := jsongetstring(obj, "type")
|
ot, _ := obj.GetString("type")
|
||||||
url, _ = jsongetstring(obj, "url")
|
url, _ = obj.GetString("url")
|
||||||
if ot == "Note" || ot == "Article" || ot == "Page" {
|
if ot == "Note" || ot == "Article" || ot == "Page" {
|
||||||
audience = newphone(audience, obj)
|
audience = newphone(audience, obj)
|
||||||
xid, _ = jsongetstring(obj, "id")
|
xid, _ = obj.GetString("id")
|
||||||
precis, _ = jsongetstring(obj, "summary")
|
precis, _ = obj.GetString("summary")
|
||||||
content, _ = jsongetstring(obj, "content")
|
content, _ = obj.GetString("content")
|
||||||
if !strings.HasPrefix(content, "<p>") {
|
if !strings.HasPrefix(content, "<p>") {
|
||||||
content = "<p>" + content
|
content = "<p>" + content
|
||||||
}
|
}
|
||||||
rid, _ = jsongetstring(obj, "inReplyTo")
|
rid, _ = obj.GetString("inReplyTo")
|
||||||
convoy, _ = jsongetstring(obj, "context")
|
convoy, _ = obj.GetString("context")
|
||||||
if convoy == "" {
|
if convoy == "" {
|
||||||
convoy, _ = jsongetstring(obj, "conversation")
|
convoy, _ = obj.GetString("conversation")
|
||||||
}
|
}
|
||||||
if what == "honk" && rid != "" {
|
if what == "honk" && rid != "" {
|
||||||
what = "tonk"
|
what = "tonk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ot == "Tombstone" {
|
if ot == "Tombstone" {
|
||||||
xid, _ = jsongetstring(obj, "id")
|
xid, _ = obj.GetString("id")
|
||||||
}
|
}
|
||||||
atts, _ := jsongetarray(obj, "attachment")
|
atts, _ := obj.GetArray("attachment")
|
||||||
for i, att := range atts {
|
for i, atti := range atts {
|
||||||
at, _ := jsongetstring(att, "type")
|
att, ok := atti.(junk.Junk)
|
||||||
mt, _ := jsongetstring(att, "mediaType")
|
if !ok {
|
||||||
u, _ := jsongetstring(att, "url")
|
continue
|
||||||
name, _ := jsongetstring(att, "name")
|
}
|
||||||
|
at, _ := att.GetString("type")
|
||||||
|
mt, _ := att.GetString("mediaType")
|
||||||
|
u, _ := att.GetString("url")
|
||||||
|
name, _ := att.GetString("name")
|
||||||
localize := false
|
localize := false
|
||||||
if i > 4 {
|
if i > 4 {
|
||||||
log.Printf("excessive attachment: %s", at)
|
log.Printf("excessive attachment: %s", at)
|
||||||
|
@ -583,17 +527,21 @@ func xonkxonk(user *WhatAbout, item interface{}, origin string) *Honk {
|
||||||
xonk.Donks = append(xonk.Donks, donk)
|
xonk.Donks = append(xonk.Donks, donk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tags, _ := jsongetarray(obj, "tag")
|
tags, _ := obj.GetArray("tag")
|
||||||
for _, tag := range tags {
|
for _, tagi := range tags {
|
||||||
tt, _ := jsongetstring(tag, "type")
|
tag, ok := tagi.(junk.Junk)
|
||||||
name, _ := jsongetstring(tag, "name")
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
tt, _ := tag.GetString("type")
|
||||||
|
name, _ := tag.GetString("name")
|
||||||
if tt == "Emoji" {
|
if tt == "Emoji" {
|
||||||
icon, _ := jsongetmap(tag, "icon")
|
icon, _ := tag.GetMap("icon")
|
||||||
mt, _ := jsongetstring(icon, "mediaType")
|
mt, _ := icon.GetString("mediaType")
|
||||||
if mt == "" {
|
if mt == "" {
|
||||||
mt = "image/png"
|
mt = "image/png"
|
||||||
}
|
}
|
||||||
u, _ := jsongetstring(icon, "url")
|
u, _ := icon.GetString("url")
|
||||||
donk := savedonk(u, name, mt, true)
|
donk := savedonk(u, name, mt, true)
|
||||||
if donk != nil {
|
if donk != nil {
|
||||||
xonk.Donks = append(xonk.Donks, donk)
|
xonk.Donks = append(xonk.Donks, donk)
|
||||||
|
@ -603,6 +551,7 @@ func xonkxonk(user *WhatAbout, item interface{}, origin string) *Honk {
|
||||||
}
|
}
|
||||||
if originate(xid) != origin {
|
if originate(xid) != origin {
|
||||||
log.Printf("original sin: %s <> %s", xid, origin)
|
log.Printf("original sin: %s <> %s", xid, origin)
|
||||||
|
item.Write(os.Stdout)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
audience = append(audience, who)
|
audience = append(audience, who)
|
||||||
|
@ -646,10 +595,10 @@ func xonkxonk(user *WhatAbout, item interface{}, origin string) *Honk {
|
||||||
return xonkxonkfn(item, origin)
|
return xonkxonkfn(item, origin)
|
||||||
}
|
}
|
||||||
|
|
||||||
func rubadubdub(user *WhatAbout, req map[string]interface{}) {
|
func rubadubdub(user *WhatAbout, req junk.Junk) {
|
||||||
xid, _ := jsongetstring(req, "id")
|
xid, _ := req.GetString("id")
|
||||||
actor, _ := jsongetstring(req, "actor")
|
actor, _ := req.GetString("actor")
|
||||||
j := NewJunk()
|
j := junk.New()
|
||||||
j["@context"] = itiswhatitis
|
j["@context"] = itiswhatitis
|
||||||
j["id"] = user.URL + "/dub/" + xid
|
j["id"] = user.URL + "/dub/" + xid
|
||||||
j["type"] = "Accept"
|
j["type"] = "Accept"
|
||||||
|
@ -659,20 +608,20 @@ func rubadubdub(user *WhatAbout, req map[string]interface{}) {
|
||||||
j["object"] = req
|
j["object"] = req
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
WriteJunk(&buf, j)
|
j.Write(&buf)
|
||||||
msg := buf.Bytes()
|
msg := buf.Bytes()
|
||||||
|
|
||||||
deliverate(0, user.Name, actor, msg)
|
deliverate(0, user.Name, actor, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func itakeitallback(user *WhatAbout, xid string) {
|
func itakeitallback(user *WhatAbout, xid string) {
|
||||||
j := NewJunk()
|
j := junk.New()
|
||||||
j["@context"] = itiswhatitis
|
j["@context"] = itiswhatitis
|
||||||
j["id"] = user.URL + "/unsub/" + xid
|
j["id"] = user.URL + "/unsub/" + xid
|
||||||
j["type"] = "Undo"
|
j["type"] = "Undo"
|
||||||
j["actor"] = user.URL
|
j["actor"] = user.URL
|
||||||
j["to"] = xid
|
j["to"] = xid
|
||||||
f := NewJunk()
|
f := junk.New()
|
||||||
f["id"] = user.URL + "/sub/" + xid
|
f["id"] = user.URL + "/sub/" + xid
|
||||||
f["type"] = "Follow"
|
f["type"] = "Follow"
|
||||||
f["actor"] = user.URL
|
f["actor"] = user.URL
|
||||||
|
@ -681,14 +630,14 @@ func itakeitallback(user *WhatAbout, xid string) {
|
||||||
j["published"] = time.Now().UTC().Format(time.RFC3339)
|
j["published"] = time.Now().UTC().Format(time.RFC3339)
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
WriteJunk(&buf, j)
|
j.Write(&buf)
|
||||||
msg := buf.Bytes()
|
msg := buf.Bytes()
|
||||||
|
|
||||||
deliverate(0, user.Name, xid, msg)
|
deliverate(0, user.Name, xid, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func subsub(user *WhatAbout, xid string) {
|
func subsub(user *WhatAbout, xid string) {
|
||||||
j := NewJunk()
|
j := junk.New()
|
||||||
j["@context"] = itiswhatitis
|
j["@context"] = itiswhatitis
|
||||||
j["id"] = user.URL + "/sub/" + xid
|
j["id"] = user.URL + "/sub/" + xid
|
||||||
j["type"] = "Follow"
|
j["type"] = "Follow"
|
||||||
|
@ -698,16 +647,16 @@ func subsub(user *WhatAbout, xid string) {
|
||||||
j["published"] = time.Now().UTC().Format(time.RFC3339)
|
j["published"] = time.Now().UTC().Format(time.RFC3339)
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
WriteJunk(&buf, j)
|
j.Write(&buf)
|
||||||
msg := buf.Bytes()
|
msg := buf.Bytes()
|
||||||
|
|
||||||
deliverate(0, user.Name, xid, msg)
|
deliverate(0, user.Name, xid, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func jonkjonk(user *WhatAbout, h *Honk) (map[string]interface{}, map[string]interface{}) {
|
func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) {
|
||||||
dt := h.Date.Format(time.RFC3339)
|
dt := h.Date.Format(time.RFC3339)
|
||||||
var jo map[string]interface{}
|
var jo junk.Junk
|
||||||
j := NewJunk()
|
j := junk.New()
|
||||||
j["id"] = user.URL + "/" + h.What + "/" + shortxid(h.XID)
|
j["id"] = user.URL + "/" + h.What + "/" + shortxid(h.XID)
|
||||||
j["actor"] = user.URL
|
j["actor"] = user.URL
|
||||||
j["published"] = dt
|
j["published"] = dt
|
||||||
|
@ -722,7 +671,7 @@ func jonkjonk(user *WhatAbout, h *Honk) (map[string]interface{}, map[string]inte
|
||||||
case "honk":
|
case "honk":
|
||||||
j["type"] = "Create"
|
j["type"] = "Create"
|
||||||
|
|
||||||
jo = NewJunk()
|
jo = junk.New()
|
||||||
jo["id"] = h.XID
|
jo["id"] = h.XID
|
||||||
jo["type"] = "Note"
|
jo["type"] = "Note"
|
||||||
jo["published"] = dt
|
jo["published"] = dt
|
||||||
|
@ -750,7 +699,7 @@ func jonkjonk(user *WhatAbout, h *Honk) (map[string]interface{}, map[string]inte
|
||||||
var tags []interface{}
|
var tags []interface{}
|
||||||
g := bunchofgrapes(h.Noise)
|
g := bunchofgrapes(h.Noise)
|
||||||
for _, m := range g {
|
for _, m := range g {
|
||||||
t := NewJunk()
|
t := junk.New()
|
||||||
t["type"] = "Mention"
|
t["type"] = "Mention"
|
||||||
t["name"] = m.who
|
t["name"] = m.who
|
||||||
t["href"] = m.where
|
t["href"] = m.where
|
||||||
|
@ -758,11 +707,11 @@ func jonkjonk(user *WhatAbout, h *Honk) (map[string]interface{}, map[string]inte
|
||||||
}
|
}
|
||||||
herd := herdofemus(h.Noise)
|
herd := herdofemus(h.Noise)
|
||||||
for _, e := range herd {
|
for _, e := range herd {
|
||||||
t := NewJunk()
|
t := junk.New()
|
||||||
t["id"] = e.ID
|
t["id"] = e.ID
|
||||||
t["type"] = "Emoji"
|
t["type"] = "Emoji"
|
||||||
t["name"] = e.Name
|
t["name"] = e.Name
|
||||||
i := NewJunk()
|
i := junk.New()
|
||||||
i["type"] = "Image"
|
i["type"] = "Image"
|
||||||
i["mediaType"] = "image/png"
|
i["mediaType"] = "image/png"
|
||||||
i["url"] = e.ID
|
i["url"] = e.ID
|
||||||
|
@ -777,7 +726,7 @@ func jonkjonk(user *WhatAbout, h *Honk) (map[string]interface{}, map[string]inte
|
||||||
if re_emus.MatchString(d.Name) {
|
if re_emus.MatchString(d.Name) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
jd := NewJunk()
|
jd := junk.New()
|
||||||
jd["mediaType"] = d.Media
|
jd["mediaType"] = d.Media
|
||||||
jd["name"] = d.Name
|
jd["name"] = d.Name
|
||||||
jd["type"] = "Document"
|
jd["type"] = "Document"
|
||||||
|
@ -803,7 +752,7 @@ func honkworldwide(user *WhatAbout, honk *Honk) {
|
||||||
jonk, _ := jonkjonk(user, honk)
|
jonk, _ := jonkjonk(user, honk)
|
||||||
jonk["@context"] = itiswhatitis
|
jonk["@context"] = itiswhatitis
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
WriteJunk(&buf, jonk)
|
jonk.Write(&buf)
|
||||||
msg := buf.Bytes()
|
msg := buf.Bytes()
|
||||||
|
|
||||||
rcpts := make(map[string]bool)
|
rcpts := make(map[string]bool)
|
||||||
|
@ -836,10 +785,10 @@ func honkworldwide(user *WhatAbout, honk *Honk) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func asjonker(user *WhatAbout) map[string]interface{} {
|
func asjonker(user *WhatAbout) junk.Junk {
|
||||||
about := obfusbreak(user.About)
|
about := obfusbreak(user.About)
|
||||||
|
|
||||||
j := NewJunk()
|
j := junk.New()
|
||||||
j["@context"] = itiswhatitis
|
j["@context"] = itiswhatitis
|
||||||
j["id"] = user.URL
|
j["id"] = user.URL
|
||||||
j["type"] = "Person"
|
j["type"] = "Person"
|
||||||
|
@ -851,12 +800,12 @@ func asjonker(user *WhatAbout) map[string]interface{} {
|
||||||
j["preferredUsername"] = user.Name
|
j["preferredUsername"] = user.Name
|
||||||
j["summary"] = about
|
j["summary"] = about
|
||||||
j["url"] = user.URL
|
j["url"] = user.URL
|
||||||
a := NewJunk()
|
a := junk.New()
|
||||||
a["type"] = "icon"
|
a["type"] = "icon"
|
||||||
a["mediaType"] = "image/png"
|
a["mediaType"] = "image/png"
|
||||||
a["url"] = fmt.Sprintf("https://%s/a?a=%s", serverName, url.QueryEscape(user.URL))
|
a["url"] = fmt.Sprintf("https://%s/a?a=%s", serverName, url.QueryEscape(user.URL))
|
||||||
j["icon"] = a
|
j["icon"] = a
|
||||||
k := NewJunk()
|
k := junk.New()
|
||||||
k["id"] = user.URL + "#key"
|
k["id"] = user.URL + "#key"
|
||||||
k["owner"] = user.URL
|
k["owner"] = user.URL
|
||||||
k["publicKeyPem"] = user.Key
|
k["publicKeyPem"] = user.Key
|
||||||
|
@ -901,11 +850,15 @@ func gofish(name string) string {
|
||||||
handlock.Unlock()
|
handlock.Unlock()
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
links, _ := jsongetarray(j, "links")
|
links, _ := j.GetArray("links")
|
||||||
for _, l := range links {
|
for _, li := range links {
|
||||||
href, _ := jsongetstring(l, "href")
|
l, ok := li.(junk.Junk)
|
||||||
rel, _ := jsongetstring(l, "rel")
|
if !ok {
|
||||||
t, _ := jsongetstring(l, "type")
|
continue
|
||||||
|
}
|
||||||
|
href, _ := l.GetString("href")
|
||||||
|
rel, _ := l.GetString("rel")
|
||||||
|
t, _ := l.GetString("type")
|
||||||
if rel == "self" && friendorfoe(t) {
|
if rel == "self" && friendorfoe(t) {
|
||||||
stmtSaveXonker.Exec(name, href, "fishname")
|
stmtSaveXonker.Exec(name, href, "fishname")
|
||||||
handlock.Lock()
|
handlock.Lock()
|
||||||
|
@ -935,8 +888,8 @@ func investigate(name string) string {
|
||||||
log.Printf("error investigating honker: %s", err)
|
log.Printf("error investigating honker: %s", err)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
t, _ := jsongetstring(obj, "type")
|
t, _ := obj.GetString("type")
|
||||||
id, _ := jsongetstring(obj, "id")
|
id, _ := obj.GetString("id")
|
||||||
if t != "Person" {
|
if t != "Person" {
|
||||||
log.Printf("it's not a person! %s", name)
|
log.Printf("it's not a person! %s", name)
|
||||||
return ""
|
return ""
|
||||||
|
|
4
fun.go
4
fun.go
|
@ -410,12 +410,12 @@ func zaggy(keyname string) (key *rsa.PublicKey) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var ok bool
|
var ok bool
|
||||||
data, ok = jsonfindstring(j, []string{"publicKey", "publicKeyPem"})
|
data, ok = j.FindString([]string{"publicKey", "publicKeyPem"})
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Printf("error finding %s pubkey", keyname)
|
log.Printf("error finding %s pubkey", keyname)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, ok = jsonfindstring(j, []string{"publicKey", "owner"})
|
_, ok = j.FindString([]string{"publicKey", "owner"})
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Printf("error finding %s pubkey owner", keyname)
|
log.Printf("error finding %s pubkey owner", keyname)
|
||||||
return
|
return
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -7,5 +7,5 @@ require (
|
||||||
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f
|
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f
|
||||||
golang.org/x/net v0.0.0-20190522155817-f3200d17e092
|
golang.org/x/net v0.0.0-20190522155817-f3200d17e092
|
||||||
humungus.tedunangst.com/r/go-sqlite3 v1.1.3
|
humungus.tedunangst.com/r/go-sqlite3 v1.1.3
|
||||||
humungus.tedunangst.com/r/webs v0.5.2
|
humungus.tedunangst.com/r/webs v0.5.3
|
||||||
)
|
)
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -21,3 +21,5 @@ humungus.tedunangst.com/r/go-sqlite3 v1.1.3 h1:G2N4wzDS0NbuvrZtQJhh4F+3X+s7BF8b9
|
||||||
humungus.tedunangst.com/r/go-sqlite3 v1.1.3/go.mod h1:FtEEmQM7U2Ey1TuEEOyY1BmphTZnmiEjPsNLEAkpf/M=
|
humungus.tedunangst.com/r/go-sqlite3 v1.1.3/go.mod h1:FtEEmQM7U2Ey1TuEEOyY1BmphTZnmiEjPsNLEAkpf/M=
|
||||||
humungus.tedunangst.com/r/webs v0.5.2 h1:/HQ4xd33i1As3/5eD7RJXk7CewSg9WFa2HDBIkYlnxU=
|
humungus.tedunangst.com/r/webs v0.5.2 h1:/HQ4xd33i1As3/5eD7RJXk7CewSg9WFa2HDBIkYlnxU=
|
||||||
humungus.tedunangst.com/r/webs v0.5.2/go.mod h1:79Ww3HmgE1m+HXU0r0b9hkOD3JuDzXoGiEauHuKcwBI=
|
humungus.tedunangst.com/r/webs v0.5.2/go.mod h1:79Ww3HmgE1m+HXU0r0b9hkOD3JuDzXoGiEauHuKcwBI=
|
||||||
|
humungus.tedunangst.com/r/webs v0.5.3 h1:XwDc9EYU/kIZp1S87X756Ywl8VatvV2tVxZUq4H09Sw=
|
||||||
|
humungus.tedunangst.com/r/webs v0.5.3/go.mod h1:79Ww3HmgE1m+HXU0r0b9hkOD3JuDzXoGiEauHuKcwBI=
|
||||||
|
|
55
honk.go
55
honk.go
|
@ -35,6 +35,7 @@ import (
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"humungus.tedunangst.com/r/webs/htfilter"
|
"humungus.tedunangst.com/r/webs/htfilter"
|
||||||
"humungus.tedunangst.com/r/webs/image"
|
"humungus.tedunangst.com/r/webs/image"
|
||||||
|
"humungus.tedunangst.com/r/webs/junk"
|
||||||
"humungus.tedunangst.com/r/webs/login"
|
"humungus.tedunangst.com/r/webs/login"
|
||||||
"humungus.tedunangst.com/r/webs/rss"
|
"humungus.tedunangst.com/r/webs/rss"
|
||||||
"humungus.tedunangst.com/r/webs/templates"
|
"humungus.tedunangst.com/r/webs/templates"
|
||||||
|
@ -217,10 +218,10 @@ func butwhatabout(name string) (*WhatAbout, error) {
|
||||||
return &user, err
|
return &user, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func crappola(j map[string]interface{}) bool {
|
func crappola(j junk.Junk) bool {
|
||||||
t, _ := jsongetstring(j, "type")
|
t, _ := j.GetString("type")
|
||||||
a, _ := jsongetstring(j, "actor")
|
a, _ := j.GetString("actor")
|
||||||
o, _ := jsongetstring(j, "object")
|
o, _ := j.GetString("object")
|
||||||
if t == "Delete" && a == o {
|
if t == "Delete" && a == o {
|
||||||
log.Printf("crappola from %s", a)
|
log.Printf("crappola from %s", a)
|
||||||
return true
|
return true
|
||||||
|
@ -234,7 +235,7 @@ func ping(user *WhatAbout, who string) {
|
||||||
log.Printf("no inbox for ping: %s", err)
|
log.Printf("no inbox for ping: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
j := NewJunk()
|
j := junk.New()
|
||||||
j["@context"] = itiswhatitis
|
j["@context"] = itiswhatitis
|
||||||
j["type"] = "Ping"
|
j["type"] = "Ping"
|
||||||
j["id"] = user.URL + "/ping/" + xfiltrate()
|
j["id"] = user.URL + "/ping/" + xfiltrate()
|
||||||
|
@ -255,7 +256,7 @@ func pong(user *WhatAbout, who string, obj string) {
|
||||||
log.Printf("no inbox for pong %s : %s", who, err)
|
log.Printf("no inbox for pong %s : %s", who, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
j := NewJunk()
|
j := junk.New()
|
||||||
j["@context"] = itiswhatitis
|
j["@context"] = itiswhatitis
|
||||||
j["type"] = "Pong"
|
j["type"] = "Pong"
|
||||||
j["id"] = user.URL + "/pong/" + xfiltrate()
|
j["id"] = user.URL + "/pong/" + xfiltrate()
|
||||||
|
@ -280,7 +281,7 @@ func inbox(w http.ResponseWriter, r *http.Request) {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
io.Copy(&buf, r.Body)
|
io.Copy(&buf, r.Body)
|
||||||
payload := buf.Bytes()
|
payload := buf.Bytes()
|
||||||
j, err := ReadJunk(bytes.NewReader(payload))
|
j, err := junk.Read(bytes.NewReader(payload))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("bad payload: %s", err)
|
log.Printf("bad payload: %s", err)
|
||||||
io.WriteString(os.Stdout, "bad payload\n")
|
io.WriteString(os.Stdout, "bad payload\n")
|
||||||
|
@ -301,31 +302,31 @@ func inbox(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
what, _ := jsongetstring(j, "type")
|
what, _ := j.GetString("type")
|
||||||
if what == "Like" {
|
if what == "Like" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
who, _ := jsongetstring(j, "actor")
|
who, _ := j.GetString("actor")
|
||||||
origin := keymatch(keyname, who)
|
origin := keymatch(keyname, who)
|
||||||
if origin == "" {
|
if origin == "" {
|
||||||
log.Printf("keyname actor mismatch: %s <> %s", keyname, who)
|
log.Printf("keyname actor mismatch: %s <> %s", keyname, who)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
objid, _ := jsongetstring(j, "id")
|
objid, _ := j.GetString("id")
|
||||||
if thoudostbitethythumb(user.ID, []string{who}, objid) {
|
if thoudostbitethythumb(user.ID, []string{who}, objid) {
|
||||||
log.Printf("ignoring thumb sucker %s", who)
|
log.Printf("ignoring thumb sucker %s", who)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch what {
|
switch what {
|
||||||
case "Ping":
|
case "Ping":
|
||||||
obj, _ := jsongetstring(j, "id")
|
obj, _ := j.GetString("id")
|
||||||
log.Printf("ping from %s: %s", who, obj)
|
log.Printf("ping from %s: %s", who, obj)
|
||||||
pong(user, who, obj)
|
pong(user, who, obj)
|
||||||
case "Pong":
|
case "Pong":
|
||||||
obj, _ := jsongetstring(j, "object")
|
obj, _ := j.GetString("object")
|
||||||
log.Printf("pong from %s: %s", who, obj)
|
log.Printf("pong from %s: %s", who, obj)
|
||||||
case "Follow":
|
case "Follow":
|
||||||
obj, _ := jsongetstring(j, "object")
|
obj, _ := j.GetString("object")
|
||||||
if obj == user.URL {
|
if obj == user.URL {
|
||||||
log.Printf("updating honker follow: %s", who)
|
log.Printf("updating honker follow: %s", who)
|
||||||
stmtSaveDub.Exec(user.ID, who, who, "dub")
|
stmtSaveDub.Exec(user.ID, who, who, "dub")
|
||||||
|
@ -341,9 +342,9 @@ func inbox(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case "Update":
|
case "Update":
|
||||||
obj, ok := jsongetmap(j, "object")
|
obj, ok := j.GetMap("object")
|
||||||
if ok {
|
if ok {
|
||||||
what, _ := jsongetstring(obj, "type")
|
what, _ := obj.GetString("type")
|
||||||
switch what {
|
switch what {
|
||||||
case "Person":
|
case "Person":
|
||||||
return
|
return
|
||||||
|
@ -351,16 +352,16 @@ func inbox(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
log.Printf("unknown Update activity")
|
log.Printf("unknown Update activity")
|
||||||
fd, _ := os.OpenFile("savedinbox.json", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
|
fd, _ := os.OpenFile("savedinbox.json", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
|
||||||
WriteJunk(fd, j)
|
j.Write(fd)
|
||||||
io.WriteString(fd, "\n")
|
io.WriteString(fd, "\n")
|
||||||
fd.Close()
|
fd.Close()
|
||||||
|
|
||||||
case "Undo":
|
case "Undo":
|
||||||
obj, ok := jsongetmap(j, "object")
|
obj, ok := j.GetMap("object")
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Printf("unknown undo no object")
|
log.Printf("unknown undo no object")
|
||||||
} else {
|
} else {
|
||||||
what, _ := jsongetstring(obj, "type")
|
what, _ := obj.GetString("type")
|
||||||
switch what {
|
switch what {
|
||||||
case "Follow":
|
case "Follow":
|
||||||
log.Printf("updating honker undo: %s", who)
|
log.Printf("updating honker undo: %s", who)
|
||||||
|
@ -421,7 +422,7 @@ func outbox(w http.ResponseWriter, r *http.Request) {
|
||||||
jonks = append(jonks, j)
|
jonks = append(jonks, j)
|
||||||
}
|
}
|
||||||
|
|
||||||
j := NewJunk()
|
j := junk.New()
|
||||||
j["@context"] = itiswhatitis
|
j["@context"] = itiswhatitis
|
||||||
j["id"] = user.URL + "/outbox"
|
j["id"] = user.URL + "/outbox"
|
||||||
j["type"] = "OrderedCollection"
|
j["type"] = "OrderedCollection"
|
||||||
|
@ -430,7 +431,7 @@ func outbox(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
w.Header().Set("Cache-Control", "max-age=60")
|
w.Header().Set("Cache-Control", "max-age=60")
|
||||||
w.Header().Set("Content-Type", theonetruename)
|
w.Header().Set("Content-Type", theonetruename)
|
||||||
WriteJunk(w, j)
|
j.Write(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func emptiness(w http.ResponseWriter, r *http.Request) {
|
func emptiness(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -444,7 +445,7 @@ func emptiness(w http.ResponseWriter, r *http.Request) {
|
||||||
if strings.HasSuffix(r.URL.Path, "/following") {
|
if strings.HasSuffix(r.URL.Path, "/following") {
|
||||||
colname = "/following"
|
colname = "/following"
|
||||||
}
|
}
|
||||||
j := NewJunk()
|
j := junk.New()
|
||||||
j["@context"] = itiswhatitis
|
j["@context"] = itiswhatitis
|
||||||
j["id"] = user.URL + colname
|
j["id"] = user.URL + colname
|
||||||
j["type"] = "OrderedCollection"
|
j["type"] = "OrderedCollection"
|
||||||
|
@ -453,7 +454,7 @@ func emptiness(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
w.Header().Set("Cache-Control", "max-age=60")
|
w.Header().Set("Cache-Control", "max-age=60")
|
||||||
w.Header().Set("Content-Type", theonetruename)
|
w.Header().Set("Content-Type", theonetruename)
|
||||||
WriteJunk(w, j)
|
j.Write(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func showuser(w http.ResponseWriter, r *http.Request) {
|
func showuser(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -467,7 +468,7 @@ func showuser(w http.ResponseWriter, r *http.Request) {
|
||||||
j := asjonker(user)
|
j := asjonker(user)
|
||||||
w.Header().Set("Cache-Control", "max-age=600")
|
w.Header().Set("Cache-Control", "max-age=600")
|
||||||
w.Header().Set("Content-Type", theonetruename)
|
w.Header().Set("Content-Type", theonetruename)
|
||||||
WriteJunk(w, j)
|
j.Write(w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
u := login.GetUserInfo(r)
|
u := login.GetUserInfo(r)
|
||||||
|
@ -518,7 +519,7 @@ func showhonk(w http.ResponseWriter, r *http.Request) {
|
||||||
j["@context"] = itiswhatitis
|
j["@context"] = itiswhatitis
|
||||||
w.Header().Set("Cache-Control", "max-age=3600")
|
w.Header().Set("Cache-Control", "max-age=3600")
|
||||||
w.Header().Set("Content-Type", theonetruename)
|
w.Header().Set("Content-Type", theonetruename)
|
||||||
WriteJunk(w, j)
|
j.Write(w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
honks := gethonksbyconvoy(-1, h.Convoy)
|
honks := gethonksbyconvoy(-1, h.Convoy)
|
||||||
|
@ -1210,11 +1211,11 @@ func fingerlicker(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
j := NewJunk()
|
j := junk.New()
|
||||||
j["subject"] = fmt.Sprintf("acct:%s@%s", user.Name, serverName)
|
j["subject"] = fmt.Sprintf("acct:%s@%s", user.Name, serverName)
|
||||||
j["aliases"] = []string{user.URL}
|
j["aliases"] = []string{user.URL}
|
||||||
var links []map[string]interface{}
|
var links []map[string]interface{}
|
||||||
l := NewJunk()
|
l := junk.New()
|
||||||
l["rel"] = "self"
|
l["rel"] = "self"
|
||||||
l["type"] = `application/activity+json`
|
l["type"] = `application/activity+json`
|
||||||
l["href"] = user.URL
|
l["href"] = user.URL
|
||||||
|
@ -1223,7 +1224,7 @@ func fingerlicker(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
w.Header().Set("Cache-Control", "max-age=3600")
|
w.Header().Set("Cache-Control", "max-age=3600")
|
||||||
w.Header().Set("Content-Type", "application/jrd+json")
|
w.Header().Set("Content-Type", "application/jrd+json")
|
||||||
WriteJunk(w, j)
|
j.Write(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func somedays() string {
|
func somedays() string {
|
||||||
|
|
Loading…
Reference in New Issue