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
path: root/app
diff options
context:
space:
mode:
authorToon Claes <toon@iotcl.com>2017-12-09 00:45:57 +0300
committerToon Claes <toon@iotcl.com>2017-12-13 23:26:01 +0300
commitf55aaca561986757343fb410a9e6c09cfcc61385 (patch)
tree1c84b54d8cefa3af4768af4cf31740107f188cb2 /app
parent2acf3a564c4d042b4cf5463867bd5d37723509f5 (diff)
Make discussion mail References all notes in the discussion
When a note is part of a discussion, the email sent out will be `In-Reply-To` the previous note in that discussion. It also `References` all the previous notes in that discussion, and the original issue. Closes gitlab-org/gitlab-ce#36054.
Diffstat (limited to 'app')
-rw-r--r--app/mailers/notify.rb8
-rw-r--r--app/models/note.rb9
2 files changed, 9 insertions, 8 deletions
diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb
index 250583d2d28..ec886e993c3 100644
--- a/app/mailers/notify.rb
+++ b/app/mailers/notify.rb
@@ -119,8 +119,8 @@ class Notify < BaseMailer
headers['Reply-To'] = address
fallback_reply_message_id = "<reply-#{reply_key}@#{Gitlab.config.gitlab.host}>".freeze
- headers['References'] ||= ''
- headers['References'] << ' ' << fallback_reply_message_id
+ headers['References'] ||= []
+ headers['References'] << fallback_reply_message_id
@reply_by_email = true
end
@@ -158,8 +158,8 @@ class Notify < BaseMailer
def mail_answer_note_thread(model, note, headers = {})
headers['Message-ID'] = message_id(note)
- headers['In-Reply-To'] = message_id(note.replies_to)
- headers['References'] = message_id(model)
+ headers['In-Reply-To'] = message_id(note.references.last)
+ headers['References'] = note.references.map { |ref| message_id(ref) }
headers['X-GitLab-Discussion-ID'] = note.discussion.id if note.part_of_discussion?
diff --git a/app/models/note.rb b/app/models/note.rb
index ea31bc45c61..184fbd5f5ae 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -360,13 +360,14 @@ class Note < ActiveRecord::Base
end
end
- def replies_to
+ def references
+ refs = [noteable]
+
if part_of_discussion?
- previous_note = discussion.notes.take_while { |n| n.id < id }.last
- return previous_note if previous_note
+ refs += discussion.notes.take_while { |n| n.id < id }
end
- noteable
+ refs
end
def expire_etag_cache