ensure useragent is not null

This commit is contained in:
Donovan Daniels 2024-06-11 02:20:34 -05:00
parent dac8ef2283
commit 43f3301237
Signed by: Donovan_DMC
GPG Key ID: 907D29CBFD6157BA
15 changed files with 26 additions and 4 deletions

View File

@ -73,7 +73,7 @@ class ApplicationController < ActionController::Base
APIUsage.create!( APIUsage.create!(
user_id: CurrentUser.is_anonymous? ? nil : CurrentUser.id, user_id: CurrentUser.is_anonymous? ? nil : CurrentUser.id,
api_key: @apikey.nil? || @apikey.is_anon? ? nil : @apikey, api_key: @apikey.nil? || @apikey.is_anon? ? nil : @apikey,
user_agent: request.headers["user-agent"], user_agent: request.headers["user-agent"] || "",
method: request.method, method: request.method,
path: request.path, path: request.path,
params: request.params.to_json, params: request.params.to_json,

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ExceptionsController < ApplicationController class ExceptionsController < ApplicationController
def index def index
@pagy, @exceptions = pagy(ExceptionLog.order(id: :desc), items: 25) @pagy, @exceptions = pagy(ExceptionLog.order(id: :desc), items: 25)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module PoolIndex module PoolIndex
module_function module_function

View File

@ -35,7 +35,7 @@ class APIImage < ApplicationRecord
invalidate_cache invalidate_cache
end end
def file_header_info(file_path) def file_header_info(file_path)
File.open(file_path) do |bin| File.open(file_path) do |bin|
mime_type = Marcel::MimeType.for(bin) mime_type = Marcel::MimeType.for(bin)
ext = case mime_type ext = case mime_type

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module E621 module E621
class Pool < ApplicationRecord class Pool < ApplicationRecord
self.table_name = "e621.pools" self.table_name = "e621.pools"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module E621 module E621
class Post < ApplicationRecord class Post < ApplicationRecord
self.table_name = "e621.posts" self.table_name = "e621.posts"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module E621 module E621
class Tag < ApplicationRecord class Tag < ApplicationRecord
self.table_name = "e621.tags" self.table_name = "e621.tags"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module E621 module E621
class TagAlias < ApplicationRecord class TagAlias < ApplicationRecord
self.table_name = "e621.tag_aliases" self.table_name = "e621.tag_aliases"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module E621 module E621
class TagImplication < ApplicationRecord class TagImplication < ApplicationRecord
self.table_name = "e621.tag_implications" self.table_name = "e621.tag_implications"

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module E621 module E621
class WikiPage < ApplicationRecord class WikiPage < ApplicationRecord
self.table_name = "e621.wiki_pages" self.table_name = "e621.wiki_pages"

View File

@ -8,7 +8,7 @@ class ExceptionLog < ApplicationRecord
host: Socket.gethostname, host: Socket.gethostname,
params: request.filtered_parameters, params: request.filtered_parameters,
referrer: request.referrer, referrer: request.referrer,
user_agent: request.user_agent, user_agent: request.user_agent || "",
} }
# Required to unwrap exceptions that occur inside template rendering. # Required to unwrap exceptions that occur inside template rendering.

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
def cache_store def cache_store
[:memory_store, { size: 64.megabytes }] [:memory_store, { size: 64.megabytes }]
end end

View File

@ -1,5 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
#
Rails.configuration.to_prepare do Rails.configuration.to_prepare do
GitHelper.init GitHelper.init
end end

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CreateE621ExportTables < ActiveRecord::Migration[7.1] class CreateE621ExportTables < ActiveRecord::Migration[7.1]
def change def change
reversible do |r| reversible do |r|

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddE621PoolsTagString < ActiveRecord::Migration[7.1] class AddE621PoolsTagString < ActiveRecord::Migration[7.1]
def change def change
add_column(:"e621.pools", :tag_string, :string, null: false, default: "") add_column(:"e621.pools", :tag_string, :string, null: false, default: "")