From 0dabcbfb02c09e7ece04b4aec822f152164ae67f Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Sat, 20 Jul 2019 21:06:49 -0500 Subject: [PATCH] limit post search to own social graph --- app/models/status.rb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/app/models/status.rb b/app/models/status.rb index e9aa55eab..ec492293f 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -314,18 +314,15 @@ class Status < ApplicationRecord after_create :process_bangtags, if: :local? class << self - def search_for(term, limit = 66, account = nil) + def search_for(term, limit = 33, account = nil) + return none if account.nil? pattern = sanitize_sql_like(term) pattern = "#{pattern}" - scope = Status.where("tsv @@ plainto_tsquery('english', ?)", pattern) - query = scope.public_local_visibility - if account.present? - query = query - .or(scope.where(account: account)) - .or(scope.where(account: account.following, visibility: [:private, :unlisted])) - .or(scope.where(id: account.mentions.select(:status_id))) - end - query = query.where(reblog_of_id: nil).limit(limit) + scope = Status.without_reblogs.where("tsv @@ plainto_tsquery('english', ?)", pattern) + query = scope.where(account: account) + .or(scope.where(account: account.following, visibility: [:private, :local, :unlisted])) + .or(scope.where(id: account.mentions.select(:status_id))) + .limit(limit) apply_timeline_filters(query, account, true) end