mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-16 02:51:42 +00:00
Merge branch 'issue-14334' into 'rails'
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
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:
commit
6bd62b98d6
4 changed files with 14 additions and 3 deletions
1
Gemfile
1
Gemfile
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -9,10 +9,10 @@ module Api
|
|||
# Generar un stacktrace en segundo plano y enviarlo por correo
|
||||
# solo si la API key es verificable. Del otro lado siempre
|
||||
# respondemos con lo mismo.
|
||||
def create
|
||||
if site&.airbrake_valid? airbrake_token
|
||||
def create
|
||||
if (site&.airbrake_valid? airbrake_token) && !detected_device.bot?
|
||||
BacktraceJob.perform_later site_id: params[:site_id],
|
||||
params: airbrake_params.to_h
|
||||
params: airbrake_params.to_h
|
||||
end
|
||||
|
||||
render status: 201, json: { id: 1, url: '' }
|
||||
|
@ -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
|
||||
|
|
3
config/initializers/device_detector.rb
Normal file
3
config/initializers/device_detector.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
DeviceDetector.configure do |config|
|
||||
config.max_cache_keys = 5_000 # to check if not too much
|
||||
end
|
Loading…
Reference in a new issue