summaryrefslogtreecommitdiff
path: root/app/services/mattermost/commands/issue_create_service.rb
blob: db3f868fc09c56e58a932a66a52705fd2b69936f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module Mattermost
  module Commands
    class IssueCreateService < IssueService
      def execute
        title, description = parse_command

        present Issues::CreateService.new(project, current_user, title: title, description: description).execute
      end

      private

      def parse_command
        match = params[:text].match(/\Aissue create (?<title>.*)\n*/)
        title = match[:title]
        description = match.post_match

        [title, description]
      end
    end
  end
end