summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-17 22:20:10 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-17 22:20:10 +0300
commita7d5052cd4e117768d9c32f582ed72d2cc98e5e6 (patch)
tree698e48b84d1daa4d711339af881be5dba9ce62f7 /app
parent6149dba5189b9f32b3a9caf0c4c585a973ec99fb (diff)
downloadgitlab-ce-a7d5052cd4e117768d9c32f582ed72d2cc98e5e6.tar.gz
Remove SystemHook observer
Diffstat (limited to 'app')
-rw-r--r--app/observers/base_observer.rb4
-rw-r--r--app/observers/system_hook_observer.rb17
-rw-r--r--app/observers/user_observer.rb3
-rw-r--r--app/observers/users_project_observer.rb2
-rw-r--r--app/services/base_service.rb4
-rw-r--r--app/services/projects/create_service.rb1
-rw-r--r--app/services/projects/destroy_service.rb2
7 files changed, 15 insertions, 18 deletions
diff --git a/app/observers/base_observer.rb b/app/observers/base_observer.rb
index 260d1f05db3..5a821d269a2 100644
--- a/app/observers/base_observer.rb
+++ b/app/observers/base_observer.rb
@@ -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
diff --git a/app/observers/system_hook_observer.rb b/app/observers/system_hook_observer.rb
deleted file mode 100644
index 80de177b9a2..00000000000
--- a/app/observers/system_hook_observer.rb
+++ /dev/null
@@ -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
diff --git a/app/observers/user_observer.rb b/app/observers/user_observer.rb
index fba0f1006d9..a7b1a857e29 100644
--- a/app/observers/user_observer.rb
+++ b/app/observers/user_observer.rb
@@ -1,12 +1,13 @@
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
diff --git a/app/observers/users_project_observer.rb b/app/observers/users_project_observer.rb
index 44c72b30187..b0c37d1d222 100644
--- a/app/observers/users_project_observer.rb
+++ b/app/observers/users_project_observer.rb
@@ -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
diff --git a/app/services/base_service.rb b/app/services/base_service.rb
index 9ad80923152..31b38aca530 100644
--- a/app/services/base_service.rb
+++ b/app/services/base_service.rb
@@ -28,4 +28,8 @@ class BaseService
def log_info message
Gitlab::AppLogger.info message
end
+
+ def system_hook_service
+ SystemHooksService.new
+ end
end
diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb
index 25c9f0e53b5..dfadcfd296a 100644
--- a/app/services/projects/create_service.rb
+++ b/app/services/projects/create_service.rb
@@ -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(
diff --git a/app/services/projects/destroy_service.rb b/app/services/projects/destroy_service.rb
index 8c265199217..9f05f390076 100644
--- a/app/services/projects/destroy_service.rb
+++ b/app/services/projects/destroy_service.rb
@@ -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