for image types, prefer the original over attachments
This commit is contained in:
parent
b5470175c7
commit
353a3b27f6
26
activity.go
26
activity.go
|
@ -574,6 +574,7 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
var replies []string
|
var replies []string
|
||||||
var obj junk.Junk
|
var obj junk.Junk
|
||||||
waspage := false
|
waspage := false
|
||||||
|
preferorig := false
|
||||||
switch what {
|
switch what {
|
||||||
case "Delete":
|
case "Delete":
|
||||||
obj, ok = item.GetMap("object")
|
obj, ok = item.GetMap("object")
|
||||||
|
@ -688,6 +689,7 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
case "Audio":
|
case "Audio":
|
||||||
fallthrough
|
fallthrough
|
||||||
case "Image":
|
case "Image":
|
||||||
|
preferorig = true
|
||||||
fallthrough
|
fallthrough
|
||||||
case "Video":
|
case "Video":
|
||||||
fallthrough
|
fallthrough
|
||||||
|
@ -836,6 +838,9 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
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")
|
||||||
|
if !ok {
|
||||||
|
u, ok = att.GetString("href")
|
||||||
|
}
|
||||||
if !ok {
|
if !ok {
|
||||||
if ua, ok := att.GetArray("url"); ok && len(ua) > 0 {
|
if ua, ok := att.GetArray("url"); ok && len(ua) > 0 {
|
||||||
u, ok = ua[0].(string)
|
u, ok = ua[0].(string)
|
||||||
|
@ -863,7 +868,7 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
localize := false
|
localize := false
|
||||||
if numatts > 4 {
|
if numatts > 4 {
|
||||||
ilog.Printf("excessive attachment: %s", at)
|
ilog.Printf("excessive attachment: %s", at)
|
||||||
} else if at == "Document" || at == "Image" {
|
} else if at == "Document" || at == "Image" || (preferorig && at == "Link") {
|
||||||
mt = strings.ToLower(mt)
|
mt = strings.ToLower(mt)
|
||||||
dlog.Printf("attachment: %s %s", mt, u)
|
dlog.Printf("attachment: %s %s", mt, u)
|
||||||
if mt == "text/plain" || mt == "application/pdf" ||
|
if mt == "text/plain" || mt == "application/pdf" ||
|
||||||
|
@ -876,12 +881,30 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
if skipMedia(&xonk) {
|
if skipMedia(&xonk) {
|
||||||
localize = false
|
localize = false
|
||||||
}
|
}
|
||||||
|
if preferorig && !localize {
|
||||||
|
return
|
||||||
|
}
|
||||||
donk := savedonk(u, name, desc, mt, localize)
|
donk := savedonk(u, name, desc, mt, localize)
|
||||||
if donk != nil {
|
if donk != nil {
|
||||||
xonk.Donks = append(xonk.Donks, donk)
|
xonk.Donks = append(xonk.Donks, donk)
|
||||||
}
|
}
|
||||||
numatts++
|
numatts++
|
||||||
}
|
}
|
||||||
|
if preferorig {
|
||||||
|
atts, _ := obj.GetArray("url")
|
||||||
|
for _, atti := range atts {
|
||||||
|
att, ok := atti.(junk.Junk)
|
||||||
|
if !ok {
|
||||||
|
ilog.Printf("attachment that wasn't map?")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
procatt(att)
|
||||||
|
}
|
||||||
|
if numatts == 0 {
|
||||||
|
preferorig = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !preferorig {
|
||||||
atts, _ := obj.GetArray("attachment")
|
atts, _ := obj.GetArray("attachment")
|
||||||
for _, atti := range atts {
|
for _, atti := range atts {
|
||||||
att, ok := atti.(junk.Junk)
|
att, ok := atti.(junk.Junk)
|
||||||
|
@ -894,6 +917,7 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
||||||
if att, ok := obj.GetMap("attachment"); ok {
|
if att, ok := obj.GetMap("attachment"); ok {
|
||||||
procatt(att)
|
procatt(att)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
tags, _ := obj.GetArray("tag")
|
tags, _ := obj.GetArray("tag")
|
||||||
for _, tagi := range tags {
|
for _, tagi := range tags {
|
||||||
tag, ok := tagi.(junk.Junk)
|
tag, ok := tagi.(junk.Junk)
|
||||||
|
|
Loading…
Reference in New Issue