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!(
user_id: CurrentUser.is_anonymous? ? nil : CurrentUser.id,
api_key: @apikey.nil? || @apikey.is_anon? ? nil : @apikey,
user_agent: request.headers["user-agent"],
user_agent: request.headers["user-agent"] || "",
method: request.method,
path: request.path,
params: request.params.to_json,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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