summaryrefslogtreecommitdiff
path: root/app/models/project_services/external_wiki_service.rb
blob: bf9b175978898919b41e9cf1474284c205c5f6d7 (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
33
34
35
36
# frozen_string_literal: true

class ExternalWikiService < Service
  prop_accessor :external_wiki_url

  validates :external_wiki_url, presence: true, public_url: true, if: :activated?

  def title
    'External Wiki'
  end

  def description
    _('Replaces the link to the internal wiki with a link to an external wiki.')
  end

  def self.to_param
    'external_wiki'
  end

  def fields
    [
      { type: 'text', name: 'external_wiki_url', placeholder: 'The URL of the external Wiki', required: true }
    ]
  end

  def execute(_data)
    @response = Gitlab::HTTP.get(properties['external_wiki_url'], verify: true) rescue nil
    if @response != 200
      nil
    end
  end

  def self.supported_events
    %w()
  end
end