BigW Consortium Gitlab

key_observer.rb 410 Bytes
Newer Older
1
class KeyObserver < ActiveRecord::Observer
2
  include Gitlab::ShellAdapter
3

4
  def after_save(key)
5
    GitlabShellWorker.perform_async(
6
      :add_key,
7
      key.shell_id,
8
      key.key
9
    )
10 11

    # Notify about ssh key being added
12
    NotificationService.new.new_key(key)
13 14 15
  end

  def after_destroy(key)
16
    GitlabShellWorker.perform_async(
17
      :remove_key,
18
      key.shell_id,
19
      key.key,
20
    )
21 22
  end
end