#22: change email messages for new Issue/PullRequest/Comment

This commit is contained in:
Vokhmin Alexey V 2013-03-14 18:55:59 +04:00
parent 5971ecb354
commit a9b5826f8f
10 changed files with 42 additions and 54 deletions

View File

@ -8,33 +8,38 @@ class UserMailer < ActionMailer::Base
def new_user_notification(user)
@user = user
mail(:to => user.email, :subject => I18n.t("notifications.subjects.new_user_notification", :project_name => APP_CONFIG['project_name'])) do |format|
mail(:to => email_with_name(user), :subject => I18n.t("notifications.subjects.new_user_notification", :project_name => APP_CONFIG['project_name'])) do |format|
format.html
end
end
def new_comment_notification(comment, user)
@user = user
@comment = comment
@user, @comment = user, comment
subject = @comment.issue_comment? ? subject_for_issue(@comment.commentable) :
I18n.t('notifications.subjects.new_commit_comment_notification')
mail(:to => user.email, :subject => subject) do |format|
mail(
:to => email_with_name(user),
:subject => subject,
:from => email_with_name(comment.user, false)
) do |format|
format.html
end
end
def new_issue_notification(issue, user)
@user = user
@issue = issue
mail(:to => user.email, :subject => subject_for_issue(@issue, true)) do |format|
@user, @issue = user, issue
mail(
:to => email_with_name(user),
:subject => subject_for_issue(issue, true),
:from => email_with_name(issue.user, false)
) do |format|
format.html
end
end
def issue_assign_notification(issue, user)
@user = user
@issue = issue
mail(:to => user.email, :subject => subject_for_issue(@issue)) do |format|
@user, @issue = user, issue
mail(:to => email_with_name(user), :subject => subject_for_issue(@issue)) do |format|
format.html
end
end
@ -47,7 +52,11 @@ class UserMailer < ActionMailer::Base
subject << (build_list.project ? build_list.project.name_with_owner : t("layout.projects.unexisted_project"))
subject << " - #{build_list.human_status} "
subject << I18n.t("notifications.subjects.for_arch", :arch => @build_list.arch.name)
mail(:to => user.email, :subject => subject) do |format|
mail(
:to => email_with_name(user),
:subject => subject,
:from => email_with_name(build_list.user, false)
) do |format|
format.html
end
end
@ -62,6 +71,10 @@ class UserMailer < ActionMailer::Base
protected
def email_with_name(user, user_email = true)
"#{user.user_appeal} <#{user_email ? user.email : APP_CONFIG['do-not-reply-email']}>"
end
def subject_for_issue(issue, new_issue = false)
subject = new_issue ? '' : 'Re: '
subject << "[#{issue.project.name}] #{issue.title} (##{issue.serial_id})"

View File

@ -82,7 +82,7 @@ class User < Avatar
end
def fullname
return name.present? && name.length > 0 ? "#{uname} (#{name})" : uname
return name.present? ? "#{uname} (#{name})" : uname
end
def user_appeal

View File

@ -1,14 +0,0 @@
%p== Hello, #{@user.user_appeal}.
- if @comment.issue_comment?
- link = link_to @comment.commentable.title, project_issue_url(@comment.commentable.project, @comment.commentable)
- object = 'issue'
- elsif @comment.commit_comment?
- link = link_to @comment.commentable.message, commit_url(@comment.project, @comment.commentable_id)
- object = 'commit'
%p #{ link_to @comment.user.uname, user_url(@comment.user)} added new comment to #{object} #{link}.
%p "#{ @comment.body }"
= render 'footer'

View File

@ -0,0 +1,10 @@
- if @comment.issue_comment?
- link = project_issue_url(@comment.commentable.project, @comment.commentable) << '#comment'
- elsif @comment.commit_comment?
- link = commit_url(@comment.project, @comment.commentable.id) << '#diff-comment'
- link << @comment.id.to_s
%p= @comment.body
%p
= t('notifications.bodies.view_it_on')
= link_to APP_CONFIG['project_name'], link
= render 'footer'

View File

@ -1,14 +0,0 @@
%p== Здравствуйте, #{@user.user_appeal}.
- if @comment.issue_comment?
- link = link_to @comment.commentable.title, project_issue_url(@comment.commentable.project, @comment.commentable)
- object = 'задаче'
- elsif @comment.commit_comment?
- link = link_to @comment.commentable.message, commit_url(@comment.project, @comment.commentable_id)
- object = 'коммиту'
%p #{ link_to @comment.user.uname, user_url(@comment.user)} добавил комментарий к #{object} #{link}.
%p "#{ @comment.body }"
= render 'footer'

View File

@ -1,7 +0,0 @@
%p== Hello, #{@user.user_appeal}.
%p To project #{ link_to @issue.project.name, project_url(@issue.project) } has been added an issue #{ link_to @issue.title, project_issue_url(@issue.project, @issue) }
= render 'footer'

View File

@ -0,0 +1,5 @@
%p= @issue.body
%p
= t('notifications.bodies.view_it_on')
= link_to APP_CONFIG['project_name'], project_issue_url(@issue.project, @issue)
= render 'footer'

View File

@ -1,7 +0,0 @@
%p== Здравствуйте, #{@user.user_appeal}.
%p К проекту #{ link_to @issue.project.name, project_url(@issue.project) } была добавлена задача #{ link_to @issue.title, project_issue_url(@issue.project, @issue) }
= render 'footer'

View File

@ -21,6 +21,7 @@ en:
for_arch: for arch %{arch}.
bodies:
view_it_on: View it on
new_comment_notification:
title: '%{user_link} added a new comment'
content: in issue %{issue_link}

View File

@ -21,6 +21,7 @@ ru:
for_arch: для архитектуры %{arch}.
bodies:
view_it_on: Смотрите это на
new_comment_notification:
title: '%{user_link} добавил новый комментарий'
content: к задаче %{issue_link}