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
e682d941
Commit
e682d941
authored
Jul 16, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move existing email interceptors into the same module
parent
fabf6a56
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
49 additions
and
31 deletions
+49
-31
config/initializers/additional_headers_interceptor.rb
config/initializers/additional_headers_interceptor.rb
+2
-1
config/initializers/disable_email_interceptor.rb
config/initializers/disable_email_interceptor.rb
+1
-2
config/initializers/email_template_interceptor.rb
config/initializers/email_template_interceptor.rb
+1
-2
lib/additional_email_headers_interceptor.rb
lib/additional_email_headers_interceptor.rb
+0
-6
lib/disable_email_interceptor.rb
lib/disable_email_interceptor.rb
+0
-7
lib/email_template_interceptor.rb
lib/email_template_interceptor.rb
+0
-11
lib/gitlab/email/hook/additional_headers_interceptor.rb
lib/gitlab/email/hook/additional_headers_interceptor.rb
+12
-0
lib/gitlab/email/hook/disable_email_interceptor.rb
lib/gitlab/email/hook/disable_email_interceptor.rb
+13
-0
lib/gitlab/email/hook/email_template_interceptor.rb
lib/gitlab/email/hook/email_template_interceptor.rb
+18
-0
spec/lib/gitlab/email/hook/additional_headers_interceptor_spec.rb
.../gitlab/email/hook/additional_headers_interceptor_spec.rb
+1
-1
spec/lib/gitlab/email/hook/disable_email_interceptor_spec.rb
spec/lib/gitlab/email/hook/disable_email_interceptor_spec.rb
+1
-1
No files found.
config/initializers/additional_headers_interceptor.rb
View file @
e682d941
ActionMailer
::
Base
.
register_interceptor
(
AdditionalEmailHeadersInterceptor
)
ActionMailer
::
Base
.
register_interceptor
(
::
Gitlab
::
Email
::
Hook
::
AdditionalHeadersInterceptor
)
config/initializers/disable_email_interceptor.rb
View file @
e682d941
# Interceptor in lib/disable_email_interceptor.rb
unless
Gitlab
.
config
.
gitlab
.
email_enabled
unless
Gitlab
.
config
.
gitlab
.
email_enabled
ActionMailer
::
Base
.
register_interceptor
(
DisableEmailInterceptor
)
ActionMailer
::
Base
.
register_interceptor
(
::
Gitlab
::
Email
::
Hook
::
DisableEmailInterceptor
)
ActionMailer
::
Base
.
logger
=
nil
ActionMailer
::
Base
.
logger
=
nil
end
end
config/initializers/email_template_interceptor.rb
View file @
e682d941
# Interceptor in lib/email_template_interceptor.rb
ActionMailer
::
Base
.
register_interceptor
(
::
Gitlab
::
Email
::
Hook
::
EmailTemplateInterceptor
)
ActionMailer
::
Base
.
register_interceptor
(
EmailTemplateInterceptor
)
lib/additional_email_headers_interceptor.rb
deleted
100644 → 0
View file @
fabf6a56
class
AdditionalEmailHeadersInterceptor
def
self
.
delivering_email
(
message
)
message
.
header
[
'Auto-Submitted'
]
||=
'auto-generated'
message
.
header
[
'X-Auto-Response-Suppress'
]
||=
'All'
end
end
lib/disable_email_interceptor.rb
deleted
100644 → 0
View file @
fabf6a56
# Read about interceptors in http://guides.rubyonrails.org/action_mailer_basics.html#intercepting-emails
class
DisableEmailInterceptor
def
self
.
delivering_email
(
message
)
message
.
perform_deliveries
=
false
Rails
.
logger
.
info
"Emails disabled! Interceptor prevented sending mail
#{
message
.
subject
}
"
end
end
lib/email_template_interceptor.rb
deleted
100644 → 0
View file @
fabf6a56
# Read about interceptors in http://guides.rubyonrails.org/action_mailer_basics.html#intercepting-emails
class
EmailTemplateInterceptor
def
self
.
delivering_email
(
message
)
# Remove HTML part if HTML emails are disabled.
unless
Gitlab
::
CurrentSettings
.
html_emails_enabled
message
.
parts
.
delete_if
do
|
part
|
part
.
content_type
.
start_with?
(
'text/html'
)
end
end
end
end
lib/gitlab/email/hook/additional_headers_interceptor.rb
0 → 100644
View file @
e682d941
module
Gitlab
module
Email
module
Hook
class
AdditionalHeadersInterceptor
def
self
.
delivering_email
(
message
)
message
.
header
[
'Auto-Submitted'
]
||=
'auto-generated'
message
.
header
[
'X-Auto-Response-Suppress'
]
||=
'All'
end
end
end
end
end
lib/gitlab/email/hook/disable_email_interceptor.rb
0 → 100644
View file @
e682d941
module
Gitlab
module
Email
module
Hook
class
DisableEmailInterceptor
def
self
.
delivering_email
(
message
)
message
.
perform_deliveries
=
false
Rails
.
logger
.
info
"Emails disabled! Interceptor prevented sending mail
#{
message
.
subject
}
"
end
end
end
end
end
lib/gitlab/email/hook/email_template_interceptor.rb
0 → 100644
View file @
e682d941
module
Gitlab
module
Email
module
Hook
class
EmailTemplateInterceptor
##
# Remove HTML part if HTML emails are disabled.
#
def
self
.
delivering_email
(
message
)
unless
Gitlab
::
CurrentSettings
.
html_emails_enabled
message
.
parts
.
delete_if
do
|
part
|
part
.
content_type
.
start_with?
(
'text/html'
)
end
end
end
end
end
end
end
spec/lib/
additional_emai
l_headers_interceptor_spec.rb
→
spec/lib/
gitlab/email/hook/additiona
l_headers_interceptor_spec.rb
View file @
e682d941
require
'spec_helper'
require
'spec_helper'
describe
AdditionalEmai
lHeadersInterceptor
do
describe
Gitlab
::
Email
::
Hook
::
Additiona
lHeadersInterceptor
do
let
(
:mail
)
do
let
(
:mail
)
do
ActionMailer
::
Base
.
mail
(
to:
'test@mail.com'
,
from:
'info@mail.com'
,
body:
'hello'
)
ActionMailer
::
Base
.
mail
(
to:
'test@mail.com'
,
from:
'info@mail.com'
,
body:
'hello'
)
end
end
...
...
spec/lib/disable_email_interceptor_spec.rb
→
spec/lib/
gitlab/email/hook/
disable_email_interceptor_spec.rb
View file @
e682d941
require
'spec_helper'
require
'spec_helper'
describe
DisableEmailInterceptor
do
describe
Gitlab
::
Email
::
Hook
::
DisableEmailInterceptor
do
before
do
before
do
Mail
.
register_interceptor
(
described_class
)
Mail
.
register_interceptor
(
described_class
)
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