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

5
  default_url_options[:host]     = Gitlab.config.web_host
6
  default_url_options[:protocol] = Gitlab.config.web_protocol
7
  default_url_options[:port]     = Gitlab.config.web_port
D
Dmitriy Zaporozhets 已提交
8

9
  default from: Gitlab.config.email_from
G
gitlabhq 已提交
10

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

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

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

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

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

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

49 50 51
  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} ")
52
  end
53 54 55 56 57 58

  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} ")
59
  end
60 61 62 63 64 65

  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} ")
66
  end
G
gitlabhq 已提交
67
end