gitlab-org--gitlab-foss/lib/banzai/filter/reference_redactor_filter.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

33 lines
669 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module Banzai
module Filter
2015-08-05 02:25:08 +00:00
# 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.
#
class ReferenceRedactorFilter < HTML::Pipeline::Filter
2015-08-05 02:25:08 +00:00
def call
unless context[:skip_redaction]
context = RenderContext.new(project, current_user)
ReferenceRedactor.new(context).redact([doc])
end
2015-08-05 02:25:08 +00:00
doc
end
private
2015-08-05 02:25:08 +00:00
def current_user
context[:current_user]
end
def project
context[:project]
end
2015-08-05 02:25:08 +00:00
end
end
end