diff --git a/crawler/config.rb b/crawler/config.rb index e21f8622..0ea9b891 100644 --- a/crawler/config.rb +++ b/crawler/config.rb @@ -7,3 +7,4 @@ }.merge(JSON.parse(ENV['CONFIG'])) CONFIG['access_policies'] ||= ['everybody'] +CONFIG['private'] ||= false diff --git a/crawler/types/article.rb b/crawler/types/article.rb index 1a99a50f..a8e138e4 100644 --- a/crawler/types/article.rb +++ b/crawler/types/article.rb @@ -49,7 +49,8 @@ def translation t super(t).merge(selected).merge( category: simple_category, section: simple_section.merge( - full_path: "#{simple_category[:title]} > #{simple_section[:title]}" + full_path: "#{simple_category[:title]} > #{simple_section[:title]}", + access_policy: section.access_policy(complete: CONFIG['private']) ), label_names: tags(t.locale), created_at_iso: @zendesk_obj.created_at.utc.iso8601, diff --git a/crawler/types/section.rb b/crawler/types/section.rb index 5bfe13b9..7113568a 100644 --- a/crawler/types/section.rb +++ b/crawler/types/section.rb @@ -17,15 +17,19 @@ def ignore? t super(t) || !category.exists?(t.locale) || category.ignore?(t) || - !CONFIG['access_policies'].include?(access_policy) + ( + !CONFIG['private'] && + !CONFIG['access_policies'].include?(access_policy) + ) end - protected - - def access_policy - @zendesk_obj.access_policy['access_policy']['viewable_by'] + def access_policy complete: false + res = @zendesk_obj.access_policy['access_policy'] + complete ? res : res['viewable_by'] end + protected + def translation t super(t).merge( category: category.simple(t),