summaryrefslogtreecommitdiff
path: root/internal/ap/extract.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-05-23 17:12:46 +0200
committerLibravatar GitHub <noreply@github.com>2022-05-23 16:12:46 +0100
commitf5a4f4321a96afacde920701c1f13125fc20a10c (patch)
tree260d942bb83e502bfa0cc84f80a86d329323e2d4 /internal/ap/extract.go
parent[bugfix] If status URL is empty, use URI instead and don't log unnecessary er... (diff)
downloadgotosocial-f5a4f4321a96afacde920701c1f13125fc20a10c.tar.xz
[bugfix] Fix `error extracting status content: no content found` (#598)
* don't return error if no content found in Activity * add test for content extraction * go fmt
Diffstat (limited to 'internal/ap/extract.go')
-rw-r--r--internal/ap/extract.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/internal/ap/extract.go b/internal/ap/extract.go
index 6f08aeef6..7d980f486 100644
--- a/internal/ap/extract.go
+++ b/internal/ap/extract.go
@@ -335,18 +335,24 @@ func ExtractPublicKeyForOwner(i WithPublicKey, forOwner *url.URL) (*rsa.PublicKe
return nil, nil, errors.New("couldn't find public key")
}
-// ExtractContent returns a string representation of the interface's Content property.
-func ExtractContent(i WithContent) (string, error) {
+// ExtractContent returns a string representation of the interface's Content property,
+// or an empty string if no Content is found.
+func ExtractContent(i WithContent) string {
contentProperty := i.GetActivityStreamsContent()
if contentProperty == nil {
- return "", nil
+ return ""
}
+
for iter := contentProperty.Begin(); iter != contentProperty.End(); iter = iter.Next() {
- if iter.IsXMLSchemaString() && iter.GetXMLSchemaString() != "" {
- return iter.GetXMLSchemaString(), nil
+ if iter.IsXMLSchemaString() {
+ return iter.GetXMLSchemaString()
+ }
+ if iter.IsIRI() && iter.GetIRI() != nil {
+ return iter.GetIRI().String()
}
}
- return "", errors.New("no content found")
+
+ return ""
}
// ExtractAttachments returns a slice of attachments on the interface.