diff options
author | Pierre de La Morinerie <pierre@capitainetrain.com> | 2014-02-18 14:12:01 +0400 |
---|---|---|
committer | Pierre de La Morinerie <pierre@capitainetrain.com> | 2014-03-03 19:58:44 +0400 |
commit | 7ba0b502d3e6fdc5efc5619d803a1b9fcf9db791 (patch) | |
tree | 7dab84048b9c766ad52c2e2349dd8535d6b99409 /app/mailers | |
parent | 03920b96d01ea4f5267c7ccd1aa036eab17d62b4 (diff) |
Add a "View in GitLab" link in notification emails
When an email notification concerns a specific object (issue, note,
merge request, etc.), add a link to the footer of the email that opens
the item's page in a web browser.
Rationale:
* The link is predictable: always the same text, always at the same
location, like any reliable tool.
* It allows to remove the inline-title in many emails, and leave only
the actual content of the message.
Diffstat (limited to 'app/mailers')
-rw-r--r-- | app/mailers/emails/groups.rb | 2 | ||||
-rw-r--r-- | app/mailers/emails/issues.rb | 4 | ||||
-rw-r--r-- | app/mailers/emails/merge_requests.rb | 4 | ||||
-rw-r--r-- | app/mailers/emails/notes.rb | 4 | ||||
-rw-r--r-- | app/mailers/emails/profile.rb | 2 | ||||
-rw-r--r-- | app/mailers/emails/projects.rb | 7 |
6 files changed, 22 insertions, 1 deletions
diff --git a/app/mailers/emails/groups.rb b/app/mailers/emails/groups.rb index 1c8ae122c46..1654fc55bca 100644 --- a/app/mailers/emails/groups.rb +++ b/app/mailers/emails/groups.rb @@ -3,7 +3,7 @@ module Emails def group_access_granted_email(user_group_id) @membership = UsersGroup.find(user_group_id) @group = @membership.group - + @target_url = group_url(@group) mail(to: @membership.user.email, subject: subject("Access to group was granted")) end diff --git a/app/mailers/emails/issues.rb b/app/mailers/emails/issues.rb index 3adb47dc5b1..d684e354452 100644 --- a/app/mailers/emails/issues.rb +++ b/app/mailers/emails/issues.rb @@ -3,6 +3,7 @@ module Emails def new_issue_email(recipient_id, issue_id) @issue = Issue.find(issue_id) @project = @issue.project + @target_url = project_issue_url(@project, @issue) mail(from: sender(@issue.author_id), to: recipient(recipient_id), subject: subject("#{@issue.title} (##{@issue.iid})")) @@ -12,6 +13,7 @@ module Emails @issue = Issue.find(issue_id) @previous_assignee = User.find_by(id: previous_assignee_id) if previous_assignee_id @project = @issue.project + @target_url = project_issue_url(@project, @issue) mail(from: sender(updated_by_user_id), to: recipient(recipient_id), subject: subject("#{@issue.title} (##{@issue.iid})")) @@ -21,6 +23,7 @@ module Emails @issue = Issue.find issue_id @project = @issue.project @updated_by = User.find updated_by_user_id + @target_url = project_issue_url(@project, @issue) mail(from: sender(updated_by_user_id), to: recipient(recipient_id), subject: subject("#{@issue.title} (##{@issue.iid})")) @@ -31,6 +34,7 @@ module Emails @issue_status = status @project = @issue.project @updated_by = User.find updated_by_user_id + @target_url = project_issue_url(@project, @issue) mail(from: sender(updated_by_user_id), to: recipient(recipient_id), subject: subject("#{@issue.title} (##{@issue.iid})")) diff --git a/app/mailers/emails/merge_requests.rb b/app/mailers/emails/merge_requests.rb index 0845e14edc7..5e1b8faf13e 100644 --- a/app/mailers/emails/merge_requests.rb +++ b/app/mailers/emails/merge_requests.rb @@ -3,6 +3,7 @@ module Emails def new_merge_request_email(recipient_id, merge_request_id) @merge_request = MergeRequest.find(merge_request_id) @project = @merge_request.project + @target_url = project_merge_request_url(@project, @merge_request) mail(from: sender(@merge_request.author_id), to: recipient(recipient_id), subject: subject("#{@merge_request.title} (!#{@merge_request.iid})")) @@ -12,6 +13,7 @@ module Emails @merge_request = MergeRequest.find(merge_request_id) @previous_assignee = User.find_by(id: previous_assignee_id) if previous_assignee_id @project = @merge_request.project + @target_url = project_merge_request_url(@project, @merge_request) mail(from: sender(updated_by_user_id), to: recipient(recipient_id), subject: subject("#{@merge_request.title} (!#{@merge_request.iid})")) @@ -21,6 +23,7 @@ module Emails @merge_request = MergeRequest.find(merge_request_id) @updated_by = User.find updated_by_user_id @project = @merge_request.project + @target_url = project_merge_request_url(@project, @merge_request) mail(from: sender(updated_by_user_id), to: recipient(recipient_id), subject: subject("#{@merge_request.title} (!#{@merge_request.iid})")) @@ -29,6 +32,7 @@ module Emails def merged_merge_request_email(recipient_id, merge_request_id) @merge_request = MergeRequest.find(merge_request_id) @project = @merge_request.project + @target_url = project_merge_request_url(@project, @merge_request) mail(from: sender(@merge_request.author_id_of_changes), to: recipient(recipient_id), subject: subject("#{@merge_request.title} (!#{@merge_request.iid})")) diff --git a/app/mailers/emails/notes.rb b/app/mailers/emails/notes.rb index 00b127da429..22c4ededf5f 100644 --- a/app/mailers/emails/notes.rb +++ b/app/mailers/emails/notes.rb @@ -4,6 +4,7 @@ module Emails @note = Note.find(note_id) @commit = @note.noteable @project = @note.project + @target_url = project_commit_url(@project, @commit, anchor: "note_#{@note.id}") mail(from: sender(@note.author_id), to: recipient(recipient_id), subject: subject("#{@commit.title} (#{@commit.short_id})")) @@ -13,6 +14,7 @@ module Emails @note = Note.find(note_id) @issue = @note.noteable @project = @note.project + @target_url = project_issue_url(@project, @issue) mail(from: sender(@note.author_id), to: recipient(recipient_id), subject: subject("#{@issue.title} (##{@issue.iid})")) @@ -22,6 +24,7 @@ module Emails @note = Note.find(note_id) @merge_request = @note.noteable @project = @note.project + @target_url = project_merge_request_url(@project, @merge_request, anchor: "note_#{@note.id}") mail(from: sender(@note.author_id), to: recipient(recipient_id), subject: subject("#{@merge_request.title} (!#{@merge_request.iid})")) @@ -30,6 +33,7 @@ module Emails def note_wall_email(recipient_id, note_id) @note = Note.find(note_id) @project = @note.project + @target_url = project_wall_url(@note.project, anchor: "note_#{@note.id}") mail(from: sender(@note.author_id), to: recipient(recipient_id), subject: subject("Note on wall")) diff --git a/app/mailers/emails/profile.rb b/app/mailers/emails/profile.rb index c91660a02b5..f02d95fd557 100644 --- a/app/mailers/emails/profile.rb +++ b/app/mailers/emails/profile.rb @@ -3,6 +3,7 @@ module Emails def new_user_email(user_id, password) @user = User.find(user_id) @password = password + @target_url = user_url(@user) mail(to: @user.email, subject: subject("Account was created for you")) end @@ -15,6 +16,7 @@ module Emails def new_ssh_key_email(key_id) @key = Key.find(key_id) @user = @key.user + @target_url = user_url(@user) mail(to: @user.email, subject: subject("SSH key was added to your account")) end end diff --git a/app/mailers/emails/projects.rb b/app/mailers/emails/projects.rb index 46f24e9fb7c..46aa34d13da 100644 --- a/app/mailers/emails/projects.rb +++ b/app/mailers/emails/projects.rb @@ -3,6 +3,7 @@ module Emails def project_access_granted_email(user_project_id) @users_project = UsersProject.find user_project_id @project = @users_project.project + @target_url = project_url(@project) mail(to: @users_project.user.email, subject: subject("Access to project was granted")) end @@ -10,6 +11,7 @@ module Emails def project_was_moved_email(project_id, user_id) @user = User.find user_id @project = Project.find project_id + @target_url = project_url(@project) mail(to: @user.email, subject: subject("Project was moved")) end @@ -21,6 +23,11 @@ module Emails @commits = Commit.decorate(compare.commits) @diffs = compare.diffs @branch = branch + if @commits.length > 1 + @target_url = project_compare_url(@project, from: @commits.first, to: @commits.last) + else + @target_url = project_commit_url(@project, @compare.commit) + end mail(from: sender(author_id), to: recipient, |