debian-mirror-gitlab/app/services/notes/update_service.rb

32 lines
790 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2015-04-26 12:48:37 +05:30
module Notes
class UpdateService < BaseService
2015-09-11 14:41:01 +05:30
def execute(note)
return note unless note.editable?
2015-04-26 12:48:37 +05:30
2017-08-17 22:00:37 +05:30
old_mentioned_users = note.mentioned_users.to_a
2018-11-18 11:00:15 +05:30
note.update(params.merge(updated_by: current_user))
2015-11-26 14:37:03 +05:30
note.create_new_cross_references!(current_user)
2015-04-26 12:48:37 +05:30
2016-04-02 18:10:28 +05:30
if note.previous_changes.include?('note')
2017-08-17 22:00:37 +05:30
TodoService.new.update_note(note, current_user, old_mentioned_users)
2016-04-02 18:10:28 +05:30
end
2018-12-23 12:14:25 +05:30
if note.supports_suggestion?
Suggestion.transaction do
note.suggestions.delete_all
Suggestions::CreateService.new(note).execute
end
# We need to refresh the previous suggestions call cache
# in order to get the new records.
note.reload
end
2015-04-26 12:48:37 +05:30
note
end
end
end