Class: Banzai::Filter::InlineMetricsRedactorFilter

Inherits:
HTML::Pipeline::Filter
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
lib/banzai/filter/inline_metrics_redactor_filter.rb

Overview

HTML filter that removes embeded elements that the current user does not have permission to view.

Defined Under Namespace

Classes: Embed, Route

Constant Summary collapse

METRICS_CSS_CLASS =
'.js-render-metrics'
EMBED_LIMIT =
100

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Instance Method Details

#callObject

Finds all embeds based on the css class the FE uses to identify the embedded content, removing only unnecessary nodes.


19
20
21
22
23
24
25
26
27
28
# File 'lib/banzai/filter/inline_metrics_redactor_filter.rb', line 19

def call
  nodes.each do |node|
    embed = embeds_by_node[node]
    user_has_access = user_access_by_embed[embed]

    node.remove unless user_has_access
  end

  doc
end