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
17858d49
Commit
17858d49
authored
May 13, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6109 from jamit/master
Added email threading for update emails on issues and merge requests
parents
3ea4bf48
a7bdf87f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
0 deletions
+46
-0
app/mailers/emails/issues.rb
app/mailers/emails/issues.rb
+4
-0
app/mailers/emails/merge_requests.rb
app/mailers/emails/merge_requests.rb
+4
-0
app/mailers/emails/notes.rb
app/mailers/emails/notes.rb
+2
-0
app/mailers/notify.rb
app/mailers/notify.rb
+16
-0
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+20
-0
No files found.
app/mailers/emails/issues.rb
View file @
17858d49
...
@@ -4,6 +4,7 @@ module Emails
...
@@ -4,6 +4,7 @@ module Emails
@issue
=
Issue
.
find
(
issue_id
)
@issue
=
Issue
.
find
(
issue_id
)
@project
=
@issue
.
project
@project
=
@issue
.
project
@target_url
=
project_issue_url
(
@project
,
@issue
)
@target_url
=
project_issue_url
(
@project
,
@issue
)
set_message_id
(
"issue_
#{
issue_id
}
"
)
mail
(
from:
sender
(
@issue
.
author_id
),
mail
(
from:
sender
(
@issue
.
author_id
),
to:
recipient
(
recipient_id
),
to:
recipient
(
recipient_id
),
subject:
subject
(
"
#{
@issue
.
title
}
(#
#{
@issue
.
iid
}
)"
))
subject:
subject
(
"
#{
@issue
.
title
}
(#
#{
@issue
.
iid
}
)"
))
...
@@ -14,6 +15,7 @@ module Emails
...
@@ -14,6 +15,7 @@ module Emails
@previous_assignee
=
User
.
find_by
(
id:
previous_assignee_id
)
if
previous_assignee_id
@previous_assignee
=
User
.
find_by
(
id:
previous_assignee_id
)
if
previous_assignee_id
@project
=
@issue
.
project
@project
=
@issue
.
project
@target_url
=
project_issue_url
(
@project
,
@issue
)
@target_url
=
project_issue_url
(
@project
,
@issue
)
set_reference
(
"issue_
#{
issue_id
}
"
)
mail
(
from:
sender
(
updated_by_user_id
),
mail
(
from:
sender
(
updated_by_user_id
),
to:
recipient
(
recipient_id
),
to:
recipient
(
recipient_id
),
subject:
subject
(
"
#{
@issue
.
title
}
(#
#{
@issue
.
iid
}
)"
))
subject:
subject
(
"
#{
@issue
.
title
}
(#
#{
@issue
.
iid
}
)"
))
...
@@ -24,6 +26,7 @@ module Emails
...
@@ -24,6 +26,7 @@ module Emails
@project
=
@issue
.
project
@project
=
@issue
.
project
@updated_by
=
User
.
find
updated_by_user_id
@updated_by
=
User
.
find
updated_by_user_id
@target_url
=
project_issue_url
(
@project
,
@issue
)
@target_url
=
project_issue_url
(
@project
,
@issue
)
set_reference
(
"issue_
#{
issue_id
}
"
)
mail
(
from:
sender
(
updated_by_user_id
),
mail
(
from:
sender
(
updated_by_user_id
),
to:
recipient
(
recipient_id
),
to:
recipient
(
recipient_id
),
subject:
subject
(
"
#{
@issue
.
title
}
(#
#{
@issue
.
iid
}
)"
))
subject:
subject
(
"
#{
@issue
.
title
}
(#
#{
@issue
.
iid
}
)"
))
...
@@ -35,6 +38,7 @@ module Emails
...
@@ -35,6 +38,7 @@ module Emails
@project
=
@issue
.
project
@project
=
@issue
.
project
@updated_by
=
User
.
find
updated_by_user_id
@updated_by
=
User
.
find
updated_by_user_id
@target_url
=
project_issue_url
(
@project
,
@issue
)
@target_url
=
project_issue_url
(
@project
,
@issue
)
set_reference
(
"issue_
#{
issue_id
}
"
)
mail
(
from:
sender
(
updated_by_user_id
),
mail
(
from:
sender
(
updated_by_user_id
),
to:
recipient
(
recipient_id
),
to:
recipient
(
recipient_id
),
subject:
subject
(
"
#{
@issue
.
title
}
(#
#{
@issue
.
iid
}
)"
))
subject:
subject
(
"
#{
@issue
.
title
}
(#
#{
@issue
.
iid
}
)"
))
...
...
app/mailers/emails/merge_requests.rb
View file @
17858d49
...
@@ -4,6 +4,7 @@ module Emails
...
@@ -4,6 +4,7 @@ module Emails
@merge_request
=
MergeRequest
.
find
(
merge_request_id
)
@merge_request
=
MergeRequest
.
find
(
merge_request_id
)
@project
=
@merge_request
.
project
@project
=
@merge_request
.
project
@target_url
=
project_merge_request_url
(
@project
,
@merge_request
)
@target_url
=
project_merge_request_url
(
@project
,
@merge_request
)
set_message_id
(
"merge_request_
#{
merge_request_id
}
"
)
mail
(
from:
sender
(
@merge_request
.
author_id
),
mail
(
from:
sender
(
@merge_request
.
author_id
),
to:
recipient
(
recipient_id
),
to:
recipient
(
recipient_id
),
subject:
subject
(
"
#{
@merge_request
.
title
}
(#
#{
@merge_request
.
iid
}
)"
))
subject:
subject
(
"
#{
@merge_request
.
title
}
(#
#{
@merge_request
.
iid
}
)"
))
...
@@ -14,6 +15,7 @@ module Emails
...
@@ -14,6 +15,7 @@ module Emails
@previous_assignee
=
User
.
find_by
(
id:
previous_assignee_id
)
if
previous_assignee_id
@previous_assignee
=
User
.
find_by
(
id:
previous_assignee_id
)
if
previous_assignee_id
@project
=
@merge_request
.
project
@project
=
@merge_request
.
project
@target_url
=
project_merge_request_url
(
@project
,
@merge_request
)
@target_url
=
project_merge_request_url
(
@project
,
@merge_request
)
set_reference
(
"merge_request_
#{
merge_request_id
}
"
)
mail
(
from:
sender
(
updated_by_user_id
),
mail
(
from:
sender
(
updated_by_user_id
),
to:
recipient
(
recipient_id
),
to:
recipient
(
recipient_id
),
subject:
subject
(
"
#{
@merge_request
.
title
}
(#
#{
@merge_request
.
iid
}
)"
))
subject:
subject
(
"
#{
@merge_request
.
title
}
(#
#{
@merge_request
.
iid
}
)"
))
...
@@ -24,6 +26,7 @@ module Emails
...
@@ -24,6 +26,7 @@ module Emails
@updated_by
=
User
.
find
updated_by_user_id
@updated_by
=
User
.
find
updated_by_user_id
@project
=
@merge_request
.
project
@project
=
@merge_request
.
project
@target_url
=
project_merge_request_url
(
@project
,
@merge_request
)
@target_url
=
project_merge_request_url
(
@project
,
@merge_request
)
set_reference
(
"merge_request_
#{
merge_request_id
}
"
)
mail
(
from:
sender
(
updated_by_user_id
),
mail
(
from:
sender
(
updated_by_user_id
),
to:
recipient
(
recipient_id
),
to:
recipient
(
recipient_id
),
subject:
subject
(
"
#{
@merge_request
.
title
}
(#
#{
@merge_request
.
iid
}
)"
))
subject:
subject
(
"
#{
@merge_request
.
title
}
(#
#{
@merge_request
.
iid
}
)"
))
...
@@ -33,6 +36,7 @@ module Emails
...
@@ -33,6 +36,7 @@ module Emails
@merge_request
=
MergeRequest
.
find
(
merge_request_id
)
@merge_request
=
MergeRequest
.
find
(
merge_request_id
)
@project
=
@merge_request
.
project
@project
=
@merge_request
.
project
@target_url
=
project_merge_request_url
(
@project
,
@merge_request
)
@target_url
=
project_merge_request_url
(
@project
,
@merge_request
)
set_reference
(
"merge_request_
#{
merge_request_id
}
"
)
mail
(
from:
sender
(
updated_by_user_id
),
mail
(
from:
sender
(
updated_by_user_id
),
to:
recipient
(
recipient_id
),
to:
recipient
(
recipient_id
),
subject:
subject
(
"
#{
@merge_request
.
title
}
(#
#{
@merge_request
.
iid
}
)"
))
subject:
subject
(
"
#{
@merge_request
.
title
}
(#
#{
@merge_request
.
iid
}
)"
))
...
...
app/mailers/emails/notes.rb
View file @
17858d49
...
@@ -15,6 +15,7 @@ module Emails
...
@@ -15,6 +15,7 @@ module Emails
@issue
=
@note
.
noteable
@issue
=
@note
.
noteable
@project
=
@note
.
project
@project
=
@note
.
project
@target_url
=
project_issue_url
(
@project
,
@issue
,
anchor:
"note_
#{
@note
.
id
}
"
)
@target_url
=
project_issue_url
(
@project
,
@issue
,
anchor:
"note_
#{
@note
.
id
}
"
)
set_reference
(
"issue_
#{
@issue
.
id
}
"
)
mail
(
from:
sender
(
@note
.
author_id
),
mail
(
from:
sender
(
@note
.
author_id
),
to:
recipient
(
recipient_id
),
to:
recipient
(
recipient_id
),
subject:
subject
(
"
#{
@issue
.
title
}
(#
#{
@issue
.
iid
}
)"
))
subject:
subject
(
"
#{
@issue
.
title
}
(#
#{
@issue
.
iid
}
)"
))
...
@@ -25,6 +26,7 @@ module Emails
...
@@ -25,6 +26,7 @@ module Emails
@merge_request
=
@note
.
noteable
@merge_request
=
@note
.
noteable
@project
=
@note
.
project
@project
=
@note
.
project
@target_url
=
project_merge_request_url
(
@project
,
@merge_request
,
anchor:
"note_
#{
@note
.
id
}
"
)
@target_url
=
project_merge_request_url
(
@project
,
@merge_request
,
anchor:
"note_
#{
@note
.
id
}
"
)
set_reference
(
"merge_request_
#{
@merge_request
.
id
}
"
)
mail
(
from:
sender
(
@note
.
author_id
),
mail
(
from:
sender
(
@note
.
author_id
),
to:
recipient
(
recipient_id
),
to:
recipient
(
recipient_id
),
subject:
subject
(
"
#{
@merge_request
.
title
}
(#
#{
@merge_request
.
iid
}
)"
))
subject:
subject
(
"
#{
@merge_request
.
title
}
(#
#{
@merge_request
.
iid
}
)"
))
...
...
app/mailers/notify.rb
View file @
17858d49
...
@@ -53,6 +53,22 @@ class Notify < ActionMailer::Base
...
@@ -53,6 +53,22 @@ class Notify < ActionMailer::Base
end
end
end
end
# Set the Message-ID header field
#
# local_part - The local part of the message ID
#
def
set_message_id
(
local_part
)
headers
[
"Message-ID"
]
=
"<
#{
local_part
}
@
#{
Gitlab
.
config
.
gitlab
.
host
}
>"
end
# Set the References header field
#
# local_part - The local part of the referenced message ID
#
def
set_reference
(
local_part
)
headers
[
"References"
]
=
"<
#{
local_part
}
@
#{
Gitlab
.
config
.
gitlab
.
host
}
>"
end
# Formats arguments into a String suitable for use as an email subject
# Formats arguments into a String suitable for use as an email subject
#
#
# extra - Extra Strings to be inserted into the subject
# extra - Extra Strings to be inserted into the subject
...
...
spec/mailers/notify_spec.rb
View file @
17858d49
...
@@ -161,6 +161,10 @@ describe Notify do
...
@@ -161,6 +161,10 @@ describe Notify do
it
'contains a link to the new issue'
do
it
'contains a link to the new issue'
do
should
have_body_text
/
#{
project_issue_path
project
,
issue
}
/
should
have_body_text
/
#{
project_issue_path
project
,
issue
}
/
end
end
it
'has the correct message-id set'
do
should
have_header
'Message-ID'
,
"<issue_
#{
issue
.
id
}
@
#{
Gitlab
.
config
.
gitlab
.
host
}
>"
end
end
end
describe
'that are new with a description'
do
describe
'that are new with a description'
do
...
@@ -197,6 +201,10 @@ describe Notify do
...
@@ -197,6 +201,10 @@ describe Notify do
it
'contains a link to the issue'
do
it
'contains a link to the issue'
do
should
have_body_text
/
#{
project_issue_path
project
,
issue
}
/
should
have_body_text
/
#{
project_issue_path
project
,
issue
}
/
end
end
it
'has the correct reference set'
do
should
have_header
'References'
,
"<issue_
#{
issue
.
id
}
@
#{
Gitlab
.
config
.
gitlab
.
host
}
>"
end
end
end
describe
'status changed'
do
describe
'status changed'
do
...
@@ -224,6 +232,10 @@ describe Notify do
...
@@ -224,6 +232,10 @@ describe Notify do
it
'contains a link to the issue'
do
it
'contains a link to the issue'
do
should
have_body_text
/
#{
project_issue_path
project
,
issue
}
/
should
have_body_text
/
#{
project_issue_path
project
,
issue
}
/
end
end
it
'has the correct reference set'
do
should
have_header
'References'
,
"<issue_
#{
issue
.
id
}
@
#{
Gitlab
.
config
.
gitlab
.
host
}
>"
end
end
end
end
end
...
@@ -253,6 +265,10 @@ describe Notify do
...
@@ -253,6 +265,10 @@ describe Notify do
it
'contains the target branch for the merge request'
do
it
'contains the target branch for the merge request'
do
should
have_body_text
/
#{
merge_request
.
target_branch
}
/
should
have_body_text
/
#{
merge_request
.
target_branch
}
/
end
end
it
'has the correct message-id set'
do
should
have_header
'Message-ID'
,
"<merge_request_
#{
merge_request
.
id
}
@
#{
Gitlab
.
config
.
gitlab
.
host
}
>"
end
end
end
describe
'that are new with a description'
do
describe
'that are new with a description'
do
...
@@ -313,6 +329,10 @@ describe Notify do
...
@@ -313,6 +329,10 @@ describe Notify do
it
'contains a link to the merge request'
do
it
'contains a link to the merge request'
do
should
have_body_text
/
#{
project_merge_request_path
project
,
merge_request
}
/
should
have_body_text
/
#{
project_merge_request_path
project
,
merge_request
}
/
end
end
it
'has the correct reference set'
do
should
have_header
'References'
,
"<merge_request_
#{
merge_request
.
id
}
@
#{
Gitlab
.
config
.
gitlab
.
host
}
>"
end
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