diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-08-15 11:09:36 -0500 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-08-15 11:09:36 -0500 |
commit | bbb025be691cb32f56c97ae42e72f40b99c6be9c (patch) | |
tree | d38128bd6fa8bde1ad048098a6cc3fcbd05bfda3 /app/models | |
parent | 5ae918d968bf459b396fc876ae2f4d6fd6eaa964 (diff) |
add ability to search own posts by prepending `me:` to searches
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/status.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/status.rb b/app/models/status.rb index a2d64ecf0..8df4ab100 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -339,9 +339,15 @@ class Status < ApplicationRecord class << self def search_for(term, limit = 33, account = nil) return none if account.nil? + if term.start_with?('me:') + term = term.split(nil, 2)[1] + scope = account.statuses + else + scope = Status + end pattern = sanitize_sql_like(term) pattern = "#{pattern}" - scope = Status.without_reblogs.where("tsv @@ plainto_tsquery('english', ?)", pattern) + scope = scope.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))) |