blob: ccb5cec2df8848716f7e4a499b26915908f36db2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# frozen_string_literal: true
class UserAgentDetailService
def initialize(spammable:, perform_spam_check:)
@spammable = spammable
@perform_spam_check = perform_spam_check
end
def create
spam_params = Gitlab::RequestContext.instance.spam_params
if !perform_spam_check || spam_params&.user_agent.blank? || spam_params&.ip_address.blank?
message = 'Skipped UserAgentDetail creation because necessary spam_params were not provided'
return ServiceResponse.success(message: message)
end
spammable.create_user_agent_detail(user_agent: spam_params.user_agent, ip_address: spam_params.ip_address)
end
private
attr_reader :spammable, :perform_spam_check
end
|