limit post search to own social graph
parent
483f550f9c
commit
0dabcbfb02
|
@ -314,18 +314,15 @@ class Status < ApplicationRecord
|
||||||
after_create :process_bangtags, if: :local?
|
after_create :process_bangtags, if: :local?
|
||||||
|
|
||||||
class << self
|
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 = sanitize_sql_like(term)
|
||||||
pattern = "#{pattern}"
|
pattern = "#{pattern}"
|
||||||
scope = Status.where("tsv @@ plainto_tsquery('english', ?)", pattern)
|
scope = Status.without_reblogs.where("tsv @@ plainto_tsquery('english', ?)", pattern)
|
||||||
query = scope.public_local_visibility
|
query = scope.where(account: account)
|
||||||
if account.present?
|
.or(scope.where(account: account.following, visibility: [:private, :local, :unlisted]))
|
||||||
query = query
|
.or(scope.where(id: account.mentions.select(:status_id)))
|
||||||
.or(scope.where(account: account))
|
.limit(limit)
|
||||||
.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)
|
|
||||||
apply_timeline_filters(query, account, true)
|
apply_timeline_filters(query, account, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue