allow forcing the creation of an e621 status change
This commit is contained in:
parent
e7518a5c0f
commit
107acfb155
|
@ -1,15 +1,15 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module E621StatusUpdater
|
module E621StatusUpdater
|
||||||
def self.run
|
def self.run(force: E621Status.count == 0)
|
||||||
return if Rails.env.development?
|
return if Rails.env.development?
|
||||||
status = Requests::E621.status
|
status = Requests::E621.status
|
||||||
previous_status = Cache.redis.get("e621_status:current").to_i
|
previous_status = Cache.redis.get("e621_status:current").to_i
|
||||||
last_change_time = Cache.redis.get("e621_status:last_change_time")
|
last_change_time = Cache.redis.get("e621_status:last_change_time")
|
||||||
last_change_time = Time.parse(last_change_time) if last_change_time.present?
|
last_change_time = Time.parse(last_change_time) if last_change_time.present?
|
||||||
if previous_status == status
|
if previous_status == status && !force
|
||||||
Cache.redis.set("e621_status:last_change_time", (Time.now - 2.seconds).to_s)
|
Cache.redis.set("e621_status:last_change_time", (Time.now - 2.seconds).to_s)
|
||||||
elsif last_change_time.nil? || (Time.now - last_change_time) >= 3.minutes
|
elsif last_change_time.nil? || (Time.now - last_change_time) >= 3.minutes || force
|
||||||
Rails.logger.debug { "Updating status: #{previous_status} -> #{status}" }
|
Rails.logger.debug { "Updating status: #{previous_status} -> #{status}" }
|
||||||
Cache.redis.set("e621_status:current", status.to_s)
|
Cache.redis.set("e621_status:current", status.to_s)
|
||||||
Cache.redis.set("e621_status:last_change_time", (Time.now - 2.seconds).to_s)
|
Cache.redis.set("e621_status:last_change_time", (Time.now - 2.seconds).to_s)
|
||||||
|
|
|
@ -136,7 +136,7 @@ module Websites
|
||||||
|
|
||||||
def common_headers(domain)
|
def common_headers(domain)
|
||||||
{
|
{
|
||||||
"Report-To": {
|
"Report-To": {
|
||||||
group: "default",
|
group: "default",
|
||||||
max_age: 31_536_000,
|
max_age: 31_536_000,
|
||||||
endpoints: [
|
endpoints: [
|
||||||
|
@ -144,23 +144,23 @@ module Websites
|
||||||
],
|
],
|
||||||
include_subdomains: true,
|
include_subdomains: true,
|
||||||
}.to_json,
|
}.to_json,
|
||||||
"NEL": {
|
"NEL": {
|
||||||
report_to: "default",
|
report_to: "default",
|
||||||
max_age: 31_536_000,
|
max_age: 31_536_000,
|
||||||
include_subdomains: true,
|
include_subdomains: true,
|
||||||
}.to_json,
|
}.to_json,
|
||||||
"Strict-Transport-Security": "max-age=63072000; includeSubDomains; preload",
|
"Strict-Transport-Security": "max-age=63072000; includeSubDomains; preload",
|
||||||
"Expect-CT": "max-age=63072000, enforce, report-uri=\"https://yiff.report-uri.com/r/d/ct/enforce\"",
|
"Expect-CT": "max-age=63072000, enforce, report-uri=\"https://yiff.report-uri.com/r/d/ct/enforce\"",
|
||||||
"Upgrade-Insecure-Requests": "1",
|
"Upgrade-Insecure-Requests": "1",
|
||||||
"Referrer-Policy": "strict-origin-when-cross-origin",
|
"Referrer-Policy": "strict-origin-when-cross-origin",
|
||||||
"X-XSS-Protection": "0",
|
"X-XSS-Protection": "0",
|
||||||
"X-Permitted-Cross-Domain-Policies": "none",
|
"X-Permitted-Cross-Domain-Policies": "none",
|
||||||
"Access-Control-Allow-Headers": "Content-Type, Authorization",
|
"Access-Control-Allow-Headers": "Content-Type, Authorization",
|
||||||
"Access-Control-Allow-Origin": "*",
|
"Access-Control-Allow-Origin": "*",
|
||||||
"Access-Control-Allow-Methods": "GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS",
|
"Access-Control-Allow-Methods": "GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS",
|
||||||
"X-Frame-Options": "DENY",
|
"X-Frame-Options": "DENY",
|
||||||
"X-Content-Type-Options": "nosniff",
|
"X-Content-Type-Options": "nosniff",
|
||||||
"X-Feature-Policy": [
|
"X-Feature-Policy": [
|
||||||
"accelerometer 'none'",
|
"accelerometer 'none'",
|
||||||
"ambient-light-sensor 'none'",
|
"ambient-light-sensor 'none'",
|
||||||
"autoplay 'none'",
|
"autoplay 'none'",
|
||||||
|
@ -195,7 +195,7 @@ module Websites
|
||||||
"screen-wake-lock 'none'",
|
"screen-wake-lock 'none'",
|
||||||
"xr-spatial-tracking 'none'",
|
"xr-spatial-tracking 'none'",
|
||||||
].join("; "),
|
].join("; "),
|
||||||
"Content-Security-Policy": [
|
"Content-Security-Policy": [
|
||||||
"default-src 'self' #{domain} *.#{domain}",
|
"default-src 'self' #{domain} *.#{domain}",
|
||||||
"script-src 'self' 'unsafe-inline' #{domain} *.#{domain} https://cdnjs.cloudflare.com https://static.cloudflareinsights.com",
|
"script-src 'self' 'unsafe-inline' #{domain} *.#{domain} https://cdnjs.cloudflare.com https://static.cloudflareinsights.com",
|
||||||
"style-src 'self' 'unsafe-inline' #{domain} *.#{domain} https://cdnjs.cloudflare.com https://fonts.googleapis.com",
|
"style-src 'self' 'unsafe-inline' #{domain} *.#{domain} https://cdnjs.cloudflare.com https://fonts.googleapis.com",
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module RequestExtension
|
module RequestExtension
|
||||||
def forwarded_host
|
def forwarded_host
|
||||||
headers["X-Forwarded-Host"] || host
|
headers["X-Forwarded-Host"] || host
|
||||||
|
|
|
@ -37,7 +37,6 @@ module E621WsRoutes
|
||||||
get(:browserconfig, constraints: { format: "xml" })
|
get(:browserconfig, constraints: { format: "xml" })
|
||||||
root(action: :index)
|
root(action: :index)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class CustomStaticMiddleware
|
class CustomStaticMiddleware
|
||||||
def initialize(app, domain_map)
|
def initialize(app, domain_map)
|
||||||
@app = app
|
@app = app
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace :e621 do
|
||||||
end
|
end
|
||||||
|
|
||||||
task remove_timeouts: :environment do
|
task remove_timeouts: :environment do
|
||||||
E621Thumbnail.where(status: "timeout", created_at: ..10.minutes.ago).find_each do |entry|
|
E621Thumbnail.where(status: "timeout", created_at: ..5.minutes.ago).find_each do |entry|
|
||||||
puts "Removing timed out generation for post #{entry.post_id} (#{entry.stripped_md5}"
|
puts "Removing timed out generation for post #{entry.post_id} (#{entry.stripped_md5}"
|
||||||
entry.destroy
|
entry.destroy
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user