Commit a7d5052c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Remove SystemHook observer

parent 6149dba5
......@@ -10,4 +10,8 @@ class BaseObserver < ActiveRecord::Observer
def log_info message
Gitlab::AppLogger.info message
end
def system_hook_service
SystemHooksService.new
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
def after_create(user)
log_info("User \"#{user.name}\" (#{user.email}) was created")
notification.new_user(user)
system_hook_service.execute_hooks_for(user, :create)
end
def after_destroy user
log_info("User \"#{user.name}\" (#{user.email}) was removed")
system_hook_service.execute_hooks_for(user, :destroy)
end
def after_save user
......
......@@ -7,6 +7,7 @@ class UsersProjectObserver < BaseObserver
)
notification.new_team_member(users_project)
system_hook_service.execute_hooks_for(users_project, :create)
end
def after_update(users_project)
......@@ -19,5 +20,6 @@ class UsersProjectObserver < BaseObserver
action: Event::LEFT,
author_id: users_project.user.id
)
system_hook_service.execute_hooks_for(users_project, :destroy)
end
end
......@@ -28,4 +28,8 @@ class BaseService
def log_info message
Gitlab::AppLogger.info message
end
def system_hook_service
SystemHooksService.new
end
end
......@@ -52,6 +52,7 @@ module Projects
if @project.save
log_info("#{@project.owner.name} created a new project \"#{@project.name_with_namespace}\"")
system_hook_service.execute_hooks_for(@project, :create)
unless @project.group
@project.users_projects.create(
......
......@@ -19,6 +19,8 @@ module Projects
project.satellite.destroy
log_info("Project \"#{project.name}\" was removed")
system_hook_service.execute_hooks_for(project, :destroy)
true
end
end
end
......
......@@ -19,8 +19,7 @@ module Gitlab
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
config.active_record.observers = :system_hook_observer,
:user_observer,
config.active_record.observers = :user_observer,
:users_project_observer
# 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