about summary refs log tree commit diff
path: root/app/models/status.rb
diff options
context:
space:
mode:
authorJenkins <jenkins@jenkins.ninjawedding.org>2018-02-11 04:10:16 +0000
committerJenkins <jenkins@jenkins.ninjawedding.org>2018-02-11 04:10:16 +0000
commitefc9ffcb80b995ef8c8d95ab1d8cb0af8efc094d (patch)
tree6ce57e5980ba0279355f97893d21852caace0232 /app/models/status.rb
parentb6159bcb0a20f3aabfb4d17ad60842b7aa81925c (diff)
parent718802a05dfb3211d758513daf6070ffa22751dd (diff)
Merge remote-tracking branch 'tootsuite/master' into glitchsoc/master
Diffstat (limited to 'app/models/status.rb')
-rw-r--r--app/models/status.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index e927fb9dd..6fb9b15dd 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -32,6 +32,8 @@ class Status < ApplicationRecord
   include Cacheable
   include StatusThreadingConcern
 
+  update_index('statuses#status', :proper) if Chewy.enabled?
+
   enum visibility: [:public, :unlisted, :private, :direct], _suffix: :visibility
 
   belongs_to :application, class_name: 'Doorkeeper::Application', optional: true
@@ -81,6 +83,22 @@ class Status < ApplicationRecord
 
   delegate :domain, to: :account, prefix: true
 
+  def searchable_by(preloaded = nil)
+    ids = [account_id]
+
+    if preloaded.nil?
+      ids += mentions.pluck(:account_id)
+      ids += favourites.pluck(:account_id)
+      ids += reblogs.pluck(:account_id)
+    else
+      ids += preloaded.mentions[id] || []
+      ids += preloaded.favourites[id] || []
+      ids += preloaded.reblogs[id] || []
+    end
+
+    ids.uniq
+  end
+
   def reply?
     !in_reply_to_id.nil? || attributes['reply']
   end