all repos — honk @ ac167b30239ac26f1d79c0d3a22ebb32db88f926

my fork of honk

tidy and simplify some activity parsing
Ted Unangst tedu@tedunangst.com
Fri, 22 May 2020 00:15:48 -0400
commit

ac167b30239ac26f1d79c0d3a22ebb32db88f926

parent

039b5dbdb41f685ae90055093b9d8ce2a3ff2283

1 files changed, 15 insertions(+), 18 deletions(-)

jump to
M activity.goactivity.go

@@ -482,7 +482,7 @@ dt = time.Now().Format(time.RFC3339)

} var err error - var xid, rid, url, content, precis, convoy string + var xid, rid, url, convoy string var replies []string var obj junk.Junk isUpdate := false

@@ -659,11 +659,11 @@ url, _ = obj.GetString("url")

if dt2, ok := obj.GetString("published"); ok { dt = dt2 } - content, _ = obj.GetString("content") + content, _ := obj.GetString("content") if !strings.HasPrefix(content, "<p>") { content = "<p>" + content } - precis, _ = obj.GetString("summary") + precis, _ := obj.GetString("summary") if name, ok := obj.GetString("name"); ok { if precis != "" { content = precis + "<p>" + content

@@ -715,12 +715,20 @@ }

if what == "honk" && rid != "" { what = "tonk" } + if len(content) > 90001 { + log.Printf("content too long. truncating") + content = content[:90001] + } + + xonk.Noise = content + xonk.Precis = precis + if rejectxonk(&xonk) { + log.Printf("fast reject: %s", xid) + return nil + } + numatts := 0 procatt := func(att junk.Junk) { - if rejectxonk(&xonk) { - log.Printf("skipping rejected attachment: %s", xid) - return - } at, _ := att.GetString("type") mt, _ := att.GetString("mediaType") u, ok := att.GetString("url")

@@ -783,10 +791,6 @@ procatt(att)

} tags, _ := obj.GetArray("tag") for _, tagi := range tags { - if rejectxonk(&xonk) { - log.Printf("skipping rejected attachment: %s", xid) - continue - } tag, ok := tagi.(junk.Junk) if !ok { continue

@@ -884,18 +888,11 @@ if currenttid == "" {

currenttid = convoy } - if len(content) > 90001 { - log.Printf("content too long. truncating") - content = content[:90001] - } - // init xonk xonk.What = what xonk.RID = rid xonk.Date, _ = time.Parse(time.RFC3339, dt) xonk.URL = url - xonk.Noise = content - xonk.Precis = precis xonk.Format = "html" xonk.Convoy = convoy xonk.Mentions = mentions