Class: AntiAbuse::AbuseReport::CreateService

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/anti_abuse/abuse_report/create_service.rb

Constant Summary

Constants inherited from BaseService

BaseService::UnauthorizedError

Instance Attribute Summary collapse

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

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

#can?, #can_all?, #can_any?

Constructor Details

#initialize(params) ⇒ CreateService

Returns a new instance of CreateService.



8
9
10
# File 'app/services/anti_abuse/abuse_report/create_service.rb', line 8

def initialize(params)
  @params = params.dup
end

Instance Attribute Details

#abuse_reportObject (readonly)

Returns the value of attribute abuse_report.



6
7
8
# File 'app/services/anti_abuse/abuse_report/create_service.rb', line 6

def abuse_report
  @abuse_report
end

Instance Method Details

#executeObject



12
13
14
15
16
17
18
# File 'app/services/anti_abuse/abuse_report/create_service.rb', line 12

def execute
  return error('Reporter param must be a valid User') unless valid_reporter?

  return error('AbuseReport record was not created') unless create_abuse_report

  ServiceResponse.success(payload: abuse_report)
end