From caa15f3567ebdf29dc296abe7b1a8c7e0d727c17 Mon Sep 17 00:00:00 2001 From: Justin DiRose Date: Wed, 10 Jun 2020 16:30:30 -0500 Subject: [PATCH] FIX: Do not return restricted tags without access --- lib/knowledge_explorer/query.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/knowledge_explorer/query.rb b/lib/knowledge_explorer/query.rb index eb21386..36644d5 100644 --- a/lib/knowledge_explorer/query.rb +++ b/lib/knowledge_explorer/query.rb @@ -125,6 +125,10 @@ module KnowledgeExplorer end end + allowed_tags = DiscourseTagging.filter_allowed_tags(Guardian.new(@user)).map(&:name) + + tags = tags.select { |tag| allowed_tags.include?(tag[:id]) } + tags.sort_by { |tag| [tag[:active] ? 0 : 1, -tag[:count]] } end