FEATURE: search for all posts by a group

This commit is contained in:
Sam
2015-09-15 17:39:14 +10:00
parent 17d999ab12
commit 6496895096
2 changed files with 20 additions and 0 deletions

View File

@@ -233,6 +233,15 @@ class Search
end
end
advanced_filter(/group:(.+)/) do |posts,match|
group_id = Group.where('name ilike ? OR (id = ? AND id > 0)', match, match.to_i).pluck(:id).first
if group_id
posts.where("posts.user_id IN (select gu.user_id from group_users gu where gu.group_id = ?)", group_id)
else
posts.where("1 = 0")
end
end
advanced_filter(/user:(.+)/) do |posts,match|
user_id = User.where('username_lower = ? OR id = ?', match.downcase, match.to_i).pluck(:id).first
if user_id