#328: Send email on project change
This commit is contained in:
parent
04964f0171
commit
126cdf1e68
|
@ -52,7 +52,7 @@ class UserMailer < ActionMailer::Base
|
|||
end
|
||||
|
||||
def build_list_notification(build_list, user)
|
||||
I18n.locale = user.language if user.language
|
||||
set_locale user
|
||||
@user, @build_list = user, build_list
|
||||
|
||||
subject = "[№ #{build_list.id}] "
|
||||
|
@ -69,7 +69,7 @@ class UserMailer < ActionMailer::Base
|
|||
end
|
||||
|
||||
def invite_approve_notification(register_request)
|
||||
I18n.locale = register_request.language if register_request.language
|
||||
set_locale register_request
|
||||
@register_request = register_request
|
||||
mail(
|
||||
:to => register_request.email,
|
||||
|
@ -79,8 +79,32 @@ class UserMailer < ActionMailer::Base
|
|||
end
|
||||
end
|
||||
|
||||
def git_delete_branch_notification(user, options)
|
||||
set_locale user
|
||||
mail(
|
||||
:to => user.email,
|
||||
:subject => I18n.t('notifications.subjects.new_commit')
|
||||
) do |format|
|
||||
format.html { render 'git_delete_branch_notification', :locals => options }
|
||||
end
|
||||
end
|
||||
|
||||
def git_new_push_notification(user, options)
|
||||
set_locale user
|
||||
mail(
|
||||
:to => user.email,
|
||||
:subject => I18n.t('notifications.subjects.new_commit')
|
||||
) do |format|
|
||||
format.html { render 'git_new_push_notification', :locals => options }
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_locale(user)
|
||||
I18n.locale = user.language if user.language
|
||||
end
|
||||
|
||||
def email_with_name(user, email = APP_CONFIG['do-not-reply-email'])
|
||||
"\"#{user.user_appeal}\" <#{email}>"
|
||||
end
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
json.user do
|
||||
json.(@user, :id)
|
||||
json.notifiers do
|
||||
json.(@user.notifier, :can_notify, :new_comment, :new_comment_reply, :new_issue, :issue_assign, :new_comment_commit_owner, :new_comment_commit_repo_owner, :new_comment_commit_commentor, :new_build, :new_associated_build)
|
||||
json.(@user.notifier, :can_notify, :new_comment, :new_comment_reply, :new_issue, :issue_assign, :new_comment_commit_owner, :new_comment_commit_repo_owner, :new_comment_commit_commentor, :new_build, :new_associated_build,
|
||||
:new_commit)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
- user = User.where(:email => user_email).first || User.new(:email => user_email) if defined?(user_email)
|
||||
|
||||
%p
|
||||
- _user_link = defined?(user_email) ? user_link(user, defined?(user_name) ? user_name : user_email) : nil
|
||||
= t('notifications.bodies.delete_branch', :branch_name => branch_name, :user_link => _user_link).html_safe
|
||||
= raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_owner, project_name)) )
|
||||
|
||||
= render 'footer'
|
|
@ -0,0 +1,20 @@
|
|||
- user = User.where(:email => user_email).first || User.new(:email => user_email) if defined?(user_email)
|
||||
|
||||
|
||||
%p
|
||||
- _user_link = defined?(user_email) ? user_link(user, defined?(user_name) ? user_name : user_email) : nil
|
||||
= raw t("notifications.bodies.#{change_type}_branch", {:branch_name => branch_name, :user_link => _user_link})
|
||||
= raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_owner, project_name)) )
|
||||
|
||||
|
||||
%p
|
||||
- last_commits.each do |commit|
|
||||
= link_to shortest_hash_id(commit[0]), commit_path(project_owner, project_name, commit[0])
|
||||
= commit[1]
|
||||
%br
|
||||
- if defined? other_commits
|
||||
%br
|
||||
=link_to t('notifications.bodies.more_commits', :count => other_commits_count, :commits => commits_pluralize(other_commits_count)),
|
||||
diff_path(project_owner, project_name, :diff => other_commits)
|
||||
|
||||
= render 'footer'
|
|
@ -9,7 +9,7 @@
|
|||
= form_for @user.notifier, :url => notifiers_settings_path, :html => {:class => :form} do |f|
|
||||
= render 'notifier', :f => f, :field => :can_notify
|
||||
%h3= t("layout.settings.notifiers.code_header")
|
||||
- [:new_comment_commit_owner, :new_comment_commit_repo_owner, :new_comment_commit_commentor].each do |field|
|
||||
- [:new_commit, :new_comment_commit_owner, :new_comment_commit_repo_owner, :new_comment_commit_commentor].each do |field|
|
||||
= render 'notifier', :f => f, :field => field
|
||||
%h3= t("layout.settings.notifiers.tracker_header")
|
||||
- [:new_comment, :new_comment_reply, :new_issue, :issue_assign].each do |field|
|
||||
|
|
|
@ -154,11 +154,11 @@ en:
|
|||
group_already_added: Group already added
|
||||
successfully_added: Member %s successfully added
|
||||
error_in_adding: Member %s adding error
|
||||
wrong_user: User with nickname '%{uname}' not found!
|
||||
wrong_user: "User with nickname '%{uname}' not found!"
|
||||
|
||||
blob:
|
||||
successfully_updated: File '%{name}' successfully updated
|
||||
updating_error: Error updating file '%{name}'
|
||||
successfully_updated: "File '%{name}' successfully updated"
|
||||
updating_error: "Error updating file '%{name}'"
|
||||
|
||||
attributes:
|
||||
password: Password
|
||||
|
@ -188,6 +188,7 @@ en:
|
|||
new_comment_reply: New reply of comment notifications
|
||||
new_issue: New task notifications
|
||||
issue_assign: New task assignment notifications
|
||||
new_commit: Notify about new commits in my projects
|
||||
new_comment_commit_owner: Notify about comments to my commit
|
||||
new_comment_commit_repo_owner: Notify about comments to my repository commits
|
||||
new_comment_commit_commentor: Notify about comments after my commit
|
||||
|
|
|
@ -12,6 +12,7 @@ en:
|
|||
|
||||
notifications:
|
||||
subjects:
|
||||
new_commit: "[%{ project_name }] Update of project"
|
||||
new_comment_notification: New comment to your task
|
||||
new_commit_comment_notification: New comment to commit
|
||||
new_issue_notification: New task added to project
|
||||
|
|
|
@ -12,6 +12,7 @@ ru:
|
|||
|
||||
notifications:
|
||||
subjects:
|
||||
new_commit: "[%{ project_name }] Обновление проекта"
|
||||
new_comment_notification: Новый комментарий к Вашей задаче
|
||||
new_commit_comment_notification: Новый комментарий к коммиту
|
||||
new_issue_notification: Новая задача добавлена к проекту
|
||||
|
|
|
@ -154,11 +154,11 @@ ru:
|
|||
group_already_added: Группа уже добавлена
|
||||
successfully_added: Участник %s успешно добавлен
|
||||
error_in_adding: Ошибка при добавлении участника %s
|
||||
wrong_user: Пользователь с ником '%{uname}' не найден.
|
||||
wrong_user: "Пользователь с ником '%{uname}' не найден."
|
||||
|
||||
blob:
|
||||
successfully_updated: Файл '%{name}' успешно обновлен
|
||||
updating_error: Ошибка обновления файла '%{name}'
|
||||
successfully_updated: "Файл '%{name}' успешно обновлен"
|
||||
updating_error: "Ошибка обновления файла '%{name}'"
|
||||
|
||||
attributes:
|
||||
password: Пароль
|
||||
|
@ -188,6 +188,7 @@ ru:
|
|||
new_comment_reply: Оповещать о новом ответе на мой комментарий
|
||||
new_issue: Оповещать о новых задачах в моих проектах
|
||||
issue_assign: Оповещать, когда на меня выставляют задачу
|
||||
new_commit: Оповещать о новых коммитах в моих проектах
|
||||
new_comment_commit_owner: Оповещать о комментариях к моему коммиту
|
||||
new_comment_commit_repo_owner: Оповещать о комментариях к коммитам в моем репозитории
|
||||
new_comment_commit_commentor: Оповещать о комментариях к коммиту после моего
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddNewCommitToSettingsNotifier < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :settings_notifiers, :new_commit, :boolean, :default => false
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20131107152408) do
|
||||
ActiveRecord::Schema.define(:version => 20131126154305) do
|
||||
|
||||
create_table "activity_feeds", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
|
@ -21,6 +21,8 @@ ActiveRecord::Schema.define(:version => 20131107152408) do
|
|||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
add_index "activity_feeds", ["user_id", "kind"], :name => "index_activity_feeds_on_user_id_and_kind"
|
||||
|
||||
create_table "advisories", :force => true do |t|
|
||||
t.string "advisory_id"
|
||||
t.text "description", :default => ""
|
||||
|
@ -509,7 +511,7 @@ ActiveRecord::Schema.define(:version => 20131107152408) do
|
|||
add_index "repository_statuses", ["repository_id", "platform_id"], :name => "index_repository_statuses_on_repository_id_and_platform_id", :unique => true
|
||||
|
||||
create_table "settings_notifiers", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
t.integer "user_id", :null => false
|
||||
t.boolean "can_notify", :default => true
|
||||
t.boolean "new_comment", :default => true
|
||||
t.boolean "new_comment_reply", :default => true
|
||||
|
@ -522,6 +524,7 @@ ActiveRecord::Schema.define(:version => 20131107152408) do
|
|||
t.boolean "new_comment_commit_commentor", :default => true
|
||||
t.boolean "new_build", :default => true
|
||||
t.boolean "new_associated_build", :default => true
|
||||
t.boolean "new_commit", :default => false
|
||||
end
|
||||
|
||||
create_table "ssh_keys", :force => true do |t|
|
||||
|
|
|
@ -44,6 +44,9 @@ module Modules::Observers::ActivityFeed::Git
|
|||
:kind => kind,
|
||||
:data => options
|
||||
)
|
||||
if recipient.notifier.can_notify && recipient.notifier.new_commit
|
||||
UserMailer.send(kind, recipient, options).deliver
|
||||
end
|
||||
end
|
||||
|
||||
when 'Hash' # 'Gollum::Committer'
|
||||
|
|
Loading…
Reference in New Issue