all repos — honk @ 84ca26f386e4216a3689b2e1a019b1e0389c3e4a

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