allow import the most recent honks for a xonker
Ted Unangst tedu@tedunangst.com
Sun, 16 Jun 2019 22:36:52 -0400
2 files changed,
54 insertions(+),
32 deletions(-)
M
activity.go
→
activity.go
@@ -311,6 +311,50 @@ boxlock.Unlock()
return b, nil } +func gimmexonks(user *WhatAbout, outbox string) { + log.Printf("getting outbox: %s", outbox) + j, err := GetJunk(outbox) + if err != nil { + log.Printf("error getting outbox: %s", err) + return + } + t, _ := j.GetString("type") + origin := originate(outbox) + if t == "OrderedCollection" { + items, _ := j.GetArray("orderedItems") + if items == nil { + obj, ok := j.GetMap("first") + if ok { + items, _ = obj.GetArray("orderedItems") + } else { + page1, _ := j.GetString("first") + j, err = GetJunk(page1) + if err != nil { + log.Printf("error gettings page1: %s", err) + return + } + items, _ = j.GetArray("orderedItems") + } + } + if len(items) > 20 { + items = items[0:20] + } + for i, j := 0, len(items)-1; i < j; i, j = i+1, j-1 { + items[i], items[j] = items[j], items[i] + } + for _, item := range items { + obj, ok := item.(junk.Junk) + if !ok { + continue + } + xonk := xonkxonk(user, obj, origin) + if xonk != nil { + savexonk(user, xonk) + } + } + } +} + func peeppeep() { user, _ := butwhatabout("htest") honkers := gethonkers(user.ID)@@ -324,40 +368,9 @@ if err != nil {
log.Printf("error getting outbox: %s", err) continue } - log.Printf("getting outbox") - j, err := GetJunk(box.Out) - if err != nil { - log.Printf("err: %s", err) - continue - } - t, _ := j.GetString("type") - origin := originate(f.XID) - if t == "OrderedCollection" { - items, _ := j.GetArray("orderedItems") - if items == nil { - page1, _ := j.GetString("first") - j, err = GetJunk(page1) - if err != nil { - log.Printf("err: %s", err) - continue - } - items, _ = j.GetArray("orderedItems") - } - - for _, item := range items { - obj, ok := item.(junk.Junk) - if !ok { - continue - } - xonk := xonkxonk(user, obj, origin) - if xonk != nil { - savexonk(user, xonk) - } - } - } + gimmexonks(user, box.Out) } } - func whosthere(xid string) ([]string, string) { obj, err := GetJunk(xid) if err != nil {
M
honk.go
→
honk.go
@@ -372,8 +372,17 @@ if err != nil {
log.Printf("error getting external object: %s", err) return } + log.Printf("importing %s", xid) u := login.GetUserInfo(r) user, _ := butwhatabout(u.Username) + + what, _ := j.GetString("type") + if what == "Person" { + outbox, _ := j.GetString("outbox") + gimmexonks(user, outbox) + http.Redirect(w, r, "/h?xid="+url.QueryEscape(xid), http.StatusSeeOther) + return + } xonk := xonkxonk(user, j, originate(xid)) convoy := "" if xonk != nil {