Add new method to mailer for deliver emails with push info

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2013-12-17 14:45:55 +02:00
parent 2428a0b2dd
commit d550933907
No known key found for this signature in database
GPG key ID: 627C5F589F467F17
3 changed files with 21 additions and 3 deletions

View file

@ -13,5 +13,15 @@ module Emails
mail(to: @user.email,
subject: subject("Project was moved"))
end
def repository_push_email(project_id, recipient, branch, compare)
@project = Project.find project_id
@commits = compare.commits
@commit = compare.commit
@diffs = compare.diffs
@branch = branch
mail(to: recipient, subject: subject("New push to repository"))
end
end
end

View file

@ -32,8 +32,16 @@ class EmailsOnPushService < Service
'emails_on_push'
end
def execute
true
def execute(push_data)
before_sha = push_data[:before]
after_sha = push_data[:after]
branch = push_data[:ref]
compare = Gitlab::Git::Compare.new(project.repository.raw_repository, before_sha, after_sha)
recipients.split(" ").each do |recipient|
Notify.delay.repository_push_email(project_id, recipient, branch, compare)
end
end
def fields

View file

@ -34,7 +34,7 @@
- if type == 'text'
= f.text_field name, class: "input-xlarge", placeholder: placeholder
- elsif type == 'textarea'
= f.text_area name, rows: 5, class: "input-xlarge", placeholder: placeholder
= f.text_area name, rows: 5, class: "input-xxlarge", placeholder: placeholder
- elsif type == 'checkbox'
= f.check_box name