notify.rb 3.0 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
D
Dmitriy Zaporozhets 已提交
7
  default_url_options[:port]     = Gitlab.config.web_port if Gitlab.config.web_custom_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
  def new_issue_email(issue_id)
    @issue = Issue.find(issue_id)
R
Riyad Preukschas 已提交
19
    @project = @issue.project
20
    mail(:to => @issue.assignee_email, :subject => "gitlab | New Issue was created")
G
gitlabhq 已提交
21 22
  end

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

30 31 32
  def note_commit_email(recipient_id, note_id)
    recipient = User.find(recipient_id)
    @note = Note.find(note_id)
33
    @commit = @note.target
R
Riyad Preukschas 已提交
34
    @project = @note.project
35
    mail(:to => recipient.email, :subject => "gitlab | note for commit | #{@note.project_name} ")
36
  end
37 38 39 40

  def note_merge_request_email(recipient_id, note_id)
    recipient = User.find(recipient_id)
    @note = Note.find(note_id)
41
    @merge_request = @note.noteable
R
Riyad Preukschas 已提交
42
    @project = @note.project
43
    mail(:to => recipient.email, :subject => "gitlab | note for merge request | #{@note.project_name} ")
G
gitlabhq 已提交
44 45
  end

46 47 48
  def note_issue_email(recipient_id, note_id)
    recipient = User.find(recipient_id)
    @note = Note.find(note_id)
49
    @issue = @note.noteable
R
Riyad Preukschas 已提交
50
    @project = @note.project
51
    mail(:to => recipient.email, :subject => "gitlab | note for issue #{@issue.id} | #{@note.project_name} ")
G
gitlabhq 已提交
52
  end
53

I
Ian Morgan 已提交
54 55 56 57
  def note_wiki_email(recipient_id, note_id)
    recipient = User.find(recipient_id)
    @note = Note.find(note_id)
    @wiki = @note.noteable
R
Riyad Preukschas 已提交
58
    @project = @note.project
I
Ian Morgan 已提交
59 60 61
    mail(:to => recipient.email, :subject => "gitlab | note for wiki | #{@note.project_name}")
  end

62 63
  def new_merge_request_email(merge_request_id)
    @merge_request = MergeRequest.find(merge_request_id)
R
Riyad Preukschas 已提交
64
    @project = @merge_request.project
65
    mail(:to => @merge_request.assignee_email, :subject => "gitlab | new merge request | #{@merge_request.title} ")
66
  end
67 68 69 70 71

  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)
R
Riyad Preukschas 已提交
72
    @project = @merge_request.project
73
    mail(:to => recipient.email, :subject => "gitlab | merge request changed | #{@merge_request.title} ")
74
  end
75 76 77 78 79

  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)
R
Riyad Preukschas 已提交
80
    @project = @issue.project
81
    mail(:to => recipient.email, :subject => "gitlab | changed issue | #{@issue.title} ")
82
  end
G
gitlabhq 已提交
83
end