Mention fixup (#167)

* rework mention creation a bit

* rework mention creation a bit

* tidy up status dereferencing

* start adding tests for dereferencing

* fixups

* fix

* review changes
This commit is contained in:
tobi 2021-08-29 12:03:08 +02:00 committed by GitHub
commit 53507ac2a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 680 additions and 192 deletions

View file

@ -242,8 +242,9 @@ func ExtractImageURL(i WithImage) (*url.URL, error) {
// ExtractSummary extracts the summary/content warning of an interface.
func ExtractSummary(i WithSummary) (string, error) {
summaryProp := i.GetActivityStreamsSummary()
if summaryProp == nil {
return "", errors.New("summary property was nil")
if summaryProp == nil || summaryProp.Len() == 0 {
// no summary to speak of
return "", nil
}
for iter := summaryProp.Begin(); iter != summaryProp.End(); iter = iter.Next() {
@ -544,12 +545,12 @@ func ExtractMentions(i WithTag) ([]*gtsmodel.Mention, error) {
mentionable, ok := t.(Mentionable)
if !ok {
continue
return nil, errors.New("mention was not convertable to ap.Mentionable")
}
mention, err := ExtractMention(mentionable)
if err != nil {
continue
return nil, err
}
mentions = append(mentions, mention)