rename some of the text functions for clarity

This commit is contained in:
tobi 2025-03-07 11:40:44 +01:00
commit c8556cfd97
16 changed files with 145 additions and 124 deletions

View file

@ -1376,7 +1376,6 @@ func (c *Converter) baseStatusToFrontend(
InReplyToID: nil, // Set below.
InReplyToAccountID: nil, // Set below.
Sensitive: *s.Sensitive,
SpoilerText: text.HTMLToPlain(s.ContentWarning),
Visibility: c.VisToAPIVis(ctx, s.Visibility),
LocalOnly: s.IsLocalOnly(),
Language: nil, // Set below.
@ -1397,6 +1396,11 @@ func (c *Converter) baseStatusToFrontend(
Text: s.Text,
ContentType: ContentTypeToAPIContentType(s.ContentType),
InteractionPolicy: *apiInteractionPolicy,
// Mastodon API says spoiler_text should be *text*, not HTML, so
// parse any HTML back to plaintext when serializing via the API,
// attempting to preserve semantic intent to keep it readable.
SpoilerText: text.ParseHTMLToPlain(s.ContentWarning),
}
if at := s.EditedAt; !at.IsZero() {

View file

@ -383,7 +383,7 @@ func filterableFields(s *gtsmodel.Status) []string {
// remove markdown-formatting characters
// and ensure more consistent filtering.
if s.Content != "" {
text := text.HTMLToPlain(s.Content)
text := text.ParseHTMLToPlain(s.Content)
if text != "" {
fields = append(fields, text)
}