mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: new search filter - @username
This commit is contained in:
@@ -279,7 +279,7 @@ class Search
|
||||
end
|
||||
end
|
||||
|
||||
advanced_filter(/^\#([a-zA-Z0-9,\-:]+)/) do |posts,match|
|
||||
advanced_filter(/^\#([a-zA-Z0-9\-:]+)/) do |posts,match|
|
||||
slug = match.to_s.split(":")
|
||||
if slug[1]
|
||||
# sub category
|
||||
@@ -315,6 +315,15 @@ class Search
|
||||
end
|
||||
end
|
||||
|
||||
advanced_filter(/^\@([a-zA-Z0-9_\-.]+)/) do |posts,match|
|
||||
user_id = User.where(staged: false).where(username_lower: match.downcase).pluck(:id).first
|
||||
if user_id
|
||||
posts.where("posts.user_id = #{user_id}")
|
||||
else
|
||||
posts.where("1 = 0")
|
||||
end
|
||||
end
|
||||
|
||||
advanced_filter(/before:(.*)/) do |posts,match|
|
||||
if date = Search.word_to_date(match)
|
||||
posts.where("posts.created_at < ?", date)
|
||||
|
||||
Reference in New Issue
Block a user