tidy and simplify some activity parsing
This commit is contained in:
parent
22ea1b382f
commit
46238c0ec4
33
activity.go
33
activity.go
|
@ -482,7 +482,7 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
var xid, rid, url, content, precis, convoy string
|
var xid, rid, url, convoy string
|
||||||
var replies []string
|
var replies []string
|
||||||
var obj junk.Junk
|
var obj junk.Junk
|
||||||
isUpdate := false
|
isUpdate := false
|
||||||
|
@ -659,11 +659,11 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
if dt2, ok := obj.GetString("published"); ok {
|
if dt2, ok := obj.GetString("published"); ok {
|
||||||
dt = dt2
|
dt = dt2
|
||||||
}
|
}
|
||||||
content, _ = obj.GetString("content")
|
content, _ := obj.GetString("content")
|
||||||
if !strings.HasPrefix(content, "<p>") {
|
if !strings.HasPrefix(content, "<p>") {
|
||||||
content = "<p>" + content
|
content = "<p>" + content
|
||||||
}
|
}
|
||||||
precis, _ = obj.GetString("summary")
|
precis, _ := obj.GetString("summary")
|
||||||
if name, ok := obj.GetString("name"); ok {
|
if name, ok := obj.GetString("name"); ok {
|
||||||
if precis != "" {
|
if precis != "" {
|
||||||
content = precis + "<p>" + content
|
content = precis + "<p>" + content
|
||||||
|
@ -715,12 +715,20 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
if what == "honk" && rid != "" {
|
if what == "honk" && rid != "" {
|
||||||
what = "tonk"
|
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
|
numatts := 0
|
||||||
procatt := func(att junk.Junk) {
|
procatt := func(att junk.Junk) {
|
||||||
if rejectxonk(&xonk) {
|
|
||||||
log.Printf("skipping rejected attachment: %s", xid)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
at, _ := att.GetString("type")
|
at, _ := att.GetString("type")
|
||||||
mt, _ := att.GetString("mediaType")
|
mt, _ := att.GetString("mediaType")
|
||||||
u, ok := att.GetString("url")
|
u, ok := att.GetString("url")
|
||||||
|
@ -783,10 +791,6 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
}
|
}
|
||||||
tags, _ := obj.GetArray("tag")
|
tags, _ := obj.GetArray("tag")
|
||||||
for _, tagi := range tags {
|
for _, tagi := range tags {
|
||||||
if rejectxonk(&xonk) {
|
|
||||||
log.Printf("skipping rejected attachment: %s", xid)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
tag, ok := tagi.(junk.Junk)
|
tag, ok := tagi.(junk.Junk)
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
|
@ -884,18 +888,11 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
currenttid = convoy
|
currenttid = convoy
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(content) > 90001 {
|
|
||||||
log.Printf("content too long. truncating")
|
|
||||||
content = content[:90001]
|
|
||||||
}
|
|
||||||
|
|
||||||
// init xonk
|
// init xonk
|
||||||
xonk.What = what
|
xonk.What = what
|
||||||
xonk.RID = rid
|
xonk.RID = rid
|
||||||
xonk.Date, _ = time.Parse(time.RFC3339, dt)
|
xonk.Date, _ = time.Parse(time.RFC3339, dt)
|
||||||
xonk.URL = url
|
xonk.URL = url
|
||||||
xonk.Noise = content
|
|
||||||
xonk.Precis = precis
|
|
||||||
xonk.Format = "html"
|
xonk.Format = "html"
|
||||||
xonk.Convoy = convoy
|
xonk.Convoy = convoy
|
||||||
xonk.Mentions = mentions
|
xonk.Mentions = mentions
|
||||||
|
|
Loading…
Reference in New Issue