From 842486f5c812a5a1c7eb585a14f7acbee92ad3a6 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Sun, 27 Nov 2016 22:12:02 +0800 Subject: WIP --- app/services/notes/create_service.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app/services/notes/create_service.rb') 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) -- cgit v1.2.1