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
Tatuya Kamada
gitlab-ce
Commits
a8a861ae
Commit
a8a861ae
authored
Aug 19, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add BaseMailer to house shared mailer functionality.
parent
03b54f1f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
49 deletions
+52
-49
app/mailers/base_mailer.rb
app/mailers/base_mailer.rb
+50
-0
app/mailers/email_rejection_mailer.rb
app/mailers/email_rejection_mailer.rb
+1
-17
app/mailers/notify.rb
app/mailers/notify.rb
+1
-32
No files found.
app/mailers/base_mailer.rb
0 → 100644
View file @
a8a861ae
class
EmailRejectionMailer
<
ActionMailer
::
Base
add_template_helper
ApplicationHelper
add_template_helper
GitlabMarkdownHelper
attr_accessor
:current_user
helper_method
:current_user
,
:can?
default
from:
Proc
.
new
{
default_sender_address
.
format
}
default
reply_to:
Proc
.
new
{
default_reply_to_address
.
format
}
def
self
.
delay
delay_for
(
2
.
seconds
)
end
def
rejection
(
reason
,
original_raw
,
can_retry
=
false
)
@reason
=
reason
@original_message
=
Mail
::
Message
.
new
(
original_raw
)
headers
=
{
to:
@original_message
.
from
,
subject:
"[Rejected]
#{
@original_message
.
subject
}
"
}
headers
[
'Message-ID'
]
=
SecureRandom
.
hex
headers
[
'In-Reply-To'
]
=
@original_message
.
message_id
headers
[
'References'
]
=
@original_message
.
message_id
headers
[
'Reply-To'
]
=
@original_message
.
to
.
first
if
can_retry
mail
(
headers
)
end
def
can?
Ability
.
abilities
.
allowed?
(
user
,
action
,
subject
)
end
private
def
default_sender_address
address
=
Mail
::
Address
.
new
(
Gitlab
.
config
.
gitlab
.
email_from
)
address
.
display_name
=
Gitlab
.
config
.
gitlab
.
email_display_name
address
end
def
default_reply_to_address
address
=
Mail
::
Address
.
new
(
Gitlab
.
config
.
gitlab
.
email_reply_to
)
address
.
display_name
=
Gitlab
.
config
.
gitlab
.
email_display_name
address
end
end
app/mailers/email_rejection_mailer.rb
View file @
a8a861ae
class
EmailRejectionMailer
<
ActionMailer
::
Base
add_template_helper
ApplicationHelper
add_template_helper
GitlabMarkdownHelper
helper_method
:current_user
,
:can?
default
from:
"
#{
Gitlab
.
config
.
gitlab
.
email_display_name
}
<
#{
Gitlab
.
config
.
gitlab
.
email_from
}
>"
default
reply_to:
"
#{
Gitlab
.
config
.
gitlab
.
email_display_name
}
<
#{
Gitlab
.
config
.
gitlab
.
email_reply_to
}
>"
class
EmailRejectionMailer
<
BaseMailer
def
rejection
(
reason
,
original_raw
,
can_retry
=
false
)
@reason
=
reason
@original_message
=
Mail
::
Message
.
new
(
original_raw
)
...
...
@@ -24,12 +16,4 @@ class EmailRejectionMailer < ActionMailer::Base
mail
(
headers
)
end
def
current_user
nil
end
def
can?
false
end
end
app/mailers/notify.rb
View file @
a8a861ae
class
Notify
<
ActionMailer
::
Base
class
Notify
<
BaseMailer
include
ActionDispatch
::
Routing
::
PolymorphicRoutes
include
Emails
::
Issues
...
...
@@ -8,22 +8,9 @@ class Notify < ActionMailer::Base
include
Emails
::
Profile
include
Emails
::
Groups
add_template_helper
ApplicationHelper
add_template_helper
GitlabMarkdownHelper
add_template_helper
MergeRequestsHelper
add_template_helper
EmailsHelper
attr_accessor
:current_user
helper_method
:current_user
,
:can?
default
from:
Proc
.
new
{
default_sender_address
.
format
}
default
reply_to:
Proc
.
new
{
default_reply_to_address
.
format
}
# Just send email with 2 seconds delay
def
self
.
delay
delay_for
(
2
.
seconds
)
end
def
test_email
(
recipient_email
,
subject
,
body
)
mail
(
to:
recipient_email
,
subject:
subject
,
...
...
@@ -69,20 +56,6 @@ class Notify < ActionMailer::Base
private
# The default email address to send emails from
def
default_sender_address
address
=
Mail
::
Address
.
new
(
Gitlab
.
config
.
gitlab
.
email_from
)
address
.
display_name
=
Gitlab
.
config
.
gitlab
.
email_display_name
address
end
# The default email address to send emails from
def
default_reply_to_address
address
=
Mail
::
Address
.
new
(
Gitlab
.
config
.
gitlab
.
email_reply_to
)
address
.
display_name
=
Gitlab
.
config
.
gitlab
.
email_display_name
address
end
def
can_send_from_user_email?
(
sender
)
sender_domain
=
sender
.
email
.
split
(
"@"
).
last
self
.
class
.
allowed_email_domains
.
include?
(
sender_domain
)
...
...
@@ -197,10 +170,6 @@ class Notify < ActionMailer::Base
mail_thread
(
model
,
headers
)
end
def
can?
Ability
.
abilities
.
allowed?
(
user
,
action
,
subject
)
end
def
reply_key
@reply_key
||=
Gitlab
::
ReplyByEmail
.
reply_key
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