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
|
|
|
|
|
2019-02-15 15:39:39 +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.
|
2019-07-31 22:56:46 +05:30
|
|
|
note.reset
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
note
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|