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
Jérome Perrin
gitlab-ce
Commits
616675b4
Commit
616675b4
authored
Nov 17, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove duplication in mailers/emails/notes.rb
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
4747412a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
45 deletions
+52
-45
app/mailers/emails/issues.rb
app/mailers/emails/issues.rb
+12
-10
app/mailers/emails/notes.rb
app/mailers/emails/notes.rb
+40
-35
No files found.
app/mailers/emails/issues.rb
View file @
616675b4
module
Emails
module
Issues
def
new_issue_email
(
recipient_id
,
issue_id
)
mail_with_notification
(
issue_id
,
recipient_id
)
do
mail_new_thread
(
@issue
,
thread_options
(
@issue
.
author_id
,
recipient_id
))
issue_
mail_with_notification
(
issue_id
,
recipient_id
)
do
mail_new_thread
(
@issue
,
issue_
thread_options
(
@issue
.
author_id
,
recipient_id
))
end
end
def
reassigned_issue_email
(
recipient_id
,
issue_id
,
previous_assignee_id
,
updated_by_user_id
)
mail_with_notification
(
issue_id
,
recipient_id
)
do
issue_
mail_with_notification
(
issue_id
,
recipient_id
)
do
@previous_assignee
=
User
.
find_by
(
id:
previous_assignee_id
)
if
previous_assignee_id
mail_answer_thread
(
@issue
,
thread_options
(
updated_by_user_id
,
recipient_id
))
mail_answer_thread
(
@issue
,
issue_
thread_options
(
updated_by_user_id
,
recipient_id
))
end
end
def
closed_issue_email
(
recipient_id
,
issue_id
,
updated_by_user_id
)
mail_with_notification
(
issue_id
,
recipient_id
)
do
issue_
mail_with_notification
(
issue_id
,
recipient_id
)
do
@updated_by
=
User
.
find
updated_by_user_id
mail_answer_thread
(
@issue
,
thread_options
(
updated_by_user_id
,
recipient_id
))
mail_answer_thread
(
@issue
,
issue_
thread_options
(
updated_by_user_id
,
recipient_id
))
end
end
def
issue_status_changed_email
(
recipient_id
,
issue_id
,
status
,
updated_by_user_id
)
mail_with_notification
(
issue_id
,
recipient_id
)
do
issue_
mail_with_notification
(
issue_id
,
recipient_id
)
do
@issue_status
=
status
@updated_by
=
User
.
find
updated_by_user_id
mail_answer_thread
(
@issue
,
thread_options
(
updated_by_user_id
,
recipient_id
))
mail_answer_thread
(
@issue
,
issue_
thread_options
(
updated_by_user_id
,
recipient_id
))
end
end
def
thread_options
(
sender_id
,
recipient_id
)
private
def
issue_thread_options
(
sender_id
,
recipient_id
)
{
from:
sender
(
sender_id
),
to:
recipient
(
recipient_id
),
...
...
@@ -36,7 +38,7 @@ module Emails
}
end
def
mail_with_notification
(
issue_id
,
recipient_id
)
def
issue_
mail_with_notification
(
issue_id
,
recipient_id
)
@issue
=
Issue
.
find
(
issue_id
)
@project
=
@issue
.
project
@target_url
=
namespace_project_issue_url
(
@project
.
namespace
,
@project
,
@issue
)
...
...
app/mailers/emails/notes.rb
View file @
616675b4
module
Emails
module
Notes
def
note_commit_email
(
recipient_id
,
note_id
)
@note
=
Note
.
find
(
note_id
)
@commit
=
@note
.
noteable
@project
=
@note
.
project
@target_url
=
namespace_project_commit_url
(
@project
.
namespace
,
@project
,
@commit
,
anchor:
"note_
#{
@note
.
id
}
"
)
mail_answer_thread
(
@commit
,
from:
sender
(
@note
.
author_id
),
to:
recipient
(
recipient_id
),
subject:
subject
(
"
#{
@commit
.
title
}
(
#{
@commit
.
short_id
}
)"
))
SentNotification
.
record_note
(
@note
,
recipient_id
,
reply_key
)
note_mail_with_notification
(
note_id
,
recipient_id
)
do
@commit
=
@note
.
noteable
@target_url
=
namespace_project_commit_url
(
*
note_target_url_options
)
mail_answer_thread
(
@commit
,
from:
sender
(
@note
.
author_id
),
to:
recipient
(
recipient_id
),
subject:
subject
(
"
#{
@commit
.
title
}
(
#{
@commit
.
short_id
}
)"
))
end
end
def
note_issue_email
(
recipient_id
,
note_id
)
@note
=
Note
.
find
(
note_id
)
@issue
=
@note
.
noteable
@project
=
@note
.
project
@target_url
=
namespace_project_issue_url
(
@project
.
namespace
,
@project
,
@issue
,
anchor:
"note_
#{
@note
.
id
}
"
)
mail_answer_thread
(
@issue
,
from:
sender
(
@note
.
author_id
),
to:
recipient
(
recipient_id
),
subject:
subject
(
"
#{
@issue
.
title
}
(#
#{
@issue
.
iid
}
)"
))
SentNotification
.
record_note
(
@note
,
recipient_id
,
reply_key
)
note_mail_with_notification
(
note_id
,
recipient_id
)
do
@issue
=
@note
.
noteable
@target_url
=
namespace_project_issue_url
(
*
note_target_url_options
)
mail_answer_thread
(
@issue
,
note_thread_options
(
recipient_id
))
end
end
def
note_merge_request_email
(
recipient_id
,
note_id
)
note_mail_with_notification
(
note_id
,
recipient_id
)
do
@merge_request
=
@note
.
noteable
@target_url
=
namespace_project_merge_request_url
(
*
note_target_url_options
)
mail_answer_thread
(
@merge_request
,
note_thread_options
(
recipient_id
))
end
end
private
def
note_target_url_options
[
@project
.
namespace
,
@project
,
@note
.
noteable
,
anchor:
"note_
#{
@note
.
id
}
"
]
end
def
note_thread_options
(
recipient_id
)
{
from:
sender
(
@note
.
author_id
),
to:
recipient
(
recipient_id
),
subject:
subject
(
"
#{
@note
.
noteable
.
title
}
(#
#{
@note
.
noteable
.
iid
}
)"
)
}
end
def
note_mail_with_notification
(
note_id
,
recipient_id
)
@note
=
Note
.
find
(
note_id
)
@merge_request
=
@note
.
noteable
@project
=
@note
.
project
@target_url
=
namespace_project_merge_request_url
(
@project
.
namespace
,
@project
,
@merge_request
,
anchor:
"note_
#{
@note
.
id
}
"
)
mail_answer_thread
(
@merge_request
,
from:
sender
(
@note
.
author_id
),
to:
recipient
(
recipient_id
),
subject:
subject
(
"
#{
@merge_request
.
title
}
(#
#{
@merge_request
.
iid
}
)"
))
SentNotification
.
record_note
(
@note
,
recipient_id
,
reply_key
)
yield
SentNotification
.
record
(
@note
,
recipient_id
,
reply_key
)
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