2012-03-04 14:35:15 +01:00
|
|
|
class KeyObserver < ActiveRecord::Observer
|
2013-01-03 08:06:07 +01:00
|
|
|
include Gitolited
|
2012-08-28 23:04:06 +02:00
|
|
|
|
2012-03-04 14:35:15 +01:00
|
|
|
def after_save(key)
|
2013-02-11 18:27:26 +01:00
|
|
|
GitlabShellWorker.perform_async(
|
2013-02-04 14:07:56 +01:00
|
|
|
:add_key,
|
2013-02-05 10:12:15 +01:00
|
|
|
key.shell_id,
|
2013-02-04 14:07:56 +01:00
|
|
|
key.key
|
2013-01-28 20:02:10 +01:00
|
|
|
)
|
2013-03-19 19:00:41 +01:00
|
|
|
|
|
|
|
# Notify about ssh key being added
|
|
|
|
Notify.delay.new_ssh_key_email(key.id) if key.user
|
2012-03-04 14:35:15 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def after_destroy(key)
|
2013-02-11 18:27:26 +01:00
|
|
|
GitlabShellWorker.perform_async(
|
2013-01-28 20:02:10 +01:00
|
|
|
:remove_key,
|
2013-02-05 10:12:15 +01:00
|
|
|
key.shell_id,
|
2013-02-04 14:07:56 +01:00
|
|
|
key.key,
|
2013-01-28 20:02:10 +01:00
|
|
|
)
|
2012-03-04 14:35:15 +01:00
|
|
|
end
|
|
|
|
end
|