Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
db0ffef8
Commit
db0ffef8
authored
Mar 23, 2017
by
http://jneen.net/
Committed by
Felipe Artur
Apr 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add an incoming email handler for service desk
parent
15464516
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
0 deletions
+65
-0
lib/gitlab/email/handler.rb
lib/gitlab/email/handler.rb
+3
-0
lib/gitlab/email/handler/ee/service_desk_handler.rb
lib/gitlab/email/handler/ee/service_desk_handler.rb
+62
-0
No files found.
lib/gitlab/email/handler.rb
View file @
db0ffef8
...
...
@@ -2,10 +2,13 @@ require 'gitlab/email/handler/create_note_handler'
require
'gitlab/email/handler/create_issue_handler'
require
'gitlab/email/handler/unsubscribe_handler'
require
'gitlab/email/handler/ee/service_desk_handler'
module
Gitlab
module
Email
module
Handler
HANDLERS
=
[
EE
::
ServiceDeskHandler
,
UnsubscribeHandler
,
CreateNoteHandler
,
CreateIssueHandler
,
...
...
lib/gitlab/email/handler/ee/service_desk_handler.rb
0 → 100644
View file @
db0ffef8
module
Gitlab
module
Email
module
Handler
module
EE
class
ServiceDeskHandler
<
BaseHandler
include
ReplyProcessing
def
can_handle?
Gitlab
::
EE
::
ServiceDesk
.
enabled?
&&
service_desk_key
.
present?
end
def
execute
raise
EmailUnparsableError
if
from_address
.
blank?
create_issue!
send_thank_you_email!
end
private
def
service_desk_key
@service_desk_key
||=
(
mail_key
=~
/\Aservice-desk[+](\w+)\z/
and
$1
)
end
def
project
return
@project
if
instance_variable_defined?
(
:@project
)
@project
=
Project
.
where
(
service_desk_enabled:
true
,
service_desk_mail_key:
service_desk_key
).
first
end
def
create_issue!
# NB: the support bot is specifically forbidden
# from mentioning any entities, or from using
# slash commands.
@issue
=
Issues
::
CreateService
.
new
(
project
,
User
.
support_bot
,
title:
mail
.
subject
,
description:
message
,
confidential:
true
,
).
execute
@issue
.
update_attributes
(
service_desk_reply_to:
from_address
)
end
def
send_thank_you_email!
Notify
.
thank_you_email
(
@issue
.
id
)
end
def
from_address
(
mail
.
reply_to
||
[]).
first
||
mail
.
sender
||
mail
.
from
.
first
end
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment