summaryrefslogtreecommitdiff
path: root/app/services/notes/create_service.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-11-27 22:12:02 +0800
committerDouwe Maan <douwe@selenight.nl>2016-11-30 17:46:46 +0800
commit842486f5c812a5a1c7eb585a14f7acbee92ad3a6 (patch)
tree5c64aca547dd08308c9bb755636c16cce60803c1 /app/services/notes/create_service.rb
parent098066050d148deb024fdec6c36bfe9320c674bd (diff)
downloadgitlab-ce-new-resolvable-discussion.tar.gz
Diffstat (limited to 'app/services/notes/create_service.rb')
-rw-r--r--app/services/notes/create_service.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/services/notes/create_service.rb b/app/services/notes/create_service.rb
index d75592e31f3..82bde6f38bc 100644
--- a/app/services/notes/create_service.rb
+++ b/app/services/notes/create_service.rb
@@ -1,10 +1,19 @@
module Notes
class CreateService < BaseService
def execute
+ in_reply_to_discussion_id = params.delete(:in_reply_to_discussion_id)
+
+ params[:type] = DiscussionNote.name if params.delete(:new_discussion)
+
note = project.notes.new(params)
note.author = current_user
note.system = false
+ if note.is_a?(DiscussionNote) && in_reply_to_discussion_id
+ discussion_exists = note.noteable.notes.discussion_notes.find_discussion(in_reply_to_discussion_id)
+ note.in_reply_to_discussion_id = in_reply_to_discussion_id if discussion_exists
+ end
+
if note.award_emoji?
noteable = note.noteable
if noteable.user_can_award?(current_user, note.award_emoji_name)