Commit a7d5052c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Remove SystemHook observer

parent 6149dba5
...@@ -10,4 +10,8 @@ class BaseObserver < ActiveRecord::Observer ...@@ -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
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
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
......
...@@ -7,6 +7,7 @@ class UsersProjectObserver < BaseObserver ...@@ -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 ...@@ -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
...@@ -28,4 +28,8 @@ class BaseService ...@@ -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
...@@ -52,6 +52,7 @@ module Projects ...@@ -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(
......
...@@ -19,6 +19,8 @@ module Projects ...@@ -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
......
...@@ -19,8 +19,7 @@ module Gitlab ...@@ -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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment