Commit 853c69c48a1641ad742cf9f70326fc93c44ea58d
1 parent
db469ea3
Exists in
master
and in
4 other branches
Reorder and group methods in Notify mailer
Showing
1 changed file
with
66 additions
and
35 deletions
Show diff stats
app/mailers/notify.rb
| @@ -9,11 +9,11 @@ class Notify < ActionMailer::Base | @@ -9,11 +9,11 @@ class Notify < ActionMailer::Base | ||
| 9 | 9 | ||
| 10 | default from: Gitlab.config.email_from | 10 | default from: Gitlab.config.email_from |
| 11 | 11 | ||
| 12 | - def new_user_email(user_id, password) | ||
| 13 | - @user = User.find(user_id) | ||
| 14 | - @password = password | ||
| 15 | - mail(to: @user.email, subject: subject("Account was created for you")) | ||
| 16 | - end | 12 | + |
| 13 | + | ||
| 14 | + # | ||
| 15 | + # Issue | ||
| 16 | + # | ||
| 17 | 17 | ||
| 18 | def new_issue_email(issue_id) | 18 | def new_issue_email(issue_id) |
| 19 | @issue = Issue.find(issue_id) | 19 | @issue = Issue.find(issue_id) |
| @@ -21,12 +21,46 @@ class Notify < ActionMailer::Base | @@ -21,12 +21,46 @@ class Notify < ActionMailer::Base | ||
| 21 | mail(to: @issue.assignee_email, subject: subject("new issue ##{@issue.id}", @issue.title)) | 21 | mail(to: @issue.assignee_email, subject: subject("new issue ##{@issue.id}", @issue.title)) |
| 22 | end | 22 | end |
| 23 | 23 | ||
| 24 | - def note_wall_email(recipient_id, note_id) | ||
| 25 | - @note = Note.find(note_id) | ||
| 26 | - @project = @note.project | ||
| 27 | - mail(to: recipient(recipient_id), subject: subject) | 24 | + def reassigned_issue_email(recipient_id, issue_id, previous_assignee_id) |
| 25 | + @issue = Issue.find(issue_id) | ||
| 26 | + @previous_assignee ||= User.find(previous_assignee_id) | ||
| 27 | + @project = @issue.project | ||
| 28 | + mail(to: recipient(recipient_id), subject: subject("changed issue ##{@issue.id}", @issue.title)) | ||
| 29 | + end | ||
| 30 | + | ||
| 31 | + def issue_status_changed_email(recipient_id, issue_id, status, updated_by_user_id) | ||
| 32 | + @issue = Issue.find issue_id | ||
| 33 | + @issue_status = status | ||
| 34 | + @updated_by = User.find updated_by_user_id | ||
| 35 | + mail(to: recipient(recipient_id), | ||
| 36 | + subject: subject("changed issue ##{@issue.id}", @issue.title)) | ||
| 37 | + end | ||
| 38 | + | ||
| 39 | + | ||
| 40 | + | ||
| 41 | + # | ||
| 42 | + # Merge Request | ||
| 43 | + # | ||
| 44 | + | ||
| 45 | + def new_merge_request_email(merge_request_id) | ||
| 46 | + @merge_request = MergeRequest.find(merge_request_id) | ||
| 47 | + @project = @merge_request.project | ||
| 48 | + mail(to: @merge_request.assignee_email, subject: subject("new merge request !#{@merge_request.id}", @merge_request.title)) | ||
| 49 | + end | ||
| 50 | + | ||
| 51 | + def reassigned_merge_request_email(recipient_id, merge_request_id, previous_assignee_id) | ||
| 52 | + @merge_request = MergeRequest.find(merge_request_id) | ||
| 53 | + @previous_assignee ||= User.find(previous_assignee_id) | ||
| 54 | + @project = @merge_request.project | ||
| 55 | + mail(to: recipient(recipient_id), subject: subject("changed merge request !#{@merge_request.id}", @merge_request.title)) | ||
| 28 | end | 56 | end |
| 29 | 57 | ||
| 58 | + | ||
| 59 | + | ||
| 60 | + # | ||
| 61 | + # Note | ||
| 62 | + # | ||
| 63 | + | ||
| 30 | def note_commit_email(recipient_id, note_id) | 64 | def note_commit_email(recipient_id, note_id) |
| 31 | @note = Note.find(note_id) | 65 | @note = Note.find(note_id) |
| 32 | @commit = @note.noteable | 66 | @commit = @note.noteable |
| @@ -35,6 +69,13 @@ class Notify < ActionMailer::Base | @@ -35,6 +69,13 @@ class Notify < ActionMailer::Base | ||
| 35 | mail(to: recipient(recipient_id), subject: subject("note for commit #{@commit.short_id}", @commit.title)) | 69 | mail(to: recipient(recipient_id), subject: subject("note for commit #{@commit.short_id}", @commit.title)) |
| 36 | end | 70 | end |
| 37 | 71 | ||
| 72 | + def note_issue_email(recipient_id, note_id) | ||
| 73 | + @note = Note.find(note_id) | ||
| 74 | + @issue = @note.noteable | ||
| 75 | + @project = @note.project | ||
| 76 | + mail(to: recipient(recipient_id), subject: subject("note for issue ##{@issue.id}")) | ||
| 77 | + end | ||
| 78 | + | ||
| 38 | def note_merge_request_email(recipient_id, note_id) | 79 | def note_merge_request_email(recipient_id, note_id) |
| 39 | @note = Note.find(note_id) | 80 | @note = Note.find(note_id) |
| 40 | @merge_request = @note.noteable | 81 | @merge_request = @note.noteable |
| @@ -42,11 +83,10 @@ class Notify < ActionMailer::Base | @@ -42,11 +83,10 @@ class Notify < ActionMailer::Base | ||
| 42 | mail(to: recipient(recipient_id), subject: subject("note for merge request !#{@merge_request.id}")) | 83 | mail(to: recipient(recipient_id), subject: subject("note for merge request !#{@merge_request.id}")) |
| 43 | end | 84 | end |
| 44 | 85 | ||
| 45 | - def note_issue_email(recipient_id, note_id) | 86 | + def note_wall_email(recipient_id, note_id) |
| 46 | @note = Note.find(note_id) | 87 | @note = Note.find(note_id) |
| 47 | - @issue = @note.noteable | ||
| 48 | @project = @note.project | 88 | @project = @note.project |
| 49 | - mail(to: recipient(recipient_id), subject: subject("note for issue ##{@issue.id}")) | 89 | + mail(to: recipient(recipient_id), subject: subject) |
| 50 | end | 90 | end |
| 51 | 91 | ||
| 52 | def note_wiki_email(recipient_id, note_id) | 92 | def note_wiki_email(recipient_id, note_id) |
| @@ -56,25 +96,11 @@ class Notify < ActionMailer::Base | @@ -56,25 +96,11 @@ class Notify < ActionMailer::Base | ||
| 56 | mail(to: recipient(recipient_id), subject: subject("note for wiki")) | 96 | mail(to: recipient(recipient_id), subject: subject("note for wiki")) |
| 57 | end | 97 | end |
| 58 | 98 | ||
| 59 | - def new_merge_request_email(merge_request_id) | ||
| 60 | - @merge_request = MergeRequest.find(merge_request_id) | ||
| 61 | - @project = @merge_request.project | ||
| 62 | - mail(to: @merge_request.assignee_email, subject: subject("new merge request !#{@merge_request.id}", @merge_request.title)) | ||
| 63 | - end | ||
| 64 | 99 | ||
| 65 | - def reassigned_merge_request_email(recipient_id, merge_request_id, previous_assignee_id) | ||
| 66 | - @merge_request = MergeRequest.find(merge_request_id) | ||
| 67 | - @previous_assignee ||= User.find(previous_assignee_id) | ||
| 68 | - @project = @merge_request.project | ||
| 69 | - mail(to: recipient(recipient_id), subject: subject("changed merge request !#{@merge_request.id}", @merge_request.title)) | ||
| 70 | - end | ||
| 71 | 100 | ||
| 72 | - def reassigned_issue_email(recipient_id, issue_id, previous_assignee_id) | ||
| 73 | - @issue = Issue.find(issue_id) | ||
| 74 | - @previous_assignee ||= User.find(previous_assignee_id) | ||
| 75 | - @project = @issue.project | ||
| 76 | - mail(to: recipient(recipient_id), subject: subject("changed issue ##{@issue.id}", @issue.title)) | ||
| 77 | - end | 101 | + # |
| 102 | + # Project | ||
| 103 | + # | ||
| 78 | 104 | ||
| 79 | def project_access_granted_email(user_project_id) | 105 | def project_access_granted_email(user_project_id) |
| 80 | @users_project = UsersProject.find user_project_id | 106 | @users_project = UsersProject.find user_project_id |
| @@ -83,14 +109,19 @@ class Notify < ActionMailer::Base | @@ -83,14 +109,19 @@ class Notify < ActionMailer::Base | ||
| 83 | subject: subject("access to project was granted")) | 109 | subject: subject("access to project was granted")) |
| 84 | end | 110 | end |
| 85 | 111 | ||
| 86 | - def issue_status_changed_email(recipient_id, issue_id, status, updated_by_user_id) | ||
| 87 | - @issue = Issue.find issue_id | ||
| 88 | - @issue_status = status | ||
| 89 | - @updated_by = User.find updated_by_user_id | ||
| 90 | - mail(to: recipient(recipient_id), | ||
| 91 | - subject: subject("changed issue ##{@issue.id}", @issue.title)) | 112 | + |
| 113 | + | ||
| 114 | + # | ||
| 115 | + # User | ||
| 116 | + # | ||
| 117 | + | ||
| 118 | + def new_user_email(user_id, password) | ||
| 119 | + @user = User.find(user_id) | ||
| 120 | + @password = password | ||
| 121 | + mail(to: @user.email, subject: subject("Account was created for you")) | ||
| 92 | end | 122 | end |
| 93 | 123 | ||
| 124 | + | ||
| 94 | private | 125 | private |
| 95 | 126 | ||
| 96 | # Look up a User by their ID and return their email address | 127 | # Look up a User by their ID and return their email address |