all repos — honk @ 15d6fd92771656efcc2b09feb9e1cba2b3333fd4

my fork of honk

activity.go (view raw)

  1//
  2// Copyright (c) 2019 Ted Unangst <tedu@tedunangst.com>
  3//
  4// Permission to use, copy, modify, and distribute this software for any
  5// purpose with or without fee is hereby granted, provided that the above
  6// copyright notice and this permission notice appear in all copies.
  7//
  8// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 10// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 11// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 12// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 13// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 14// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 15
 16package main
 17
 18import (
 19	"bytes"
 20	"compress/gzip"
 21	"crypto/rsa"
 22	"database/sql"
 23	"encoding/json"
 24	"fmt"
 25	"image"
 26	"io"
 27	"log"
 28	"net/http"
 29	"net/url"
 30	"os"
 31	"strconv"
 32	"strings"
 33	"sync"
 34	"time"
 35)
 36
 37func NewJunk() map[string]interface{} {
 38	return make(map[string]interface{})
 39}
 40
 41func WriteJunk(w io.Writer, j map[string]interface{}) error {
 42	e := json.NewEncoder(w)
 43	e.SetEscapeHTML(false)
 44	e.SetIndent("", "  ")
 45	err := e.Encode(j)
 46	return err
 47}
 48
 49func ReadJunk(r io.Reader) (map[string]interface{}, error) {
 50	decoder := json.NewDecoder(r)
 51	var j map[string]interface{}
 52	err := decoder.Decode(&j)
 53	if err != nil {
 54		return nil, err
 55	}
 56	return j, nil
 57}
 58
 59var theonetruename = `application/ld+json; profile="https://www.w3.org/ns/activitystreams"`
 60var thefakename = `application/activity+json`
 61var falsenames = []string{
 62	`application/ld+json`,
 63	`application/activity+json`,
 64}
 65var itiswhatitis = "https://www.w3.org/ns/activitystreams"
 66var thewholeworld = "https://www.w3.org/ns/activitystreams#Public"
 67
 68func friendorfoe(ct string) bool {
 69	ct = strings.ToLower(ct)
 70	for _, at := range falsenames {
 71		if strings.HasPrefix(ct, at) {
 72			return true
 73		}
 74	}
 75	return false
 76}
 77
 78func PostJunk(keyname string, key *rsa.PrivateKey, url string, j map[string]interface{}) error {
 79	var buf bytes.Buffer
 80	WriteJunk(&buf, j)
 81	return PostMsg(keyname, key, url, buf.Bytes())
 82}
 83
 84func PostMsg(keyname string, key *rsa.PrivateKey, url string, msg []byte) error {
 85	client := http.DefaultClient
 86	req, err := http.NewRequest("POST", url, bytes.NewReader(msg))
 87	if err != nil {
 88		return err
 89	}
 90	req.Header.Set("Content-Type", theonetruename)
 91	zig(keyname, key, req, msg)
 92	resp, err := client.Do(req)
 93	if err != nil {
 94		return err
 95	}
 96	resp.Body.Close()
 97	switch resp.StatusCode {
 98	case 200:
 99	case 201:
100	case 202:
101	default:
102		return fmt.Errorf("http post status: %d", resp.StatusCode)
103	}
104	log.Printf("successful post: %s %d", url, resp.StatusCode)
105	return nil
106}
107
108type gzCloser struct {
109	r     *gzip.Reader
110	under io.ReadCloser
111}
112
113func (gz *gzCloser) Read(p []byte) (int, error) {
114	return gz.r.Read(p)
115}
116
117func (gz *gzCloser) Close() error {
118	defer gz.under.Close()
119	return gz.r.Close()
120}
121
122func GetJunk(url string) (map[string]interface{}, error) {
123	client := http.DefaultClient
124	req, err := http.NewRequest("GET", url, nil)
125	if err != nil {
126		return nil, err
127	}
128	at := thefakename
129	if strings.Contains(url, ".well-known/webfinger?resource") {
130		at = "application/jrd+json"
131	}
132	req.Header.Set("Accept", at)
133	req.Header.Set("Accept-Encoding", "gzip")
134	req.Header.Set("User-Agent", "honksnonk/5.0")
135	resp, err := client.Do(req)
136	if err != nil {
137		return nil, err
138	}
139	if resp.StatusCode != 200 {
140		resp.Body.Close()
141		return nil, fmt.Errorf("http get status: %d", resp.StatusCode)
142	}
143	if strings.EqualFold(resp.Header.Get("Content-Encoding"), "gzip") {
144		gz, err := gzip.NewReader(resp.Body)
145		if err != nil {
146			resp.Body.Close()
147			return nil, err
148		}
149		resp.Body = &gzCloser{r: gz, under: resp.Body}
150	}
151	defer resp.Body.Close()
152	j, err := ReadJunk(resp.Body)
153	return j, err
154}
155
156func jsonfindinterface(ii interface{}, keys []string) interface{} {
157	for _, key := range keys {
158		idx, err := strconv.Atoi(key)
159		if err == nil {
160			m := ii.([]interface{})
161			if idx >= len(m) {
162				return nil
163			}
164			ii = m[idx]
165		} else {
166			m := ii.(map[string]interface{})
167			ii = m[key]
168			if ii == nil {
169				return nil
170			}
171		}
172	}
173	return ii
174}
175func jsonfindstring(j interface{}, keys []string) (string, bool) {
176	s, ok := jsonfindinterface(j, keys).(string)
177	return s, ok
178}
179func jsonfindarray(j interface{}, keys []string) ([]interface{}, bool) {
180	a, ok := jsonfindinterface(j, keys).([]interface{})
181	return a, ok
182}
183func jsonfindmap(j interface{}, keys []string) (map[string]interface{}, bool) {
184	m, ok := jsonfindinterface(j, keys).(map[string]interface{})
185	return m, ok
186}
187func jsongetstring(j interface{}, key string) (string, bool) {
188	return jsonfindstring(j, []string{key})
189}
190func jsongetarray(j interface{}, key string) ([]interface{}, bool) {
191	return jsonfindarray(j, []string{key})
192}
193func jsongetmap(j interface{}, key string) (map[string]interface{}, bool) {
194	return jsonfindmap(j, []string{key})
195}
196
197func savedonk(url string, name, media string) *Donk {
198	var donk Donk
199	row := stmtFindFile.QueryRow(url)
200	err := row.Scan(&donk.FileID)
201	if err == nil {
202		return &donk
203	}
204	log.Printf("saving donk: %s", url)
205	if err != nil && err != sql.ErrNoRows {
206		log.Printf("error querying: %s", err)
207	}
208	resp, err := http.Get(url)
209	if err != nil {
210		log.Printf("error fetching %s: %s", url, err)
211		return nil
212	}
213	defer resp.Body.Close()
214	if resp.StatusCode != 200 {
215		return nil
216	}
217	var buf bytes.Buffer
218	io.Copy(&buf, resp.Body)
219
220	xid := xfiltrate()
221
222	data := buf.Bytes()
223	if strings.HasPrefix(media, "image") {
224		img, format, err := image.Decode(&buf)
225		if err != nil {
226			log.Printf("unable to decode image: %s", err)
227			return nil
228		}
229		data, format, err = vacuumwrap(img, format)
230		media = "image/" + format
231	}
232	res, err := stmtSaveFile.Exec(xid, name, url, media, data)
233	if err != nil {
234		log.Printf("error saving file %s: %s", url, err)
235		return nil
236	}
237	donk.FileID, _ = res.LastInsertId()
238	return &donk
239}
240
241func needxonk(user *WhatAbout, x *Honk) bool {
242	if x == nil {
243		return false
244	}
245	if x.What == "eradicate" {
246		return true
247	}
248	if thoudostbitethythumb(user.ID, x.Audience, x.XID) {
249		log.Printf("not saving thumb biter? %s", x.Honker)
250		return false
251	}
252	return needxonkid(user, x.XID)
253}
254func needxonkid(user *WhatAbout, xid string) bool {
255	if strings.HasPrefix(xid, user.URL+"/h/") {
256		return false
257	}
258	row := stmtFindXonk.QueryRow(user.ID, xid)
259	var id int64
260	err := row.Scan(&id)
261	if err == nil {
262		return false
263	}
264	if err != sql.ErrNoRows {
265		log.Printf("err querying xonk: %s", err)
266	}
267	return true
268}
269
270func savexonk(user *WhatAbout, x *Honk) {
271	if x.What == "eradicate" {
272		log.Printf("eradicating %s by %s", x.RID, x.Honker)
273		_, err := stmtDeleteHonk.Exec(x.RID, x.Honker, user.ID)
274		if err != nil {
275			log.Printf("error eradicating: %s", err)
276		}
277		return
278	}
279	dt := x.Date.UTC().Format(dbtimeformat)
280	aud := strings.Join(x.Audience, " ")
281	whofore := 0
282	if strings.Contains(aud, user.URL) {
283		whofore = 1
284	}
285	res, err := stmtSaveHonk.Exec(x.UserID, x.What, x.Honker, x.XID, x.RID, dt, x.URL, aud,
286		x.Noise, x.Convoy, whofore)
287	if err != nil {
288		log.Printf("err saving xonk: %s", err)
289		return
290	}
291	x.ID, _ = res.LastInsertId()
292	for _, d := range x.Donks {
293		_, err = stmtSaveDonk.Exec(x.ID, d.FileID)
294		if err != nil {
295			log.Printf("err saving donk: %s", err)
296			return
297		}
298	}
299}
300
301type Box struct {
302	In     string
303	Out    string
304	Shared string
305}
306
307var boxofboxes = make(map[string]*Box)
308var boxlock sync.Mutex
309var boxinglock sync.Mutex
310
311func getboxes(ident string) (*Box, error) {
312	boxlock.Lock()
313	b, ok := boxofboxes[ident]
314	boxlock.Unlock()
315	if ok {
316		return b, nil
317	}
318
319	boxinglock.Lock()
320	defer boxinglock.Unlock()
321
322	boxlock.Lock()
323	b, ok = boxofboxes[ident]
324	boxlock.Unlock()
325	if ok {
326		return b, nil
327	}
328
329	db := opendatabase()
330
331	row := db.QueryRow("select ibox, obox, sbox from xonkers where xid = ?", ident)
332	b = &Box{}
333	err := row.Scan(&b.In, &b.Out, &b.Shared)
334	if err != nil {
335		j, err := GetJunk(ident)
336		if err != nil {
337			return nil, err
338		}
339		inbox, _ := jsongetstring(j, "inbox")
340		outbox, _ := jsongetstring(j, "outbox")
341		sbox, _ := jsonfindstring(j, []string{"endpoints", "sharedInbox"})
342		b = &Box{In: inbox, Out: outbox, Shared: sbox}
343		if inbox != "" {
344			db.Exec("insert into xonkers (xid, ibox, obox, sbox, pubkey) values (?, ?, ?, ?, ?)",
345				ident, inbox, outbox, sbox, "")
346		}
347	}
348	boxlock.Lock()
349	boxofboxes[ident] = b
350	boxlock.Unlock()
351	return b, nil
352}
353
354func peeppeep() {
355	user, _ := butwhatabout("htest")
356	honkers := gethonkers(user.ID)
357	for _, f := range honkers {
358		if f.Flavor != "peep" {
359			continue
360		}
361		log.Printf("getting updates: %s", f.XID)
362		box, err := getboxes(f.XID)
363		if err != nil {
364			log.Printf("error getting outbox: %s", err)
365			continue
366		}
367		log.Printf("getting outbox")
368		j, err := GetJunk(box.Out)
369		if err != nil {
370			log.Printf("err: %s", err)
371			continue
372		}
373		t, _ := jsongetstring(j, "type")
374		if t == "OrderedCollection" {
375			items, _ := jsongetarray(j, "orderedItems")
376			if items == nil {
377				page1, _ := jsongetstring(j, "first")
378				j, err = GetJunk(page1)
379				if err != nil {
380					log.Printf("err: %s", err)
381					continue
382				}
383				items, _ = jsongetarray(j, "orderedItems")
384			}
385
386			for _, item := range items {
387				xonk := xonkxonk(user, item)
388				if needxonk(user, xonk) {
389					savexonk(user, xonk)
390				}
391			}
392		}
393	}
394}
395
396func whosthere(xid string) ([]string, string) {
397	obj, err := GetJunk(xid)
398	if err != nil {
399		log.Printf("error getting remote xonk: %s", err)
400		return nil, ""
401	}
402	convoy, _ := jsongetstring(obj, "context")
403	if convoy == "" {
404		convoy, _ = jsongetstring(obj, "conversation")
405	}
406	return newphone(nil, obj), convoy
407}
408
409func newphone(a []string, obj map[string]interface{}) []string {
410	for _, addr := range []string{"to", "cc", "attributedTo"} {
411		who, _ := jsongetstring(obj, addr)
412		if who != "" {
413			a = append(a, who)
414		}
415		whos, _ := jsongetarray(obj, addr)
416		for _, w := range whos {
417			who, _ := w.(string)
418			if who != "" {
419				a = append(a, who)
420			}
421		}
422	}
423	return a
424}
425
426func xonkxonk(user *WhatAbout, item interface{}) *Honk {
427	depth := 0
428	maxdepth := 4
429	var xonkxonkfn func(item interface{}) *Honk
430
431	saveoneup := func(xid string) {
432		log.Printf("getting oneup: %s", xid)
433		if depth >= maxdepth {
434			log.Printf("in too deep")
435			return
436		}
437		obj, err := GetJunk(xid)
438		if err != nil {
439			log.Printf("error getting oneup: %s", err)
440			return
441		}
442		depth++
443		xonk := xonkxonkfn(obj)
444		if needxonk(user, xonk) {
445			xonk.UserID = user.ID
446			savexonk(user, xonk)
447		}
448		depth--
449	}
450
451	xonkxonkfn = func(item interface{}) *Honk {
452		// id, _ := jsongetstring(item, "id")
453		what, _ := jsongetstring(item, "type")
454		dt, _ := jsongetstring(item, "published")
455
456		var audience []string
457		var err error
458		var xid, rid, url, content, convoy string
459		var obj map[string]interface{}
460		var ok bool
461		switch what {
462		case "Announce":
463			xid, ok = jsongetstring(item, "object")
464			if ok {
465				if !needxonkid(user, xid) {
466					return nil
467				}
468				log.Printf("getting bonk: %s", xid)
469				obj, err = GetJunk(xid)
470				if err != nil {
471					log.Printf("error regetting: %s", err)
472				}
473			} else {
474				obj, _ = jsongetmap(item, "object")
475			}
476			what = "bonk"
477		case "Create":
478			obj, _ = jsongetmap(item, "object")
479			what = "honk"
480		case "Note":
481			obj = item.(map[string]interface{})
482			what = "honk"
483		case "Delete":
484			obj, _ = jsongetmap(item, "object")
485			rid, _ = jsongetstring(item, "object")
486			what = "eradicate"
487		default:
488			log.Printf("unknown activity: %s", what)
489			return nil
490		}
491
492		var xonk Honk
493		who, _ := jsongetstring(item, "actor")
494		if obj != nil {
495			if who == "" {
496				who, _ = jsongetstring(obj, "attributedTo")
497			}
498			ot, _ := jsongetstring(obj, "type")
499			url, _ = jsongetstring(obj, "url")
500			if ot == "Note" || ot == "Article" {
501				audience = newphone(audience, obj)
502				xid, _ = jsongetstring(obj, "id")
503				content, _ = jsongetstring(obj, "content")
504				summary, _ := jsongetstring(obj, "summary")
505				if !strings.HasPrefix(content, "<p>") {
506					content = "<p>" + content
507				}
508				if summary != "" {
509					content = "<p>summary: " + summary + content
510				}
511				rid, _ = jsongetstring(obj, "inReplyTo")
512				convoy, _ = jsongetstring(obj, "context")
513				if convoy == "" {
514					convoy, _ = jsongetstring(obj, "conversation")
515				}
516				if what == "honk" && rid != "" {
517					what = "tonk"
518					if needxonkid(user, rid) {
519						saveoneup(rid)
520					}
521				}
522			}
523			if ot == "Tombstone" {
524				rid, _ = jsongetstring(obj, "id")
525			}
526			atts, _ := jsongetarray(obj, "attachment")
527			for _, att := range atts {
528				at, _ := jsongetstring(att, "type")
529				mt, _ := jsongetstring(att, "mediaType")
530				u, _ := jsongetstring(att, "url")
531				name, _ := jsongetstring(att, "name")
532				if at == "Document" {
533					mt = strings.ToLower(mt)
534					log.Printf("attachment: %s %s", mt, u)
535					if mt == "image/jpeg" || mt == "image/png" ||
536						mt == "text/plain" {
537						donk := savedonk(u, name, mt)
538						if donk != nil {
539							xonk.Donks = append(xonk.Donks, donk)
540						}
541					}
542				}
543			}
544			tags, _ := jsongetarray(obj, "tag")
545			for _, tag := range tags {
546				tt, _ := jsongetstring(tag, "type")
547				name, _ := jsongetstring(tag, "name")
548				if tt == "Emoji" {
549					icon, _ := jsongetmap(tag, "icon")
550					mt, _ := jsongetstring(icon, "mediaType")
551					if mt == "" {
552						mt = "image/png"
553					}
554					u, _ := jsongetstring(icon, "url")
555					donk := savedonk(u, name, mt)
556					if donk != nil {
557						xonk.Donks = append(xonk.Donks, donk)
558					}
559				}
560			}
561		}
562		audience = append(audience, who)
563
564		audience = oneofakind(audience)
565
566		xonk.UserID = user.ID
567		xonk.What = what
568		xonk.Honker = who
569		xonk.XID = xid
570		xonk.RID = rid
571		xonk.Date, _ = time.Parse(time.RFC3339, dt)
572		xonk.URL = url
573		xonk.Noise = content
574		xonk.Audience = audience
575		xonk.Convoy = convoy
576
577		return &xonk
578	}
579
580	return xonkxonkfn(item)
581}
582
583func rubadubdub(user *WhatAbout, req map[string]interface{}) {
584	xid, _ := jsongetstring(req, "id")
585	reqactor, _ := jsongetstring(req, "actor")
586	j := NewJunk()
587	j["@context"] = itiswhatitis
588	j["id"] = user.URL + "/dub/" + xid
589	j["type"] = "Accept"
590	j["actor"] = user.URL
591	j["to"] = reqactor
592	j["published"] = time.Now().UTC().Format(time.RFC3339)
593	j["object"] = req
594
595	WriteJunk(os.Stdout, j)
596
597	actor, _ := jsongetstring(req, "actor")
598	box, err := getboxes(actor)
599	if err != nil {
600		log.Printf("can't get dub box: %s", err)
601		return
602	}
603	keyname, key := ziggy(user.Name)
604	err = PostJunk(keyname, key, box.In, j)
605	if err != nil {
606		log.Printf("can't rub a dub: %s", err)
607		return
608	}
609	stmtSaveDub.Exec(user.ID, actor, actor, "dub")
610}
611
612func itakeitallback(user *WhatAbout, xid string) error {
613	j := NewJunk()
614	j["@context"] = itiswhatitis
615	j["id"] = user.URL + "/unsub/" + xid
616	j["type"] = "Undo"
617	j["actor"] = user.URL
618	j["to"] = xid
619	f := NewJunk()
620	f["id"] = user.URL + "/sub/" + xid
621	f["type"] = "Follow"
622	f["actor"] = user.URL
623	f["to"] = xid
624	j["object"] = f
625	j["published"] = time.Now().UTC().Format(time.RFC3339)
626
627	box, err := getboxes(xid)
628	if err != nil {
629		return err
630	}
631	keyname, key := ziggy(user.Name)
632	err = PostJunk(keyname, key, box.In, j)
633	if err != nil {
634		return err
635	}
636	return nil
637}
638
639func subsub(user *WhatAbout, xid string) {
640	j := NewJunk()
641	j["@context"] = itiswhatitis
642	j["id"] = user.URL + "/sub/" + xid
643	j["type"] = "Follow"
644	j["actor"] = user.URL
645	j["to"] = xid
646	j["object"] = xid
647	j["published"] = time.Now().UTC().Format(time.RFC3339)
648
649	box, err := getboxes(xid)
650	if err != nil {
651		log.Printf("can't send follow: %s", err)
652		return
653	}
654	WriteJunk(os.Stdout, j)
655	keyname, key := ziggy(user.Name)
656	err = PostJunk(keyname, key, box.In, j)
657	if err != nil {
658		log.Printf("failed to subsub: %s", err)
659	}
660}
661
662func jonkjonk(user *WhatAbout, h *Honk) (map[string]interface{}, map[string]interface{}) {
663	dt := h.Date.Format(time.RFC3339)
664	var jo map[string]interface{}
665	j := NewJunk()
666	j["id"] = user.URL + "/" + h.What + "/" + h.XID
667	j["actor"] = user.URL
668	j["published"] = dt
669	j["to"] = h.Audience[0]
670	if len(h.Audience) > 1 {
671		j["cc"] = h.Audience[1:]
672	}
673
674	switch h.What {
675	case "zonk":
676		fallthrough
677	case "tonk":
678		fallthrough
679	case "honk":
680		j["type"] = "Create"
681		if h.What == "zonk" {
682			j["type"] = "Delete"
683		}
684
685		jo = NewJunk()
686		jo["id"] = user.URL + "/h/" + h.XID
687		jo["type"] = "Note"
688		if h.What == "zonk" {
689			jo["type"] = "Tombstone"
690		}
691		jo["published"] = dt
692		jo["url"] = user.URL + "/h/" + h.XID
693		jo["attributedTo"] = user.URL
694		if h.RID != "" {
695			jo["inReplyTo"] = h.RID
696		}
697		if h.Convoy != "" {
698			jo["context"] = h.Convoy
699			jo["conversation"] = h.Convoy
700		}
701		jo["to"] = h.Audience[0]
702		if len(h.Audience) > 1 {
703			jo["cc"] = h.Audience[1:]
704		}
705		jo["content"] = mentionize(h.Noise)
706		jo["summary"] = nil
707		var tags []interface{}
708		g := bunchofgrapes(h.Noise)
709		for _, m := range g {
710			t := NewJunk()
711			t["type"] = "Mention"
712			t["name"] = m.who
713			t["href"] = m.where
714			tags = append(tags, t)
715		}
716		herd := herdofemus(h.Noise)
717		for _, e := range herd {
718			t := NewJunk()
719			t["id"] = e.ID
720			t["type"] = "Emoji"
721			t["name"] = e.Name
722			i := NewJunk()
723			i["type"] = "Image"
724			i["mediaType"] = "image/png"
725			i["url"] = e.ID
726			t["icon"] = i
727			tags = append(tags, t)
728		}
729		if len(tags) > 0 {
730			jo["tag"] = tags
731		}
732		var atts []interface{}
733		for _, d := range h.Donks {
734			if re_emus.MatchString(d.Name) {
735				continue
736			}
737			jd := NewJunk()
738			jd["mediaType"] = d.Media
739			jd["name"] = d.Name
740			jd["type"] = "Document"
741			jd["url"] = d.URL
742			atts = append(atts, jd)
743		}
744		if len(atts) > 0 {
745			jo["attachment"] = atts
746		}
747		j["object"] = jo
748	case "bonk":
749		j["type"] = "Announce"
750		j["object"] = h.XID
751	}
752
753	return j, jo
754}
755
756func honkworldwide(user *WhatAbout, honk *Honk) {
757	jonk, _ := jonkjonk(user, honk)
758	jonk["@context"] = itiswhatitis
759	var buf bytes.Buffer
760	WriteJunk(&buf, jonk)
761	msg := buf.Bytes()
762
763	rcpts := make(map[string]bool)
764	for _, a := range honk.Audience {
765		if a != thewholeworld && a != user.URL && !strings.HasSuffix(a, "/followers") {
766			box, _ := getboxes(a)
767			if box != nil && box.Shared != "" {
768				rcpts["%"+box.Shared] = true
769			} else {
770				rcpts[a] = true
771			}
772		}
773	}
774	for _, f := range getdubs(user.ID) {
775		box, _ := getboxes(f.XID)
776		if box != nil && box.Shared != "" {
777			rcpts["%"+box.Shared] = true
778		} else {
779			rcpts[f.XID] = true
780		}
781	}
782	for a := range rcpts {
783		go deliverate(0, user.Name, a, msg)
784	}
785}
786
787func asjonker(user *WhatAbout) map[string]interface{} {
788	about := obfusbreak(user.About)
789
790	j := NewJunk()
791	j["@context"] = itiswhatitis
792	j["id"] = user.URL
793	j["type"] = "Person"
794	j["inbox"] = user.URL + "/inbox"
795	j["outbox"] = user.URL + "/outbox"
796	j["followers"] = user.URL + "/followers"
797	j["following"] = user.URL + "/following"
798	j["name"] = user.Display
799	j["preferredUsername"] = user.Name
800	j["summary"] = about
801	j["url"] = user.URL
802	a := NewJunk()
803	a["type"] = "icon"
804	a["mediaType"] = "image/png"
805	a["url"] = fmt.Sprintf("https://%s/a?a=%s", serverName, url.QueryEscape(user.URL))
806	j["icon"] = a
807	k := NewJunk()
808	k["id"] = user.URL + "#key"
809	k["owner"] = user.URL
810	k["publicKeyPem"] = user.Key
811	j["publicKey"] = k
812
813	return j
814}