summaryrefslogtreecommitdiff
path: root/app/models/key.rb
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-03-10 17:15:14 +0100
committerRémy Coutable <remy@rymai.me>2016-03-15 11:23:57 +0100
commit76350e2ede187a8bd15e343c30537c90ee557aa7 (patch)
tree6b5081eda7f9c9c2e7b18e86ae1631dd3b5c7f2c /app/models/key.rb
parent9403142083bf0ace81fc3059f2d6c5a494e48cbf (diff)
downloadgitlab-ce-76350e2ede187a8bd15e343c30537c90ee557aa7.tar.gz
Ensure "new SSH key" email do not ends up as dead Sidekiq jobsfix/ensure-no-new_ssh_key_email-dead-jobs
Related to #2235. This is done by: 1. Delaying the notification sending after the SSH key is commited in DB 2. Gracefully exit the mailer method if the record cannot be found
Diffstat (limited to 'app/models/key.rb')
-rw-r--r--app/models/key.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/app/models/key.rb b/app/models/key.rb
index 406a1257b5d..0282ad18139 100644
--- a/app/models/key.rb
+++ b/app/models/key.rb
@@ -16,6 +16,7 @@
require 'digest/md5'
class Key < ActiveRecord::Base
+ include AfterCommitQueue
include Sortable
belongs_to :user
@@ -62,7 +63,7 @@ class Key < ActiveRecord::Base
end
def notify_user
- NotificationService.new.new_key(self)
+ run_after_commit { NotificationService.new.new_key(self) }
end
def post_create_hook