diff options
| author | 2025-07-01 16:00:04 +0200 | |
|---|---|---|
| committer | 2025-07-01 16:00:04 +0200 | |
| commit | 4f2aa792b33fdd5fb4b22dec813b3668d7190522 (patch) | |
| tree | 1148a9322d04bf43c1c159df3079fb1790c5c154 /internal/typeutils/util.go | |
| parent | [chore] update go dependencies (#4304) (diff) | |
| download | gotosocial-4f2aa792b33fdd5fb4b22dec813b3668d7190522.tar.xz | |
[performance] add statusfilter cache to cache calculated status filtering results (#4303)
this adds another 'filter' type cache, similar to the visibility and mute caches, to cache the results of status filtering checks. for the moment this keeps all the check calls themselves within the frontend typeconversion code, but i may move this out of the typeconverter in a future PR (also removing the ErrHideStatus means of propagating a hidden status).
also tweaks some of the cache invalidation hooks to not make unnecessary calls.
Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4303
Co-authored-by: kim <grufwub@gmail.com>
Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/typeutils/util.go')
| -rw-r--r-- | internal/typeutils/util.go | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/internal/typeutils/util.go b/internal/typeutils/util.go index 2a0293f65..ecd2cecb0 100644 --- a/internal/typeutils/util.go +++ b/internal/typeutils/util.go @@ -350,60 +350,3 @@ func ContentToContentLanguage( return contentStr, langTagStr } - -// filterableFields returns text fields from -// a status that we might want to filter on: -// -// - content warning -// - content (converted to plaintext from HTML) -// - media descriptions -// - poll options -// -// Each field should be filtered separately. -// This avoids scenarios where false-positive -// multiple-word matches can be made by matching -// the last word of one field + the first word -// of the next field together. -func filterableFields(s *gtsmodel.Status) []string { - // Estimate length of fields. - fieldCount := 2 + len(s.Attachments) - if s.Poll != nil { - fieldCount += len(s.Poll.Options) - } - fields := make([]string, 0, fieldCount) - - // Content warning / title. - if s.ContentWarning != "" { - fields = append(fields, s.ContentWarning) - } - - // Status content. Though we have raw text - // available for statuses created on our - // instance, use the plaintext version to - // remove markdown-formatting characters - // and ensure more consistent filtering. - if s.Content != "" { - text := text.ParseHTMLToPlain(s.Content) - if text != "" { - fields = append(fields, text) - } - } - - // Media descriptions. - for _, attachment := range s.Attachments { - if attachment.Description != "" { - fields = append(fields, attachment.Description) - } - } - - // Poll options. - if s.Poll != nil { - for _, opt := range s.Poll.Options { - if opt != "" { - fields = append(fields, opt) - } - } - } - - return fields -} |
