BigW Consortium Gitlab

notify.rb 2.28 KB
Newer Older
gitlabhq committed
1
class Notify < ActionMailer::Base
2 3
  default_url_options[:host] = EMAIL_OPTS["host"]
  default from: EMAIL_OPTS["from"]
gitlabhq committed
4 5 6 7

  def new_user_email(user, password)
    @user = user
    @password = password
8
    mail(:to => @user.email, :subject => "gitlab | Account was created for you")
gitlabhq committed
9 10 11 12 13 14 15
  end

  def new_issue_email(issue)
    @user = issue.assignee
    @project = issue.project
    @issue = issue

16
    mail(:to => @user.email, :subject => "gitlab | New Issue was created")
gitlabhq committed
17 18 19 20 21 22
  end

  def note_wall_email(user, note)
    @user = user
    @note = note
    @project = note.project
23
    mail(:to => @user.email, :subject => "gitlab | #{@note.project.name} ")
gitlabhq committed
24 25 26 27 28 29 30
  end

  def note_commit_email(user, note)
    @user = user
    @note = note
    @project = note.project
    @commit = @project.repo.commits(note.noteable_id).first
31
    return unless ( note.notify or ( note.notify_author and @commit.author.email == @user.email ) )
32
    mail(:to => @user.email, :subject => "gitlab | note for commit | #{@note.project.name} ")
33 34 35 36 37 38 39
  end
  
  def note_merge_request_email(user, note)
    @user = user
    @note = note
    @project = note.project
    @merge_request = note.noteable
40
    mail(:to => @user.email, :subject => "gitlab | note for merge request | #{@note.project.name} ")
gitlabhq committed
41 42 43 44 45 46 47
  end

  def note_issue_email(user, note)
    @user = user
    @note = note
    @project = note.project
    @issue = note.noteable
48
    mail(:to => @user.email, :subject => "gitlab | note for issue #{@issue.id} | #{@note.project.name} ")
gitlabhq committed
49
  end
50 51 52 53 54
  
  def new_merge_request_email(merge_request)
    @user = merge_request.assignee
    @merge_request = merge_request
    @project = merge_request.project
55
    mail(:to => @user.email, :subject => "gitlab | new merge request | #{@merge_request.title} ")
56
  end
57 58 59 60 61 62
  
  def changed_merge_request_email(user, merge_request)
    @user = user
    @assignee_was ||= User.find(merge_request.assignee_id_was)
    @merge_request = merge_request
    @project = merge_request.project
63
    mail(:to => @user.email, :subject => "gitlab | merge request changed | #{@merge_request.title} ")
64
  end
65 66 67 68 69 70
  
  def changed_issue_email(user, issue)
    @user = user
    @assignee_was ||= User.find(issue.assignee_id_was)
    @issue = issue
    @project = issue.project
71
    mail(:to => @user.email, :subject => "gitlab | changed issue | #{@issue.title} ")
72
  end
gitlabhq committed
73
end