debian-mirror-gitlab/lib/banzai/filter/reference_redactor_filter.rb

33 lines
669 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2015-12-23 02:04:40 +05:30
module Banzai
module Filter
2015-10-24 18:46:33 +05:30
# HTML filter that removes references to records that the current user does
# not have permission to view.
#
# Expected to be run in its own post-processing pipeline.
#
2019-09-30 21:07:59 +05:30
class ReferenceRedactorFilter < HTML::Pipeline::Filter
2015-10-24 18:46:33 +05:30
def call
2018-05-09 12:01:36 +05:30
unless context[:skip_redaction]
context = RenderContext.new(project, current_user)
2019-09-30 21:07:59 +05:30
ReferenceRedactor.new(context).redact([doc])
2018-05-09 12:01:36 +05:30
end
2015-10-24 18:46:33 +05:30
doc
end
private
def current_user
context[:current_user]
end
def project
context[:project]
end
2015-10-24 18:46:33 +05:30
end
end
end