Merge branch 'notification_refactoring'
This commit is contained in:
commit
54fb0f8589
22 changed files with 265 additions and 65 deletions
|
@ -27,7 +27,6 @@ class Admin::UsersController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
if @admin_user.save
|
||||
Notify.new_user_email(@admin_user, params[:user][:password]).deliver
|
||||
format.html { redirect_to [:admin, @admin_user], notice: 'User was successfully created.' }
|
||||
format.json { render json: @admin_user, status: :created, location: @admin_user }
|
||||
else
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
class ApplicationController < ActionController::Base
|
||||
before_filter :authenticate_user!
|
||||
before_filter :set_current_user_for_mailer
|
||||
protect_from_forgery
|
||||
helper_method :abilities, :can?
|
||||
|
||||
|
@ -19,6 +20,10 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
def set_current_user_for_mailer
|
||||
MailerObserver.current_user = current_user
|
||||
end
|
||||
|
||||
def abilities
|
||||
@abilities ||= Six.new
|
||||
end
|
||||
|
|
|
@ -67,10 +67,7 @@ class IssuesController < ApplicationController
|
|||
def create
|
||||
@issue = @project.issues.new(params[:issue])
|
||||
@issue.author = current_user
|
||||
|
||||
if @issue.save && @issue.assignee != current_user
|
||||
Notify.new_issue_email(@issue).deliver
|
||||
end
|
||||
@issue.save
|
||||
|
||||
respond_with(@issue)
|
||||
end
|
||||
|
|
|
@ -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