mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-19 15:36: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:
commit
3f72aa114c
4 changed files with 14 additions and 3 deletions
1
Gemfile
1
Gemfile
|
@ -82,6 +82,7 @@ gem 'validates_hostname'
|
||||||
gem 'webpacker'
|
gem 'webpacker'
|
||||||
gem 'yaml_db', git: 'https://0xacab.org/sutty/yaml_db.git'
|
gem 'yaml_db', git: 'https://0xacab.org/sutty/yaml_db.git'
|
||||||
gem 'kaminari'
|
gem 'kaminari'
|
||||||
|
gem 'device_detector'
|
||||||
|
|
||||||
# database
|
# database
|
||||||
gem 'hairtrigger'
|
gem 'hairtrigger'
|
||||||
|
|
|
@ -137,6 +137,7 @@ GEM
|
||||||
rake (> 10, < 14)
|
rake (> 10, < 14)
|
||||||
ruby-statistics (>= 2.1)
|
ruby-statistics (>= 2.1)
|
||||||
thor (>= 0.19, < 2)
|
thor (>= 0.19, < 2)
|
||||||
|
device_detector (1.1.1)
|
||||||
devise (4.9.2)
|
devise (4.9.2)
|
||||||
bcrypt (~> 3.0)
|
bcrypt (~> 3.0)
|
||||||
orm_adapter (~> 0.1)
|
orm_adapter (~> 0.1)
|
||||||
|
@ -582,6 +583,7 @@ DEPENDENCIES
|
||||||
concurrent-ruby-ext
|
concurrent-ruby-ext
|
||||||
database_cleaner
|
database_cleaner
|
||||||
derailed_benchmarks
|
derailed_benchmarks
|
||||||
|
device_detector
|
||||||
devise
|
devise
|
||||||
devise-i18n
|
devise-i18n
|
||||||
devise_invitable
|
devise_invitable
|
||||||
|
|
|
@ -10,7 +10,7 @@ module Api
|
||||||
# solo si la API key es verificable. Del otro lado siempre
|
# solo si la API key es verificable. Del otro lado siempre
|
||||||
# respondemos con lo mismo.
|
# respondemos con lo mismo.
|
||||||
def create
|
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],
|
BacktraceJob.perform_later site_id: params[:site_id],
|
||||||
params: airbrake_params.to_h
|
params: airbrake_params.to_h
|
||||||
end
|
end
|
||||||
|
@ -34,6 +34,11 @@ module Api
|
||||||
def airbrake_token
|
def airbrake_token
|
||||||
@airbrake_token ||= params[:key]
|
@airbrake_token ||= params[:key]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @return [DeviceDetector]
|
||||||
|
def detected_device
|
||||||
|
@detected_device ||= DeviceDetector.new(request.headers['User-Agent'], request.headers)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
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