debian-mirror-gitlab/app/services/user_agent_detail_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
580 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2016-09-13 17:45:13 +05:30
class UserAgentDetailService
2021-09-30 23:02:18 +05:30
def initialize(spammable:, spam_params:)
2021-04-29 21:17:54 +05:30
@spammable = spammable
2021-09-30 23:02:18 +05:30
@spam_params = spam_params
2016-09-13 17:45:13 +05:30
end
def create
2021-09-30 23:02:18 +05:30
unless spam_params&.user_agent && spam_params&.ip_address
messasge = 'Skipped UserAgentDetail creation because necessary spam_params were not provided'
return ServiceResponse.success(message: messasge)
end
2016-09-13 17:45:13 +05:30
2021-09-30 23:02:18 +05:30
spammable.create_user_agent_detail(user_agent: spam_params.user_agent, ip_address: spam_params.ip_address)
2016-09-13 17:45:13 +05:30
end
2021-09-30 23:02:18 +05:30
private
attr_reader :spammable, :spam_params
2016-09-13 17:45:13 +05:30
end