From ff73147e2859e2b1be00b8bc6cfa2ea9daa16a9a Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Mon, 1 Jul 2019 10:43:38 -0400 Subject: [PATCH] some fixes and changes necessary to support peertube links --- activity.go | 32 ++++++++++++++++++++++++++------ docs/changelog.txt | 2 ++ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/activity.go b/activity.go index 60c556d..9857eef 100644 --- a/activity.go +++ b/activity.go @@ -419,6 +419,25 @@ func newphone(a []string, obj junk.Junk) []string { return a } +func extractattrto(obj junk.Junk) string { + who, _ := obj.GetString("attributedTo") + if who != "" { + return who + } + arr, _ := obj.GetArray("attributedTo") + for _, a := range arr { + o, ok := a.(junk.Junk) + if ok { + t, _ := o.GetString("type") + id, _ := o.GetString("id") + if t == "Person" || t == "" { + return id + } + } + } + return "" +} + func consumeactivity(user *WhatAbout, j junk.Junk, origin string) { xonk := xonkxonk(user, j, origin) if xonk != nil { @@ -486,6 +505,8 @@ func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk { obj, _ = item.GetMap("object") xid, _ = item.GetString("object") what = "eradicate" + case "Video": + fallthrough case "Question": fallthrough case "Note": @@ -508,12 +529,14 @@ func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk { who, _ := item.GetString("actor") if obj != nil { if who == "" { - who, _ = obj.GetString("attributedTo") + who = extractattrto(obj) } - oonker, _ = obj.GetString("attributedTo") + oonker = extractattrto(obj) ot, _ := obj.GetString("type") url, _ = obj.GetString("url") - if ot == "Note" || ot == "Article" || ot == "Page" || ot == "Question" { + if ot == "Tombstone" { + xid, _ = obj.GetString("id") + } else { audience = newphone(audience, obj) xid, _ = obj.GetString("id") precis, _ = obj.GetString("summary") @@ -553,9 +576,6 @@ func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk { what = "tonk" } } - if ot == "Tombstone" { - xid, _ = obj.GetString("id") - } atts, _ := obj.GetArray("attachment") for i, atti := range atts { att, ok := atti.(junk.Junk) diff --git a/docs/changelog.txt b/docs/changelog.txt index f329dcd..10fc85f 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -2,6 +2,8 @@ changelog -- next ++ Minimal support for Video activity and PeerTube compat. + + Support for some user selectable styling. Currently, skinny column mode. + webp image transcoding.