diff options
author | Lukas Erlacher <erlacher@in.tum.de> | 2014-08-18 16:46:46 +0200 |
---|---|---|
committer | Lukas Erlacher <erlacher@in.tum.de> | 2014-09-03 01:27:02 +0200 |
commit | 40fc4261f2e6c8eaf6e885405863e929ecbd47b3 (patch) | |
tree | 236e7f674a1983e19a74507fc9d9b54021073caa /app | |
parent | 00ccaed029efbbdff96a4b64628a3a2d9bf5125d (diff) | |
download | gitlab-ce-40fc4261f2e6c8eaf6e885405863e929ecbd47b3.tar.gz |
Add system hook for ssh key changes
Add system hook for ssh key create and destroy
Update and fix documentation
Update tests
Diffstat (limited to 'app')
-rw-r--r-- | app/models/key.rb | 10 | ||||
-rw-r--r-- | app/services/system_hooks_service.rb | 10 |
2 files changed, 20 insertions, 0 deletions
diff --git a/app/models/key.rb b/app/models/key.rb index d59993b1905..095c73d8baf 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -29,7 +29,9 @@ class Key < ActiveRecord::Base after_create :add_to_shell after_create :notify_user + after_create :post_create_hook after_destroy :remove_from_shell + after_destroy :post_destroy_hook def strip_white_space self.key = key.strip unless key.blank? @@ -56,6 +58,10 @@ class Key < ActiveRecord::Base NotificationService.new.new_key(self) end + def post_create_hook + SystemHooksService.new.execute_hooks_for(self, :create) + end + def remove_from_shell GitlabShellWorker.perform_async( :remove_key, @@ -64,6 +70,10 @@ class Key < ActiveRecord::Base ) end + def post_destroy_hook + SystemHooksService.new.execute_hooks_for(self, :destroy) + end + private def generate_fingerpint diff --git a/app/services/system_hooks_service.rb b/app/services/system_hooks_service.rb index 41014f199d5..bfc725e5eb5 100644 --- a/app/services/system_hooks_service.rb +++ b/app/services/system_hooks_service.rb @@ -22,6 +22,16 @@ class SystemHooksService } case model + when Key + data.merge!( + key: model.key, + id: model.id + ) + if model.user + data.merge!( + username: model.user.username + ) + end when Project owner = model.owner |