Remove SystemHook observer

This commit is contained in:
Dmitriy Zaporozhets 2014-06-17 22:20:10 +03:00
parent 6149dba518
commit a7d5052cd4
8 changed files with 16 additions and 20 deletions

View file

@ -10,4 +10,8 @@ class BaseObserver < ActiveRecord::Observer
def log_info message def log_info message
Gitlab::AppLogger.info message Gitlab::AppLogger.info message
end end
def system_hook_service
SystemHooksService.new
end
end end

View file

@ -1,17 +0,0 @@
class SystemHookObserver < BaseObserver
observe :user, :project, :users_project
def after_create(model)
system_hook_service.execute_hooks_for(model, :create)
end
def after_destroy(model)
system_hook_service.execute_hooks_for(model, :destroy)
end
private
def system_hook_service
SystemHooksService.new
end
end

View file

@ -1,12 +1,13 @@
class UserObserver < BaseObserver class UserObserver < BaseObserver
def after_create(user) def after_create(user)
log_info("User \"#{user.name}\" (#{user.email}) was created") log_info("User \"#{user.name}\" (#{user.email}) was created")
notification.new_user(user) notification.new_user(user)
system_hook_service.execute_hooks_for(user, :create)
end end
def after_destroy user def after_destroy user
log_info("User \"#{user.name}\" (#{user.email}) was removed") log_info("User \"#{user.name}\" (#{user.email}) was removed")
system_hook_service.execute_hooks_for(user, :destroy)
end end
def after_save user def after_save user

View file

@ -7,6 +7,7 @@ class UsersProjectObserver < BaseObserver
) )
notification.new_team_member(users_project) notification.new_team_member(users_project)
system_hook_service.execute_hooks_for(users_project, :create)
end end
def after_update(users_project) def after_update(users_project)
@ -19,5 +20,6 @@ class UsersProjectObserver < BaseObserver
action: Event::LEFT, action: Event::LEFT,
author_id: users_project.user.id author_id: users_project.user.id
) )
system_hook_service.execute_hooks_for(users_project, :destroy)
end end
end end

View file

@ -28,4 +28,8 @@ class BaseService
def log_info message def log_info message
Gitlab::AppLogger.info message Gitlab::AppLogger.info message
end end
def system_hook_service
SystemHooksService.new
end
end end

View file

@ -52,6 +52,7 @@ module Projects
if @project.save if @project.save
log_info("#{@project.owner.name} created a new project \"#{@project.name_with_namespace}\"") log_info("#{@project.owner.name} created a new project \"#{@project.name_with_namespace}\"")
system_hook_service.execute_hooks_for(@project, :create)
unless @project.group unless @project.group
@project.users_projects.create( @project.users_projects.create(

View file

@ -19,6 +19,8 @@ module Projects
project.satellite.destroy project.satellite.destroy
log_info("Project \"#{project.name}\" was removed") log_info("Project \"#{project.name}\" was removed")
system_hook_service.execute_hooks_for(project, :destroy)
true
end end
end end
end end

View file

@ -19,8 +19,7 @@ module Gitlab
# config.plugins = [ :exception_notification, :ssl_requirement, :all ] # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running. # Activate observers that should always be running.
config.active_record.observers = :system_hook_observer, config.active_record.observers = :user_observer,
:user_observer,
:users_project_observer :users_project_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.