about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-03-31 10:36:23 +0200
committerClaire <claire.github-309c@sitedethib.com>2022-03-31 10:36:23 +0200
commit6bdec0aec967c5c64e46136f73666c4a67d5a641 (patch)
treef64333019509573bec9799648217d8aa22fca166 /app
parent363773d0e9ffa9f4efc564603327f225193a2bf1 (diff)
parentef196c913c77338be5ebb1e02af2f6225f857080 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'app')
-rw-r--r--app/chewy/statuses_index.rb2
-rw-r--r--app/helpers/formatting_helper.rb1
-rw-r--r--app/lib/feed_manager.rb11
-rw-r--r--app/models/status.rb9
4 files changed, 12 insertions, 11 deletions
diff --git a/app/chewy/statuses_index.rb b/app/chewy/statuses_index.rb
index bfd61a048..1381a96ed 100644
--- a/app/chewy/statuses_index.rb
+++ b/app/chewy/statuses_index.rb
@@ -59,7 +59,7 @@ class StatusesIndex < Chewy::Index
     field :id, type: 'long'
     field :account_id, type: 'long'
 
-    field :text, type: 'text', value: ->(status) { [status.spoiler_text, extract_status_plain_text(status)].concat(status.ordered_media_attachments.map(&:description)).concat(status.preloadable_poll ? status.preloadable_poll.options : []).join("\n\n") } do
+    field :text, type: 'text', value: ->(status) { status.searchable_text } do
       field :stemmed, type: 'text', analyzer: 'content'
     end
 
diff --git a/app/helpers/formatting_helper.rb b/app/helpers/formatting_helper.rb
index 2a622ae0b..53e100dd2 100644
--- a/app/helpers/formatting_helper.rb
+++ b/app/helpers/formatting_helper.rb
@@ -12,6 +12,7 @@ module FormattingHelper
   def extract_status_plain_text(status)
     PlainTextFormatter.new(status.text, status.local?).to_s
   end
+  module_function :extract_status_plain_text
 
   def status_content_format(status)
     html_aware_format(status.text, status.local?, preloaded_accounts: [status.account] + (status.respond_to?(:active_mentions) ? status.active_mentions.map(&:account) : []), content_type: status.content_type)
diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb
index 6994f00ae..02ecb403d 100644
--- a/app/lib/feed_manager.rb
+++ b/app/lib/feed_manager.rb
@@ -5,7 +5,6 @@ require 'singleton'
 class FeedManager
   include Singleton
   include Redisable
-  include FormattingHelper
 
   # Maximum number of items stored in a single feed
   MAX_ITEMS = 400
@@ -501,16 +500,8 @@ class FeedManager
     return false if active_filters.empty?
 
     combined_regex = Regexp.union(active_filters)
-    status         = status.reblog if status.reblog?
 
-    combined_text = [
-      extract_status_plain_text(status),
-      status.spoiler_text,
-      status.preloadable_poll ? status.preloadable_poll.options.join("\n\n") : nil,
-      status.ordered_media_attachments.map(&:description).join("\n\n"),
-    ].compact.join("\n\n")
-
-    combined_regex.match?(combined_text)
+    combined_regex.match?(status.proper.searchable_text)
   end
 
   # Adds a status to an account's feed, returning true if a status was
diff --git a/app/models/status.rb b/app/models/status.rb
index 62f9e5831..9eaf85668 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -160,6 +160,15 @@ class Status < ApplicationRecord
     ids.uniq
   end
 
+  def searchable_text
+    [
+      spoiler_text,
+      FormattingHelper.extract_status_plain_text(self),
+      preloadable_poll ? preloadable_poll.options.join("\n\n") : nil,
+      ordered_media_attachments.map(&:description).join("\n\n"),
+    ].compact.join("\n\n")
+  end
+
   def reply?
     !in_reply_to_id.nil? || attributes['reply']
   end