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

33 lines
651 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.
#
class RedactorFilter < HTML::Pipeline::Filter
def call
2018-05-09 12:01:36 +05:30
unless context[:skip_redaction]
context = RenderContext.new(project, current_user)
Redactor.new(context).redact([doc])
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