gitlab-org--gitlab-foss/app/services/notes/create_service.rb

24 lines
600 B
Ruby
Raw Normal View History

2012-07-31 01:32:49 -04:00
module Notes
class CreateService < BaseService
2012-07-31 01:32:49 -04:00
def execute
2014-06-17 15:09:01 -04:00
note = project.notes.new(params)
2012-07-31 01:32:49 -04:00
note.author = current_user
note.system = false
2014-06-17 15:09:01 -04:00
2016-04-16 15:09:08 -04:00
if note.award_emoji?
2016-05-17 13:28:17 -04:00
noteable = note.noteable
todo_service.new_award_emoji(noteable, current_user)
return noteable.create_award_emoji(note.award_emoji_name, current_user)
2016-04-16 15:09:08 -04:00
end
2014-06-17 15:09:01 -04:00
if note.save
# Finish the harder work in the background
NewNoteWorker.perform_in(2.seconds, note.id, params)
2016-02-20 08:59:59 -05:00
TodoService.new.new_note(note, current_user)
2014-06-17 15:09:01 -04:00
end
2012-07-31 01:32:49 -04:00
note
end
end
end