5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-19 13:26:22 +00:00

Merge branch 'issue-14334' of https://0xacab.org/sutty/sutty into 17.3.alpine.panel.sutty.nl

This commit is contained in:
Sutty 2023-09-26 16:21:18 +00:00
commit 3f72aa114c
4 changed files with 14 additions and 3 deletions

View file

@ -82,6 +82,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

@ -137,6 +137,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)
@ -582,6 +583,7 @@ DEPENDENCIES
concurrent-ruby-ext
database_cleaner
derailed_benchmarks
device_detector
devise
devise-i18n
devise_invitable

View file

@ -10,9 +10,9 @@ 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
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

View file

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