blob: dc26039ef41a1ea5af3527ec5c51b576735b7177 (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
module Mattermost
class IssueService < BaseService
def execute
if params[:text].start_with?('create')
create_issue
else
super
end
end
private
def create_issue
issue = Issues::CreateService.new(project, current_user, issue_params).execute
byebug
if issue.valid?
generate_response(issue)
else
issue_create_error(issue.errors.full_messages)
end
end
def issue_create_error(errors)
{
response_type: :ephemeral,
text: "An error occured creating your issue: #{errors}"
}
end
def collection
project.issues
end
def link(issue)
Gitlab::Routing.
url_helpers.
namespace_project_issue_url(project.namespace, project, issue)
end
def issue_params
match = params[:text].match(/\Acreate (?<title>.+$)/)
return issue_create_error("No title given") unless match
{
title: match[:title],
description: params[:text].gsub(/\Acreate .+$\s*/, ''),
}
end
end
end
|