Class: Snippets::CreateService
- Inherits:
-
BaseService
- Object
- BaseService
- BaseService
- Snippets::CreateService
- Defined in:
- app/services/snippets/create_service.rb
Constant Summary
Constants inherited from BaseService
BaseService::CreateRepositoryError
Instance Attribute Summary
Attributes inherited from BaseService
#snippet_actions, #uploaded_assets
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
Methods inherited from BaseService
Methods included from SpamCheckMethods
#filter_spam_check_params, #spam_check
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 Snippets::BaseService
Instance Method Details
#execute ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/services/snippets/create_service.rb', line 5 def execute @snippet = build_from_params return invalid_params_error(@snippet) unless valid_params? unless visibility_allowed?(@snippet, @snippet.visibility_level) return forbidden_visibility_error(@snippet) end @snippet. = current_user spam_check(@snippet, current_user, action: :create) if save_and_commit UserAgentDetailService.new(@snippet, @request).create Gitlab::UsageDataCounters::SnippetCounter.count(:create) move_temporary_files ServiceResponse.success(payload: { snippet: @snippet } ) else snippet_error_response(@snippet, 400) end end |