Notification refactoring
This commit is contained in:
parent
f7859ec1ed
commit
7713f7fefb
7 changed files with 55 additions and 28 deletions
|
@ -12,10 +12,8 @@ class NotesController < ApplicationController
|
|||
def create
|
||||
@note = @project.notes.new(params[:note])
|
||||
@note.author = current_user
|
||||
|
||||
if @note.save
|
||||
notify if params[:notify] == '1'
|
||||
end
|
||||
@note.notify = true if params[:notify] == '1'
|
||||
@note.save
|
||||
|
||||
respond_to do |format|
|
||||
format.html {redirect_to :back}
|
||||
|
@ -35,22 +33,4 @@ class NotesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def notify
|
||||
@project.users.reject { |u| u.id == current_user.id } .each do |u|
|
||||
case @note.noteable_type
|
||||
when "Commit" then
|
||||
Notify.note_commit_email(u, @note).deliver
|
||||
when "Issue" then
|
||||
Notify.note_issue_email(u, @note).deliver
|
||||
when "MergeRequest"
|
||||
true # someone should write email notification
|
||||
when "Snippet"
|
||||
true
|
||||
else
|
||||
Notify.note_wall_email(u, @note).deliver
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue