5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-16 05:21:42 +00:00

Merge branch 'issue-14334' into 'rails'
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

Ignorar reportes de Bots (Device_detector)

See merge request sutty/sutty!205
This commit is contained in:
fauno 2023-09-26 16:33:11 +00:00
commit 6bd62b98d6
4 changed files with 14 additions and 3 deletions

View file

@ -78,6 +78,7 @@ gem 'validates_hostname'
gem 'webpacker'
gem 'yaml_db', git: 'https://0xacab.org/sutty/yaml_db.git'
gem 'kaminari'
gem 'device_detector'
# database
gem 'hairtrigger'

View file

@ -142,6 +142,7 @@ GEM
rake (> 10, < 14)
ruby-statistics (>= 2.1)
thor (>= 0.19, < 2)
device_detector (1.1.1)
devise (4.9.2)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
@ -592,6 +593,7 @@ DEPENDENCIES
concurrent-ruby-ext
database_cleaner
derailed_benchmarks
device_detector
devise
devise-i18n
devise_invitable

View file

@ -10,7 +10,7 @@ module Api
# solo si la API key es verificable. Del otro lado siempre
# respondemos con lo mismo.
def create
if site&.airbrake_valid? airbrake_token
if (site&.airbrake_valid? airbrake_token) && !detected_device.bot?
BacktraceJob.perform_later site_id: params[:site_id],
params: airbrake_params.to_h
end
@ -34,6 +34,11 @@ module Api
def airbrake_token
@airbrake_token ||= params[:key]
end
# @return [DeviceDetector]
def detected_device
@detected_device ||= DeviceDetector.new(request.headers['User-Agent'], request.headers)
end
end
end
end

View file

@ -0,0 +1,3 @@
DeviceDetector.configure do |config|
config.max_cache_keys = 5_000 # to check if not too much
end