summaryrefslogtreecommitdiff
path: root/internal/typeutils/astointernal.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-11-21 15:13:30 +0100
committerLibravatar GitHub <noreply@github.com>2023-11-21 15:13:30 +0100
commitcfefbc08d822cd85787d95dc2ee253e3368826d8 (patch)
treeaf6d6257dddca1645ab5f8e34a1c79ac80d82e0e /internal/typeutils/astointernal.go
parent[docs] Annotate split-domain setup (#2372) (diff)
downloadgotosocial-cfefbc08d822cd85787d95dc2ee253e3368826d8.tar.xz
[feature] Federate status language in and out (#2366)
* [feature] Federate status language in + out * go fmt * tests, little fix * improve comments * unnest a bit * avoid unnecessary nil check * use more descriptive variable for contentMap * prefer instance languages when selecting from contentMap * update docs to reflect lang selection * rename rdfLangString -> rdfLangs * update comments to mention Pollable * iter through slice instead of map
Diffstat (limited to 'internal/typeutils/astointernal.go')
-rw-r--r--internal/typeutils/astointernal.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/internal/typeutils/astointernal.go b/internal/typeutils/astointernal.go
index 707f51629..c7908ad24 100644
--- a/internal/typeutils/astointernal.go
+++ b/internal/typeutils/astointernal.go
@@ -244,9 +244,15 @@ func (c *Converter) ASStatusToStatus(ctx context.Context, statusable ap.Statusab
}
// status.Content
+ // status.Language
//
- // The (html-formatted) content of this status.
- status.Content = ap.ExtractContent(statusable)
+ // Many implementations set both content
+ // and contentMap; we can use these to
+ // infer the language of the status.
+ status.Content, status.Language = ContentToContentLanguage(
+ ctx,
+ ap.ExtractContent(statusable),
+ )
// status.Attachments
//
@@ -396,9 +402,6 @@ func (c *Converter) ASStatusToStatus(ctx context.Context, statusable ap.Statusab
return &s
}()
- // language
- // TODO: we might be able to extract this from the contentMap field
-
// ActivityStreamsType
status.ActivityStreamsType = statusable.GetTypeName()
@@ -707,7 +710,7 @@ func (c *Converter) ASFlagToReport(ctx context.Context, flaggable ap.Flaggable)
// For Mastodon, this will just be a string, or nothing.
// In Misskey's case, it may also contain the URLs of
// one or more reported statuses, so extract these too.
- content := ap.ExtractContent(flaggable)
+ content := ap.ExtractContent(flaggable).Content
statusURIs := []*url.URL{}
inlineURLs := misskeyReportInlineURLs(content)
statusURIs = append(statusURIs, inlineURLs...)