summaryrefslogtreecommitdiff
path: root/app/models/sent_notification.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-09-21 10:35:56 +0200
committerDouwe Maan <douwe@gitlab.com>2015-09-21 10:35:56 +0200
commit0c833498678603e2fd222a2f6386418822ce0a19 (patch)
tree53eebd325693d42276392d44da6e2dd9f6eef768 /app/models/sent_notification.rb
parentee028d9d60522f8993a0b2429ac8a0631d59229a (diff)
parentd2c90d7494e8ca6b37d4ce57b2bc08f8b1175c4b (diff)
downloadgitlab-ce-0c833498678603e2fd222a2f6386418822ce0a19.tar.gz
Merge branch 'master' into rename-reply-by-email
Diffstat (limited to 'app/models/sent_notification.rb')
-rw-r--r--app/models/sent_notification.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/app/models/sent_notification.rb b/app/models/sent_notification.rb
index 2724af8e613..3eed5c16e45 100644
--- a/app/models/sent_notification.rb
+++ b/app/models/sent_notification.rb
@@ -8,6 +8,7 @@
# noteable_type :string(255)
# recipient_id :integer
# commit_id :string(255)
+# line_code :string(255)
# reply_key :string(255) not null
#
@@ -21,6 +22,7 @@ class SentNotification < ActiveRecord::Base
validates :noteable_id, presence: true, unless: :for_commit?
validates :commit_id, presence: true, if: :for_commit?
+ validates :line_code, format: { with: /\A[a-z0-9]+_\d+_\d+\Z/ }, allow_blank: true
class << self
def reply_key
@@ -33,7 +35,7 @@ class SentNotification < ActiveRecord::Base
find_by(reply_key: reply_key)
end
- def record(noteable, recipient_id, reply_key)
+ def record(noteable, recipient_id, reply_key, params = {})
return unless reply_key
noteable_id = nil
@@ -44,7 +46,7 @@ class SentNotification < ActiveRecord::Base
noteable_id = noteable.id
end
- create(
+ params.reverse_merge!(
project: noteable.project,
noteable_type: noteable.class.name,
noteable_id: noteable_id,
@@ -52,6 +54,14 @@ class SentNotification < ActiveRecord::Base
recipient_id: recipient_id,
reply_key: reply_key
)
+
+ create(params)
+ end
+
+ def record_note(note, recipient_id, reply_key, params = {})
+ params[:line_code] = note.line_code
+
+ record(note.noteable, recipient_id, reply_key, params)
end
end