mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-28 21:02:24 -05:00
[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
This commit is contained in:
parent
a09e101931
commit
f5a4f4321a
4 changed files with 59 additions and 11 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue