From bbb025be691cb32f56c97ae42e72f40b99c6be9c Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Thu, 15 Aug 2019 11:09:36 -0500 Subject: [PATCH] add ability to search own posts by prepending `me:` to searches --- app/models/status.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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)))