2011-10-08 17:36:38 -04:00
|
|
|
class Notify < ActionMailer::Base
|
2012-05-12 05:01:09 -04:00
|
|
|
include Resque::Mailer
|
2012-04-23 08:32:56 -04:00
|
|
|
add_template_helper ApplicationHelper
|
|
|
|
|
2011-11-25 13:50:27 -05:00
|
|
|
default_url_options[:host] = EMAIL_OPTS["host"]
|
2012-03-31 08:59:06 -04:00
|
|
|
default_url_options[:protocol] = -> { EMAIL_OPTS["protocol"] ? EMAIL_OPTS["protocol"] : "http" }.call
|
|
|
|
|
2011-11-25 13:50:27 -05:00
|
|
|
default from: EMAIL_OPTS["from"]
|
2011-10-08 17:36:38 -04:00
|
|
|
|
|
|
|
def new_user_email(user, password)
|
|
|
|
@user = user
|
|
|
|
@password = password
|
2012-05-12 05:01:09 -04:00
|
|
|
mail(:to => @user['email'], :subject => "gitlab | Account was created for you")
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def new_issue_email(issue)
|
2012-05-12 05:01:09 -04:00
|
|
|
@issue = Issue.find(issue['id'])
|
|
|
|
@user = @issue.assignee
|
|
|
|
@project = @issue.project
|
2011-10-08 17:36:38 -04:00
|
|
|
|
2011-11-25 13:50:27 -05:00
|
|
|
mail(:to => @user.email, :subject => "gitlab | New Issue was created")
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def note_wall_email(user, note)
|
|
|
|
@user = user
|
2012-05-12 05:01:09 -04:00
|
|
|
@note = Note.find(note['id'])
|
|
|
|
@project = @note.project
|
|
|
|
mail(:to => @user['email'], :subject => "gitlab | #{@note.project.name} ")
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def note_commit_email(user, note)
|
|
|
|
@user = user
|
2012-05-12 05:01:09 -04:00
|
|
|
@note = Note.find(note['id'])
|
|
|
|
@project = @note.project
|
2012-02-09 21:59:39 -05:00
|
|
|
@commit = @note.target
|
2012-05-12 05:01:09 -04:00
|
|
|
mail(:to => @user['email'], :subject => "gitlab | note for commit | #{@note.project.name} ")
|
2011-12-18 09:29:58 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def note_merge_request_email(user, note)
|
|
|
|
@user = user
|
2012-05-12 05:01:09 -04:00
|
|
|
@note = Note.find(note['id'])
|
|
|
|
@project = @note.project
|
|
|
|
@merge_request = @note.noteable
|
|
|
|
mail(:to => @user['email'], :subject => "gitlab | note for merge request | #{@note.project.name} ")
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def note_issue_email(user, note)
|
|
|
|
@user = user
|
2012-05-12 05:01:09 -04:00
|
|
|
@note = Note.find(note['id'])
|
|
|
|
@project = @note.project
|
|
|
|
@issue = @note.noteable
|
|
|
|
mail(:to => @user['email'], :subject => "gitlab | note for issue #{@issue.id} | #{@note.project.name} ")
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
2011-12-17 11:07:28 -05:00
|
|
|
|
|
|
|
def new_merge_request_email(merge_request)
|
2012-05-12 05:01:09 -04:00
|
|
|
@merge_request = MergeRequest.find(merge_request['id'])
|
|
|
|
@user = @merge_request.assignee
|
|
|
|
@project = @merge_request.project
|
2012-01-07 06:03:31 -05:00
|
|
|
mail(:to => @user.email, :subject => "gitlab | new merge request | #{@merge_request.title} ")
|
2011-12-17 11:07:28 -05:00
|
|
|
end
|
2011-12-18 08:46:06 -05:00
|
|
|
|
|
|
|
def changed_merge_request_email(user, merge_request)
|
|
|
|
@user = user
|
2012-05-14 20:19:28 -04:00
|
|
|
@merge_request = MergeRequest.find(merge_request.id)
|
2012-05-12 05:01:09 -04:00
|
|
|
@assignee_was ||= User.find(@merge_request.assignee_id_was)
|
|
|
|
@project = @merge_request.project
|
|
|
|
mail(:to => @user['email'], :subject => "gitlab | merge request changed | #{@merge_request.title} ")
|
2011-12-18 08:46:06 -05:00
|
|
|
end
|
2011-12-18 09:07:47 -05:00
|
|
|
|
|
|
|
def changed_issue_email(user, issue)
|
2012-05-12 05:01:09 -04:00
|
|
|
@issue = Issue.find(issue['id'])
|
2011-12-18 09:07:47 -05:00
|
|
|
@user = user
|
2012-05-12 05:01:09 -04:00
|
|
|
@assignee_was ||= User.find(@issue.assignee_id_was)
|
|
|
|
@project = @issue.project
|
|
|
|
mail(:to => @user['email'], :subject => "gitlab | changed issue | #{@issue.title} ")
|
2011-12-18 09:07:47 -05:00
|
|
|
end
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|