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

event_create_service.rb « wiki_pages « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1f613bec00edf48cd9c1d567e9c141abe938241c (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
# frozen_string_literal: true

module WikiPages
  class EventCreateService
    # @param [User] author The event author
    def initialize(author)
      raise ArgumentError, 'author must not be nil' unless author

      @author = author
    end

    def execute(slug, page, action, event_fingerprint)
      wiki_page_meta = WikiPage::Meta.find_or_create(slug, page)

      event = ::EventCreateService.new.wiki_event(wiki_page_meta, author, action, event_fingerprint)

      ServiceResponse.success(payload: { event: event })
    rescue ::EventCreateService::IllegalActionError, ::ActiveRecord::ActiveRecordError => e
      ServiceResponse.error(message: e.message, payload: { error: e })
    end

    private

    attr_reader :author
  end
end