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 == nil {
244 return false
245 }
246 if x.What == "eradicate" {
247 return true
248 }
249 if thoudostbitethythumb(user.ID, x.Audience, x.XID) {
250 log.Printf("not saving thumb biter? %s", x.Honker)
251 return false
252 }
253 return needxonkid(user, x.XID)
254}
255func needxonkid(user *WhatAbout, xid string) bool {
256 if strings.HasPrefix(xid, user.URL+"/h/") {
257 return false
258 }
259 row := stmtFindXonk.QueryRow(user.ID, xid)
260 var id int64
261 err := row.Scan(&id)
262 if err == nil {
263 return false
264 }
265 if err != sql.ErrNoRows {
266 log.Printf("err querying xonk: %s", err)
267 }
268 return true
269}
270
271func savexonk(user *WhatAbout, x *Honk) {
272 if x.What == "eradicate" {
273 log.Printf("eradicating %s by %s", x.RID, x.Honker)
274 _, err := stmtDeleteHonk.Exec(x.RID, x.Honker, user.ID)
275 if err != nil {
276 log.Printf("error eradicating: %s", err)
277 }
278 return
279 }
280 dt := x.Date.UTC().Format(dbtimeformat)
281 aud := strings.Join(x.Audience, " ")
282 whofore := 0
283 if strings.Contains(aud, user.URL) {
284 whofore = 1
285 }
286 res, err := stmtSaveHonk.Exec(x.UserID, x.What, x.Honker, x.XID, x.RID, dt, x.URL, aud,
287 x.Noise, x.Convoy, whofore)
288 if err != nil {
289 log.Printf("err saving xonk: %s", err)
290 return
291 }
292 x.ID, _ = res.LastInsertId()
293 for _, d := range x.Donks {
294 _, err = stmtSaveDonk.Exec(x.ID, d.FileID)
295 if err != nil {
296 log.Printf("err saving donk: %s", err)
297 return
298 }
299 }
300}
301
302type Box struct {
303 In string
304 Out string
305 Shared string
306}
307
308var boxofboxes = make(map[string]*Box)
309var boxlock sync.Mutex
310var boxinglock sync.Mutex
311
312func getboxes(ident string) (*Box, error) {
313 boxlock.Lock()
314 b, ok := boxofboxes[ident]
315 boxlock.Unlock()
316 if ok {
317 return b, nil
318 }
319
320 boxinglock.Lock()
321 defer boxinglock.Unlock()
322
323 boxlock.Lock()
324 b, ok = boxofboxes[ident]
325 boxlock.Unlock()
326 if ok {
327 return b, nil
328 }
329
330 row := stmtGetBoxes.QueryRow(ident)
331 b = &Box{}
332 err := row.Scan(&b.In, &b.Out, &b.Shared)
333 if err != nil {
334 j, err := GetJunk(ident)
335 if err != nil {
336 return nil, err
337 }
338 inbox, _ := jsongetstring(j, "inbox")
339 outbox, _ := jsongetstring(j, "outbox")
340 sbox, _ := jsonfindstring(j, []string{"endpoints", "sharedInbox"})
341 b = &Box{In: inbox, Out: outbox, Shared: sbox}
342 if inbox != "" {
343 _, err = stmtSaveBoxes.Exec(ident, inbox, outbox, sbox, "")
344 if err != nil {
345 log.Printf("error saving boxes: %s", err)
346 }
347 }
348 }
349 boxlock.Lock()
350 boxofboxes[ident] = b
351 boxlock.Unlock()
352 return b, nil
353}
354
355func peeppeep() {
356 user, _ := butwhatabout("htest")
357 honkers := gethonkers(user.ID)
358 for _, f := range honkers {
359 if f.Flavor != "peep" {
360 continue
361 }
362 log.Printf("getting updates: %s", f.XID)
363 box, err := getboxes(f.XID)
364 if err != nil {
365 log.Printf("error getting outbox: %s", err)
366 continue
367 }
368 log.Printf("getting outbox")
369 j, err := GetJunk(box.Out)
370 if err != nil {
371 log.Printf("err: %s", err)
372 continue
373 }
374 t, _ := jsongetstring(j, "type")
375 if t == "OrderedCollection" {
376 items, _ := jsongetarray(j, "orderedItems")
377 if items == nil {
378 page1, _ := jsongetstring(j, "first")
379 j, err = GetJunk(page1)
380 if err != nil {
381 log.Printf("err: %s", err)
382 continue
383 }
384 items, _ = jsongetarray(j, "orderedItems")
385 }
386
387 for _, item := range items {
388 xonk := xonkxonk(user, item)
389 if needxonk(user, xonk) {
390 savexonk(user, xonk)
391 }
392 }
393 }
394 }
395}
396
397func whosthere(xid string) ([]string, string) {
398 obj, err := GetJunk(xid)
399 if err != nil {
400 log.Printf("error getting remote xonk: %s", err)
401 return nil, ""
402 }
403 convoy, _ := jsongetstring(obj, "context")
404 if convoy == "" {
405 convoy, _ = jsongetstring(obj, "conversation")
406 }
407 return newphone(nil, obj), convoy
408}
409
410func newphone(a []string, obj map[string]interface{}) []string {
411 for _, addr := range []string{"to", "cc", "attributedTo"} {
412 who, _ := jsongetstring(obj, addr)
413 if who != "" {
414 a = append(a, who)
415 }
416 whos, _ := jsongetarray(obj, addr)
417 for _, w := range whos {
418 who, _ := w.(string)
419 if who != "" {
420 a = append(a, who)
421 }
422 }
423 }
424 return a
425}
426
427func xonkxonk(user *WhatAbout, item interface{}) *Honk {
428 depth := 0
429 maxdepth := 4
430 var xonkxonkfn func(item interface{}) *Honk
431
432 saveoneup := func(xid string) {
433 log.Printf("getting oneup: %s", xid)
434 if depth >= maxdepth {
435 log.Printf("in too deep")
436 return
437 }
438 obj, err := GetJunk(xid)
439 if err != nil {
440 log.Printf("error getting oneup: %s", err)
441 return
442 }
443 depth++
444 xonk := xonkxonkfn(obj)
445 if needxonk(user, xonk) {
446 xonk.UserID = user.ID
447 savexonk(user, xonk)
448 }
449 depth--
450 }
451
452 xonkxonkfn = func(item interface{}) *Honk {
453 // id, _ := jsongetstring(item, "id")
454 what, _ := jsongetstring(item, "type")
455 dt, _ := jsongetstring(item, "published")
456
457 var audience []string
458 var err error
459 var xid, rid, url, content, convoy string
460 var obj map[string]interface{}
461 var ok bool
462 switch what {
463 case "Announce":
464 xid, ok = jsongetstring(item, "object")
465 if ok {
466 if !needxonkid(user, xid) {
467 return nil
468 }
469 log.Printf("getting bonk: %s", xid)
470 obj, err = GetJunk(xid)
471 if err != nil {
472 log.Printf("error regetting: %s", err)
473 }
474 } else {
475 obj, _ = jsongetmap(item, "object")
476 }
477 what = "bonk"
478 case "Create":
479 obj, _ = jsongetmap(item, "object")
480 what = "honk"
481 case "Note":
482 obj = item.(map[string]interface{})
483 what = "honk"
484 case "Delete":
485 obj, _ = jsongetmap(item, "object")
486 rid, _ = jsongetstring(item, "object")
487 what = "eradicate"
488 default:
489 log.Printf("unknown activity: %s", what)
490 return nil
491 }
492
493 var xonk Honk
494 who, _ := jsongetstring(item, "actor")
495 if obj != nil {
496 if who == "" {
497 who, _ = jsongetstring(obj, "attributedTo")
498 }
499 ot, _ := jsongetstring(obj, "type")
500 url, _ = jsongetstring(obj, "url")
501 if ot == "Note" || ot == "Article" {
502 audience = newphone(audience, obj)
503 xid, _ = jsongetstring(obj, "id")
504 content, _ = jsongetstring(obj, "content")
505 summary, _ := jsongetstring(obj, "summary")
506 if !strings.HasPrefix(content, "<p>") {
507 content = "<p>" + content
508 }
509 if summary != "" {
510 content = "<p>summary: " + summary + content
511 }
512 rid, _ = jsongetstring(obj, "inReplyTo")
513 convoy, _ = jsongetstring(obj, "context")
514 if convoy == "" {
515 convoy, _ = jsongetstring(obj, "conversation")
516 }
517 if what == "honk" && rid != "" {
518 what = "tonk"
519 if needxonkid(user, rid) {
520 saveoneup(rid)
521 }
522 }
523 }
524 if ot == "Tombstone" {
525 rid, _ = jsongetstring(obj, "id")
526 }
527 atts, _ := jsongetarray(obj, "attachment")
528 for _, att := range atts {
529 at, _ := jsongetstring(att, "type")
530 mt, _ := jsongetstring(att, "mediaType")
531 u, _ := jsongetstring(att, "url")
532 name, _ := jsongetstring(att, "name")
533 if at == "Document" {
534 mt = strings.ToLower(mt)
535 log.Printf("attachment: %s %s", mt, u)
536 if mt == "image/jpeg" || mt == "image/png" ||
537 mt == "text/plain" {
538 donk := savedonk(u, name, mt)
539 if donk != nil {
540 xonk.Donks = append(xonk.Donks, donk)
541 }
542 } else {
543 u = html.EscapeString(u)
544 content += fmt.Sprintf(
545 `<p>External attachment: <a href="%s" rel=noreferrer>%s</a>`, u, u)
546 }
547 } else {
548 log.Printf("unknown attachment: %s", at)
549 }
550 }
551 tags, _ := jsongetarray(obj, "tag")
552 for _, tag := range tags {
553 tt, _ := jsongetstring(tag, "type")
554 name, _ := jsongetstring(tag, "name")
555 if tt == "Emoji" {
556 icon, _ := jsongetmap(tag, "icon")
557 mt, _ := jsongetstring(icon, "mediaType")
558 if mt == "" {
559 mt = "image/png"
560 }
561 u, _ := jsongetstring(icon, "url")
562 donk := savedonk(u, name, mt)
563 if donk != nil {
564 xonk.Donks = append(xonk.Donks, donk)
565 }
566 }
567 }
568 }
569 audience = append(audience, who)
570
571 audience = oneofakind(audience)
572
573 xonk.UserID = user.ID
574 xonk.What = what
575 xonk.Honker = who
576 xonk.XID = xid
577 xonk.RID = rid
578 xonk.Date, _ = time.Parse(time.RFC3339, dt)
579 xonk.URL = url
580 xonk.Noise = content
581 xonk.Audience = audience
582 xonk.Convoy = convoy
583
584 return &xonk
585 }
586
587 return xonkxonkfn(item)
588}
589
590func rubadubdub(user *WhatAbout, req map[string]interface{}) {
591 xid, _ := jsongetstring(req, "id")
592 reqactor, _ := jsongetstring(req, "actor")
593 j := NewJunk()
594 j["@context"] = itiswhatitis
595 j["id"] = user.URL + "/dub/" + xid
596 j["type"] = "Accept"
597 j["actor"] = user.URL
598 j["to"] = reqactor
599 j["published"] = time.Now().UTC().Format(time.RFC3339)
600 j["object"] = req
601
602 WriteJunk(os.Stdout, j)
603
604 actor, _ := jsongetstring(req, "actor")
605 box, err := getboxes(actor)
606 if err != nil {
607 log.Printf("can't get dub box: %s", err)
608 return
609 }
610 keyname, key := ziggy(user.Name)
611 err = PostJunk(keyname, key, box.In, j)
612 if err != nil {
613 log.Printf("can't rub a dub: %s", err)
614 return
615 }
616 stmtSaveDub.Exec(user.ID, actor, actor, "dub")
617}
618
619func itakeitallback(user *WhatAbout, xid string) error {
620 j := NewJunk()
621 j["@context"] = itiswhatitis
622 j["id"] = user.URL + "/unsub/" + xid
623 j["type"] = "Undo"
624 j["actor"] = user.URL
625 j["to"] = xid
626 f := NewJunk()
627 f["id"] = user.URL + "/sub/" + xid
628 f["type"] = "Follow"
629 f["actor"] = user.URL
630 f["to"] = xid
631 j["object"] = f
632 j["published"] = time.Now().UTC().Format(time.RFC3339)
633
634 box, err := getboxes(xid)
635 if err != nil {
636 return err
637 }
638 keyname, key := ziggy(user.Name)
639 err = PostJunk(keyname, key, box.In, j)
640 if err != nil {
641 return err
642 }
643 return nil
644}
645
646func subsub(user *WhatAbout, xid string) {
647 j := NewJunk()
648 j["@context"] = itiswhatitis
649 j["id"] = user.URL + "/sub/" + xid
650 j["type"] = "Follow"
651 j["actor"] = user.URL
652 j["to"] = xid
653 j["object"] = xid
654 j["published"] = time.Now().UTC().Format(time.RFC3339)
655
656 box, err := getboxes(xid)
657 if err != nil {
658 log.Printf("can't send follow: %s", err)
659 return
660 }
661 WriteJunk(os.Stdout, j)
662 keyname, key := ziggy(user.Name)
663 err = PostJunk(keyname, key, box.In, j)
664 if err != nil {
665 log.Printf("failed to subsub: %s", err)
666 }
667}
668
669func jonkjonk(user *WhatAbout, h *Honk) (map[string]interface{}, map[string]interface{}) {
670 dt := h.Date.Format(time.RFC3339)
671 var jo map[string]interface{}
672 j := NewJunk()
673 j["id"] = user.URL + "/" + h.What + "/" + h.XID
674 j["actor"] = user.URL
675 j["published"] = dt
676 j["to"] = h.Audience[0]
677 if len(h.Audience) > 1 {
678 j["cc"] = h.Audience[1:]
679 }
680
681 switch h.What {
682 case "zonk":
683 fallthrough
684 case "tonk":
685 fallthrough
686 case "honk":
687 j["type"] = "Create"
688 if h.What == "zonk" {
689 j["type"] = "Delete"
690 }
691
692 jo = NewJunk()
693 jo["id"] = user.URL + "/h/" + h.XID
694 jo["type"] = "Note"
695 if h.What == "zonk" {
696 jo["type"] = "Tombstone"
697 }
698 jo["published"] = dt
699 jo["url"] = user.URL + "/h/" + h.XID
700 jo["attributedTo"] = user.URL
701 if h.RID != "" {
702 jo["inReplyTo"] = h.RID
703 }
704 if h.Convoy != "" {
705 jo["context"] = h.Convoy
706 jo["conversation"] = h.Convoy
707 }
708 jo["to"] = h.Audience[0]
709 if len(h.Audience) > 1 {
710 jo["cc"] = h.Audience[1:]
711 }
712 jo["content"] = mentionize(h.Noise)
713 jo["summary"] = nil
714 var tags []interface{}
715 g := bunchofgrapes(h.Noise)
716 for _, m := range g {
717 t := NewJunk()
718 t["type"] = "Mention"
719 t["name"] = m.who
720 t["href"] = m.where
721 tags = append(tags, t)
722 }
723 herd := herdofemus(h.Noise)
724 for _, e := range herd {
725 t := NewJunk()
726 t["id"] = e.ID
727 t["type"] = "Emoji"
728 t["name"] = e.Name
729 i := NewJunk()
730 i["type"] = "Image"
731 i["mediaType"] = "image/png"
732 i["url"] = e.ID
733 t["icon"] = i
734 tags = append(tags, t)
735 }
736 if len(tags) > 0 {
737 jo["tag"] = tags
738 }
739 var atts []interface{}
740 for _, d := range h.Donks {
741 if re_emus.MatchString(d.Name) {
742 continue
743 }
744 jd := NewJunk()
745 jd["mediaType"] = d.Media
746 jd["name"] = d.Name
747 jd["type"] = "Document"
748 jd["url"] = d.URL
749 atts = append(atts, jd)
750 }
751 if len(atts) > 0 {
752 jo["attachment"] = atts
753 }
754 j["object"] = jo
755 case "bonk":
756 j["type"] = "Announce"
757 j["object"] = h.XID
758 }
759
760 return j, jo
761}
762
763func honkworldwide(user *WhatAbout, honk *Honk) {
764 jonk, _ := jonkjonk(user, honk)
765 jonk["@context"] = itiswhatitis
766 var buf bytes.Buffer
767 WriteJunk(&buf, jonk)
768 msg := buf.Bytes()
769
770 rcpts := make(map[string]bool)
771 for _, a := range honk.Audience {
772 if a != thewholeworld && a != user.URL && !strings.HasSuffix(a, "/followers") {
773 box, _ := getboxes(a)
774 if box != nil && box.Shared != "" {
775 rcpts["%"+box.Shared] = true
776 } else {
777 rcpts[a] = true
778 }
779 }
780 }
781 for _, f := range getdubs(user.ID) {
782 box, _ := getboxes(f.XID)
783 if box != nil && box.Shared != "" {
784 rcpts["%"+box.Shared] = true
785 } else {
786 rcpts[f.XID] = true
787 }
788 }
789 for a := range rcpts {
790 go deliverate(0, user.Name, a, msg)
791 }
792}
793
794func asjonker(user *WhatAbout) map[string]interface{} {
795 about := obfusbreak(user.About)
796
797 j := NewJunk()
798 j["@context"] = itiswhatitis
799 j["id"] = user.URL
800 j["type"] = "Person"
801 j["inbox"] = user.URL + "/inbox"
802 j["outbox"] = user.URL + "/outbox"
803 j["followers"] = user.URL + "/followers"
804 j["following"] = user.URL + "/following"
805 j["name"] = user.Display
806 j["preferredUsername"] = user.Name
807 j["summary"] = about
808 j["url"] = user.URL
809 a := NewJunk()
810 a["type"] = "icon"
811 a["mediaType"] = "image/png"
812 a["url"] = fmt.Sprintf("https://%s/a?a=%s", serverName, url.QueryEscape(user.URL))
813 j["icon"] = a
814 k := NewJunk()
815 k["id"] = user.URL + "#key"
816 k["owner"] = user.URL
817 k["publicKeyPem"] = user.Key
818 j["publicKey"] = k
819
820 return j
821}