Class: DraftNotes::PublishService
- Inherits:
-
BaseService
- Object
- BaseService
- BaseService
- DraftNotes::PublishService
- Defined in:
- app/services/draft_notes/publish_service.rb
Constant Summary
Constants inherited from BaseService
BaseService::UnauthorizedError
Instance Attribute Summary
Attributes inherited from BaseService
#current_user, #merge_request, #params
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
Methods inherited from BaseService
#initialize, #merge_request_activity_counter
Methods inherited from BaseService
Methods included from BaseServiceUtility
#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level
Methods included from Gitlab::Allowable
Constructor Details
This class inherits a constructor from DraftNotes::BaseService
Instance Method Details
#execute(draft: nil, executing_user: nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/draft_notes/publish_service.rb', line 5 def execute(draft: nil, executing_user: nil) executing_user ||= current_user return error('Not allowed to create notes') unless can?(executing_user, :create_note, merge_request) review = nil if draft publish_draft_note(draft, executing_user) else review = create_review(executing_user) merge_request_activity_counter.track_publish_review_action(user: current_user) end handle_notifications(current_user, merge_request, review) success rescue ActiveRecord::RecordInvalid => e = "Unable to save #{e.record.class.name}: #{e.record.errors..join(', ')} " error() end |