Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-09-20 19:18:39 +0300
committerDouwe Maan <douwe@gitlab.com>2015-09-20 19:18:39 +0300
commit3377808193e8571b028fd05f009a7d1089dcc916 (patch)
tree99d6b29ea58bed563b5ef453450485f49e8da2bf /app/models/sent_notification.rb
parent11bbc06b4bbcb678f3ee6b8f1d143ed86d25a76c (diff)
Fix reply by email for comments on a specific line in a diff/commit.
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 33b113a2a27..03425389dd3 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,13 +22,14 @@ 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 for(reply_key)
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
@@ -38,7 +40,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,
@@ -46,6 +48,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