notify.rb 2.5 KB
Newer Older
G
gitlabhq 已提交
1
class Notify < ActionMailer::Base
2
  include Resque::Mailer
G
gitlabhq 已提交
3 4
  add_template_helper ApplicationHelper

D
Dmitriy Zaporozhets 已提交
5
  default_url_options[:host] = EMAIL_OPTS["host"]
D
Dmitriy Zaporozhets 已提交
6 7
  default_url_options[:protocol] = -> { EMAIL_OPTS["protocol"] ? EMAIL_OPTS["protocol"] : "http" }.call

D
Dmitriy Zaporozhets 已提交
8
  default from: EMAIL_OPTS["from"]
G
gitlabhq 已提交
9

10 11
  def new_user_email(user_id, password)
    @user = User.find(user_id)
G
gitlabhq 已提交
12
    @password = password
13
    mail(:to => @user.email, :subject => "gitlab | Account was created for you")
G
gitlabhq 已提交
14 15
  end

16 17 18
  def new_issue_email(issue_id)
    @issue = Issue.find(issue_id)
    mail(:to => @issue.assignee_email, :subject => "gitlab | New Issue was created")
G
gitlabhq 已提交
19 20
  end

21 22 23
  def note_wall_email(recipient_id, note_id)
    recipient = User.find(recipient_id)
    @note = Note.find(note_id)
24
    mail(:to => recipient.email, :subject => "gitlab | #{@note.project_name} ")
G
gitlabhq 已提交
25 26
  end

27 28 29
  def note_commit_email(recipient_id, note_id)
    recipient = User.find(recipient_id)
    @note = Note.find(note_id)
30
    @commit = @note.target
31
    mail(:to => recipient.email, :subject => "gitlab | note for commit | #{@note.project_name} ")
32
  end
33 34 35 36

  def note_merge_request_email(recipient_id, note_id)
    recipient = User.find(recipient_id)
    @note = Note.find(note_id)
37
    @merge_request = @note.noteable
38
    mail(:to => recipient.email, :subject => "gitlab | note for merge request | #{@note.project_name} ")
G
gitlabhq 已提交
39 40
  end

41 42 43
  def note_issue_email(recipient_id, note_id)
    recipient = User.find(recipient_id)
    @note = Note.find(note_id)
44
    @issue = @note.noteable
45
    mail(:to => recipient.email, :subject => "gitlab | note for issue #{@issue.id} | #{@note.project_name} ")
G
gitlabhq 已提交
46
  end
47

48 49 50
  def new_merge_request_email(merge_request_id)
    @merge_request = MergeRequest.find(merge_request_id)
    mail(:to => @merge_request.assignee_email, :subject => "gitlab | new merge request | #{@merge_request.title} ")
51
  end
52 53 54 55 56 57

  def reassigned_merge_request_email(recipient_id, merge_request_id, previous_assignee_id)
    recipient = User.find(recipient_id)
    @merge_request = MergeRequest.find(merge_request_id)
    @previous_assignee ||= User.find(previous_assignee_id)
    mail(:to => recipient.email, :subject => "gitlab | merge request changed | #{@merge_request.title} ")
58
  end
59 60 61 62 63 64

  def reassigned_issue_email(recipient_id, issue_id, previous_assignee_id)
    recipient = User.find(recipient_id)
    @issue = Issue.find(issue_id)
    @previous_assignee ||= User.find(previous_assignee_id)
    mail(:to => recipient.email, :subject => "gitlab | changed issue | #{@issue.title} ")
65
  end
G
gitlabhq 已提交
66
end