blob: 9fae46a24a96a65e7ad74eed35de67d387d3a7db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# frozen_string_literal: true
module Banzai
module Filter
# 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
def call
unless context[:skip_redaction]
redactor_context = RenderContext.new(project, current_user)
ReferenceRedactor.new(redactor_context).redact([doc])
end
doc
end
private
def current_user
context[:current_user]
end
def project
context[:project]
end
end
end
end
|