2022-02-07 06:40:52 +01:00
|
|
|
# frozen_string_literal: true
|
2022-02-09 00:30:46 +01:00
|
|
|
require 'request_store'
|
2022-02-07 06:40:52 +01:00
|
|
|
|
|
|
|
module CustomWizardDiscourseTagging
|
|
|
|
def filter_allowed_tags(guardian, opts = {})
|
2022-02-09 00:30:46 +01:00
|
|
|
if tag_groups = ::RequestStore.store[:tag_groups]
|
2022-02-07 06:40:52 +01:00
|
|
|
tag_group_array = tag_groups.split(",")
|
|
|
|
filtered_tags = TagGroup.includes(:tags).where(name: tag_group_array).map do |tag_group|
|
|
|
|
tag_group.tags.pluck(:name)
|
|
|
|
end.flatten
|
|
|
|
|
|
|
|
opts[:only_tag_names] ||= []
|
|
|
|
opts[:only_tag_names].push(*filtered_tags)
|
|
|
|
end
|
|
|
|
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|