Welcome to mirror list, hosted at ThFree Co, Russian Federation.

isolated_reference_extractor.rb « gitlab « lib « user_mentions « background_migration « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1d3a3af81a17bb4af6e6f660aac7cdf794c6a2e5 (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
# frozen_string_literal: true

module Gitlab
  module BackgroundMigration
    module UserMentions
      module Lib
        module Gitlab
          # Extract possible GFM references from an arbitrary String for further processing.
          class IsolatedReferenceExtractor < ::Gitlab::ReferenceExtractor
            REFERABLES = %i(isolated_mentioned_group).freeze

            REFERABLES.each do |type|
              define_method("#{type}s") do
                @references[type] ||= isolated_references(type)
              end
            end

            def isolated_references(type)
              context = ::Banzai::RenderContext.new(project, current_user)
              processor = ::Gitlab::BackgroundMigration::UserMentions::Lib::Banzai::ReferenceParser[type].new(context)

              refs = processor.process(html_documents)
              refs[:visible]
            end
          end
        end
      end
    end
  end
end