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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
7e62ad05
Commit
7e62ad05
authored
Sep 22, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix rake gitlab:incoming_email:check and make it
report error properly, so that we know what's really wrong.
parent
905d24fb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
17 deletions
+33
-17
changelogs/unreleased/38197-fix-ImapAuthenticationCheck.yml
changelogs/unreleased/38197-fix-ImapAuthenticationCheck.yml
+5
-0
lib/system_check/incoming_email/imap_authentication_check.rb
lib/system_check/incoming_email/imap_authentication_check.rb
+28
-17
No files found.
changelogs/unreleased/38197-fix-ImapAuthenticationCheck.yml
0 → 100644
View file @
7e62ad05
---
title
:
Fix `rake gitlab:incoming_email:check` and make it report the actual error
merge_request
:
14423
author
:
type
:
fixed
lib/system_check/incoming_email/imap_authentication_check.rb
View file @
7e62ad05
...
@@ -4,22 +4,17 @@ module SystemCheck
...
@@ -4,22 +4,17 @@ module SystemCheck
set_name
'IMAP server credentials are correct?'
set_name
'IMAP server credentials are correct?'
def
check?
def
check?
if
mailbox_config
if
config
begin
try_connect_imap
imap
=
Net
::
IMAP
.
new
(
config
[
:host
],
port:
config
[
:port
],
ssl:
config
[
:ssl
])
else
imap
.
starttls
if
config
[
:start_tls
]
@error
=
"
#{
mail_room_config_path
}
does not have mailboxes setup"
imap
.
login
(
config
[
:email
],
config
[
:password
])
false
connected
=
true
rescue
connected
=
false
end
end
end
end
connected
end
def
show_error
def
show_error
try_fixing_it
(
try_fixing_it
(
"An error occurred:
#{
@error
.
class
}
:
#{
@error
.
message
}
"
,
'Check that the information in config/gitlab.yml is correct'
'Check that the information in config/gitlab.yml is correct'
)
)
for_more_information
(
for_more_information
(
...
@@ -30,15 +25,31 @@ module SystemCheck
...
@@ -30,15 +25,31 @@ module SystemCheck
private
private
def
mailbox_config
def
try_connect_imap
return
@config
if
@config
imap
=
Net
::
IMAP
.
new
(
config
[
:host
],
port:
config
[
:port
],
ssl:
config
[
:ssl
])
imap
.
starttls
if
config
[
:start_tls
]
imap
.
login
(
config
[
:email
],
config
[
:password
])
true
rescue
=>
error
@error
=
error
false
end
def
config
@config
||=
load_config
end
def
mail_room_config_path
@mail_room_config_path
||=
Rails
.
root
.
join
(
'config'
,
'mail_room.yml'
).
to_s
end
config_path
=
Rails
.
root
.
join
(
'config'
,
'mail_room.yml'
).
to_s
def
load_config
erb
=
ERB
.
new
(
File
.
read
(
config_path
))
erb
=
ERB
.
new
(
File
.
read
(
mail_room_
config_path
))
erb
.
filename
=
config_path
erb
.
filename
=
mail_room_
config_path
config_file
=
YAML
.
load
(
erb
.
result
)
config_file
=
YAML
.
load
(
erb
.
result
)
@config
=
config_file
[
:mailboxes
]
&
.
first
config_file
.
dig
(
:mailboxes
,
0
)
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