all repos — honk @ 8c14fb9c6de790b2c62c4f690b9a4e6f9c77a944

my fork of honk

can simplify a bit with new functions
Ted Unangst tedu@tedunangst.com
Fri, 25 Oct 2019 17:44:46 -0400
commit

8c14fb9c6de790b2c62c4f690b9a4e6f9c77a944

parent

a03fe08a61518d59be749d9918337cd86b1fd7f1

2 files changed, 10 insertions(+), 27 deletions(-)

jump to
M activity.goactivity.go

@@ -58,9 +58,7 @@ return false

} func PostJunk(keyname string, key *rsa.PrivateKey, url string, j junk.Junk) error { - var buf bytes.Buffer - j.Write(&buf) - return PostMsg(keyname, key, url, buf.Bytes()) + return PostMsg(keyname, key, url, j.ToBytes()) } func PostMsg(keyname string, key *rsa.PrivateKey, url string, msg []byte) error {

@@ -914,11 +912,7 @@ j["to"] = actor

j["published"] = time.Now().UTC().Format(time.RFC3339) j["object"] = req - var buf bytes.Buffer - j.Write(&buf) - msg := buf.Bytes() - - deliverate(0, user.Name, actor, msg) + deliverate(0, user.Name, actor, j.ToBytes()) } func itakeitallback(user *WhatAbout, xid string) {

@@ -937,11 +931,7 @@ f["object"] = xid

j["object"] = f j["published"] = time.Now().UTC().Format(time.RFC3339) - var buf bytes.Buffer - j.Write(&buf) - msg := buf.Bytes() - - deliverate(0, user.Name, xid, msg) + deliverate(0, user.Name, xid, j.ToBytes()) } func subsub(user *WhatAbout, xid string) {

@@ -1158,9 +1148,8 @@ }

donksforhonks([]*Honk{honk}) _, j := jonkjonk(user, honk) j["@context"] = itiswhatitis - var buf bytes.Buffer - j.Write(&buf) - return buf.Bytes(), true + + return j.ToBytes(), true }}) func gimmejonk(xid string) ([]byte, bool) {

@@ -1172,9 +1161,7 @@

func honkworldwide(user *WhatAbout, honk *Honk) { jonk, _ := jonkjonk(user, honk) jonk["@context"] = itiswhatitis - var buf bytes.Buffer - jonk.Write(&buf) - msg := buf.Bytes() + msg := jonk.ToBytes() rcpts := make(map[string]bool) for _, a := range honk.Audience {

@@ -1238,9 +1225,7 @@ k["owner"] = user.URL

k["publicKeyPem"] = user.Key j["publicKey"] = k - var buf bytes.Buffer - j.Write(&buf) - return buf.Bytes() + return j.ToBytes() } var oldjonkers = cache.New(cache.Options{Filler: func(name string) ([]byte, bool) {
M web.goweb.go

@@ -290,7 +290,7 @@ }

var buf bytes.Buffer io.Copy(&buf, r.Body) payload := buf.Bytes() - j, err := junk.Read(bytes.NewReader(payload)) + j, err := junk.FromBytes(payload) if err != nil { log.Printf("bad payload: %s", err) io.WriteString(os.Stdout, "bad payload\n")

@@ -418,7 +418,7 @@ }

var buf bytes.Buffer io.Copy(&buf, r.Body) payload := buf.Bytes() - j, err := junk.Read(bytes.NewReader(payload)) + j, err := junk.FromBytes(payload) if err != nil { log.Printf("bad payload: %s", err) io.WriteString(os.Stdout, "bad payload\n")

@@ -539,9 +539,7 @@ j["type"] = "OrderedCollection"

j["totalItems"] = len(jonks) j["orderedItems"] = jonks - var buf bytes.Buffer - j.Write(&buf) - return buf.Bytes(), true + return j.ToBytes(), true }, Duration: 1 * time.Minute}) func outbox(w http.ResponseWriter, r *http.Request) {