diff options
author | ThibG <thib@sitedethib.com> | 2019-06-25 14:45:14 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2019-06-25 14:45:14 +0200 |
commit | 47ef4a6c7a74072daff8b23c4af3e300bb75ba1a (patch) | |
tree | afa97381a3bc8bd5e5c910d873dddc3fa3b2ff4e /app | |
parent | 66ac1bd063882f5a2f828c1c702089e37f36f217 (diff) |
Apply filters to poll options (#11174)
* Apply filters to poll options in WebUI Fixes #11128 * Apply filters to poll options server-side * Add poll options to searchable text
Diffstat (limited to 'app')
-rw-r--r-- | app/chewy/statuses_index.rb | 2 | ||||
-rw-r--r-- | app/javascript/mastodon/actions/importer/normalizer.js | 2 | ||||
-rw-r--r-- | app/lib/feed_manager.rb | 3 |
3 files changed, 4 insertions, 3 deletions
diff --git a/app/chewy/statuses_index.rb b/app/chewy/statuses_index.rb index 8ce413f8a..f5983a5a5 100644 --- a/app/chewy/statuses_index.rb +++ b/app/chewy/statuses_index.rb @@ -51,7 +51,7 @@ class StatusesIndex < Chewy::Index field :id, type: 'long' field :account_id, type: 'long' - field :text, type: 'text', value: ->(status) { [status.spoiler_text, Formatter.instance.plaintext(status)].concat(status.media_attachments.map(&:description)).join("\n\n") } do + field :text, type: 'text', value: ->(status) { [status.spoiler_text, Formatter.instance.plaintext(status)].concat(status.media_attachments.map(&:description)).concat(status.preloadable_poll ? status_preloadable_poll.options : []).join("\n\n") } do field :stemmed, type: 'text', analyzer: 'content' end diff --git a/app/javascript/mastodon/actions/importer/normalizer.js b/app/javascript/mastodon/actions/importer/normalizer.js index 5badb0c49..b250ee076 100644 --- a/app/javascript/mastodon/actions/importer/normalizer.js +++ b/app/javascript/mastodon/actions/importer/normalizer.js @@ -56,7 +56,7 @@ export function normalizeStatus(status, normalOldStatus) { normalStatus.hidden = normalOldStatus.get('hidden'); } else { const spoilerText = normalStatus.spoiler_text || ''; - const searchContent = [spoilerText, status.content].join('\n\n').replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n'); + const searchContent = ([spoilerText, status.content].concat((status.poll && status.poll.options) ? status.poll.options.map(option => option.title) : [])).join('\n\n').replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n'); const emojiMap = makeEmojiMap(normalStatus); normalStatus.search_index = domParser.parseFromString(searchContent, 'text/html').documentElement.textContent; diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb index d77cdb3a3..ed3ce6112 100644 --- a/app/lib/feed_manager.rb +++ b/app/lib/feed_manager.rb @@ -220,7 +220,8 @@ class FeedManager status = status.reblog if status.reblog? !combined_regex.match(Formatter.instance.plaintext(status)).nil? || - (status.spoiler_text.present? && !combined_regex.match(status.spoiler_text).nil?) + (status.spoiler_text.present? && !combined_regex.match(status.spoiler_text).nil?) || + (status.preloadable_poll && !combined_regex.match(status.preloadable_poll.options.join("\n\n")).nil?) end # Adds a status to an account's feed, returning true if a status was |