forked from e621ng/e621ng
fixes for failed cron maintenance tasks
* update rails scripts for 5.2 * system dmails should be scoped to system * fix broken url generator in forum notices
This commit is contained in:
parent
907881aced
commit
664a3f02e2
@ -110,9 +110,11 @@ class Dmail < ApplicationRecord
|
||||
end
|
||||
|
||||
def create_automated(params)
|
||||
dmail = Dmail.new(from: User.system, **params)
|
||||
dmail.owner = dmail.to
|
||||
dmail.save
|
||||
CurrentUser.as_system do
|
||||
dmail = Dmail.new(from: User.system, **params)
|
||||
dmail.owner = dmail.to
|
||||
dmail.save
|
||||
end
|
||||
dmail
|
||||
end
|
||||
end
|
||||
|
@ -10,4 +10,4 @@
|
||||
<br>
|
||||
<% end %>
|
||||
|
||||
<p><%= link_to "View topic", forum_topic_path(@forum_topic, :page => @forum_topic.last_page, :host => Danbooru.config.hostname, :only_path => false) %> | <%= link_to "Unsubscribe", maintenance_user_email_notification_url(:user_id => @user.id, :sig => email_sig(@user), :host => Danbooru.config.hostname, :only_path => false) %></p>
|
||||
<p><%= link_to "View topic", forum_topic_url(@forum_topic, :page => @forum_topic.last_page, :host => Danbooru.config.hostname, :only_path => false) %> | <%= link_to "Unsubscribe", maintenance_user_email_notification_url(:user_id => @user.id, :sig => email_sig(@user), :host => Danbooru.config.hostname, :only_path => false) %></p>
|
||||
|
@ -1,3 +1,3 @@
|
||||
#!/usr/bin/env ruby
|
||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
||||
load Gem.bin_path('bundler', 'bundle')
|
||||
|
@ -1,10 +1,9 @@
|
||||
#!/usr/bin/env ruby
|
||||
require 'pathname'
|
||||
require 'fileutils'
|
||||
include FileUtils
|
||||
|
||||
# path to your application root.
|
||||
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
||||
APP_ROOT = File.expand_path('..', __dir__)
|
||||
|
||||
def system!(*args)
|
||||
system(*args) || abort("\n== Command #{args} failed ==")
|
||||
@ -21,7 +20,6 @@ chdir APP_ROOT do
|
||||
# Install JavaScript dependencies if using Yarn
|
||||
# system('bin/yarn')
|
||||
|
||||
|
||||
# puts "\n== Copying sample files =="
|
||||
# unless File.exist?('config/database.yml')
|
||||
# cp 'config/database.yml.sample', 'config/database.yml'
|
||||
|
@ -1,10 +1,9 @@
|
||||
#!/usr/bin/env ruby
|
||||
require 'pathname'
|
||||
require 'fileutils'
|
||||
include FileUtils
|
||||
|
||||
# path to your application root.
|
||||
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
||||
APP_ROOT = File.expand_path('..', __dir__)
|
||||
|
||||
def system!(*args)
|
||||
system(*args) || abort("\n== Command #{args} failed ==")
|
||||
@ -18,6 +17,9 @@ chdir APP_ROOT do
|
||||
system! 'gem install bundler --conservative'
|
||||
system('bundle check') || system!('bundle install')
|
||||
|
||||
# Install JavaScript dependencies if using Yarn
|
||||
# system('bin/yarn')
|
||||
|
||||
puts "\n== Updating database =="
|
||||
system! 'bin/rails db:migrate'
|
||||
|
||||
|
6
bin/yarn
6
bin/yarn
@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env ruby
|
||||
VENDOR_PATH = File.expand_path('..', __dir__)
|
||||
Dir.chdir(VENDOR_PATH) do
|
||||
APP_ROOT = File.expand_path('..', __dir__)
|
||||
Dir.chdir(APP_ROOT) do
|
||||
begin
|
||||
exec "yarnpkg #{ARGV.join(" ")}"
|
||||
exec "yarnpkg", *ARGV
|
||||
rescue Errno::ENOENT
|
||||
$stderr.puts "Yarn executable was not detected in the system."
|
||||
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
|
||||
|
@ -1,9 +1,6 @@
|
||||
require_relative 'boot'
|
||||
require 'rails/all'
|
||||
|
||||
if defined?(Bundler)
|
||||
Bundler.require(:default, Rails.env)
|
||||
end
|
||||
Bundler.require(*Rails.groups)
|
||||
|
||||
require_relative "danbooru_default_config"
|
||||
|
@ -1,14 +1,4 @@
|
||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
||||
|
||||
require 'bundler/setup' # Set up gems listed in the Gemfile.
|
||||
require 'bootsnap'
|
||||
require 'tmpdir'
|
||||
Bootsnap.setup(
|
||||
cache_dir: File.join(Dir.tmpdir, 'bootsnap-cache'), # Path to your cache
|
||||
development_mode: ENV['MY_ENV'] == 'development',
|
||||
load_path_cache: true, # Should we optimize the LOAD_PATH with a cache?
|
||||
autoload_paths_cache: true, # Should we optimize ActiveSupport autoloads with cache?
|
||||
disable_trace: false, # Sets `RubyVM::InstructionSequence.compile_option = { trace_instruction: false }`
|
||||
compile_cache_iseq: true, # Should compile Ruby code into ISeq cache?
|
||||
compile_cache_yaml: true # Should compile YAML into a cache?
|
||||
)
|
||||
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
|
||||
|
@ -6,5 +6,5 @@ test:
|
||||
|
||||
production:
|
||||
adapter: redis
|
||||
url: redis://localhost:6379/1
|
||||
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
|
||||
channel_prefix: danbooru_production
|
||||
|
@ -9,20 +9,27 @@ Rails.application.configure do
|
||||
# Do not eager load code on boot.
|
||||
config.eager_load = false
|
||||
|
||||
# Show full error reports and disable caching.
|
||||
# Show full error reports.
|
||||
config.consider_all_requests_local = true
|
||||
if Rails.root.join('tmp/caching-dev.txt').exist?
|
||||
|
||||
# Enable/disable caching. By default caching is disabled.
|
||||
# Run rails dev:cache to toggle caching.
|
||||
if Rails.root.join('tmp', 'caching-dev.txt').exist?
|
||||
config.action_controller.perform_caching = true
|
||||
|
||||
|
||||
config.cache_store = :memory_store
|
||||
config.public_file_server.headers = {
|
||||
'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
|
||||
'Cache-Control' => "public, max-age=#{2.days.to_i}"
|
||||
}
|
||||
else
|
||||
config.action_controller.perform_caching = false
|
||||
|
||||
config.cache_store = :null_store
|
||||
end
|
||||
|
||||
# Store uploaded files on the local file system (see config/storage.yml for options)
|
||||
config.active_storage.service = :local
|
||||
|
||||
# Don't care if the mailer can't send.
|
||||
config.action_mailer.raise_delivery_errors = false
|
||||
|
||||
@ -34,6 +41,9 @@ Rails.application.configure do
|
||||
# Raise an error on page load if there are pending migrations.
|
||||
config.active_record.migration_error = :page_load
|
||||
|
||||
# Highlight code that triggered database queries in logs.
|
||||
config.active_record.verbose_query_logs = true
|
||||
|
||||
# Debug mode disables concatenation and preprocessing of assets.
|
||||
# This option may cause significant delays in view rendering with a large
|
||||
# number of complex assets.
|
||||
@ -42,16 +52,9 @@ Rails.application.configure do
|
||||
# Suppress logger output for asset requests.
|
||||
config.assets.quiet = true
|
||||
|
||||
# Adds additional error checking when serving assets at runtime.
|
||||
# Checks for improperly declared sprockets dependencies.
|
||||
# Raises helpful error messages.
|
||||
config.assets.raise_runtime_errors = true
|
||||
|
||||
# Raises error for missing translations
|
||||
# config.action_view.raise_on_missing_translations = true
|
||||
|
||||
config.eager_load = false
|
||||
|
||||
# Use an evented file watcher to asynchronously detect changes in source code,
|
||||
# routes, locales, etc. This feature depends on the listen gem.
|
||||
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
||||
|
@ -14,10 +14,9 @@ Rails.application.configure do
|
||||
config.consider_all_requests_local = false
|
||||
config.action_controller.perform_caching = true
|
||||
|
||||
# Attempt to read encrypted secrets from `config/secrets.yml.enc`.
|
||||
# Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
|
||||
# `config/secrets.yml.key`.
|
||||
config.read_encrypted_secrets = false
|
||||
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
|
||||
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
|
||||
# config.require_master_key = true
|
||||
|
||||
# Disable serving static files from the `/public` folder by default since
|
||||
# Apache or NGINX already handles this.
|
||||
@ -39,6 +38,9 @@ Rails.application.configure do
|
||||
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
||||
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
||||
|
||||
# Store uploaded files on the local file system (see config/storage.yml for options)
|
||||
config.active_storage.service = :local
|
||||
|
||||
# Mount Action Cable outside main process or domain
|
||||
# config.action_cable.mount_path = nil
|
||||
# config.action_cable.url = 'wss://example.com/cable'
|
||||
@ -60,6 +62,7 @@ Rails.application.configure do
|
||||
# Use a real queuing backend for Active Job (and separate queues per environment)
|
||||
# config.active_job.queue_adapter = :resque
|
||||
# config.active_job.queue_name_prefix = "danbooru_#{Rails.env}"
|
||||
|
||||
config.action_mailer.perform_caching = false
|
||||
|
||||
# Ignore bad email addresses and do not raise email delivery errors.
|
||||
|
@ -15,7 +15,7 @@ Rails.application.configure do
|
||||
# Configure public file server for tests with Cache-Control for performance.
|
||||
config.public_file_server.enabled = true
|
||||
config.public_file_server.headers = {
|
||||
'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}"
|
||||
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
|
||||
}
|
||||
|
||||
# Show full error reports and disable caching.
|
||||
@ -27,6 +27,10 @@ Rails.application.configure do
|
||||
|
||||
# Disable request forgery protection in test environment.
|
||||
config.action_controller.allow_forgery_protection = false
|
||||
|
||||
# Store uploaded files on the local file system in a temporary directory
|
||||
config.active_storage.service = :test
|
||||
|
||||
config.action_mailer.perform_caching = false
|
||||
|
||||
# Tell Action Mailer not to deliver emails to the real world.
|
||||
|
25
config/initializers/content_security_policy.rb
Normal file
25
config/initializers/content_security_policy.rb
Normal file
@ -0,0 +1,25 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Define an application-wide content security policy
|
||||
# For further information see the following documentation
|
||||
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
|
||||
|
||||
# Rails.application.config.content_security_policy do |policy|
|
||||
# policy.default_src :self, :https
|
||||
# policy.font_src :self, :https, :data
|
||||
# policy.img_src :self, :https, :data
|
||||
# policy.object_src :none
|
||||
# policy.script_src :self, :https
|
||||
# policy.style_src :self, :https
|
||||
|
||||
# # Specify URI for violation reports
|
||||
# # policy.report_uri "/csp-violation-report-endpoint"
|
||||
# end
|
||||
|
||||
# If you are using UJS then enable automatic nonce generation
|
||||
# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
|
||||
|
||||
# Report CSP violations to a specified URI
|
||||
# For further information see the following documentation:
|
||||
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
|
||||
# Rails.application.config.content_security_policy_report_only = true
|
35
config/initializers/new_framework_defaults_5_2.rb
Normal file
35
config/initializers/new_framework_defaults_5_2.rb
Normal file
@ -0,0 +1,35 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
#
|
||||
# This file contains migration options to ease your Rails 5.2 upgrade.
|
||||
#
|
||||
# Once upgraded flip defaults one by one to migrate to the new default.
|
||||
#
|
||||
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
|
||||
|
||||
# Make Active Record use stable #cache_key alongside new #cache_version method.
|
||||
# This is needed for recyclable cache keys.
|
||||
# Rails.application.config.active_record.cache_versioning = true
|
||||
|
||||
# Use AES-256-GCM authenticated encryption for encrypted cookies.
|
||||
# Also, embed cookie expiry in signed or encrypted cookies for increased security.
|
||||
#
|
||||
# This option is not backwards compatible with earlier Rails versions.
|
||||
# It's best enabled when your entire app is migrated and stable on 5.2.
|
||||
#
|
||||
# Existing cookies will be converted on read then written with the new scheme.
|
||||
# Rails.application.config.action_dispatch.use_authenticated_cookie_encryption = true
|
||||
|
||||
# Use AES-256-GCM authenticated encryption as default cipher for encrypting messages
|
||||
# instead of AES-256-CBC, when use_authenticated_message_encryption is set to true.
|
||||
# Rails.application.config.active_support.use_authenticated_message_encryption = true
|
||||
|
||||
# Add default protection from forgery to ActionController::Base instead of in
|
||||
# ApplicationController.
|
||||
# Rails.application.config.action_controller.default_protect_from_forgery = true
|
||||
|
||||
# Store boolean values are in sqlite3 databases as 1 and 0 instead of 't' and
|
||||
# 'f' after migrating old data.
|
||||
# Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
|
||||
|
||||
# Use SHA-1 instead of MD5 to generate non-sensitive digests, such as the ETag header.
|
||||
# Rails.application.config.active_support.use_sha1_digests = true
|
@ -1,6 +1,6 @@
|
||||
%w(
|
||||
%w[
|
||||
.ruby-version
|
||||
.rbenv-vars
|
||||
tmp/restart.txt
|
||||
tmp/caching-dev.txt
|
||||
).each { |path| Spring.watch(path) }
|
||||
].each { |path| Spring.watch(path) }
|
||||
|
34
config/storage.yml
Normal file
34
config/storage.yml
Normal file
@ -0,0 +1,34 @@
|
||||
test:
|
||||
service: Disk
|
||||
root: <%= Rails.root.join("tmp/storage") %>
|
||||
|
||||
local:
|
||||
service: Disk
|
||||
root: <%= Rails.root.join("storage") %>
|
||||
|
||||
# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
|
||||
# amazon:
|
||||
# service: S3
|
||||
# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
|
||||
# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
|
||||
# region: us-east-1
|
||||
# bucket: your_own_bucket
|
||||
|
||||
# Remember not to checkin your GCS keyfile to a repository
|
||||
# google:
|
||||
# service: GCS
|
||||
# project: your_project
|
||||
# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
|
||||
# bucket: your_own_bucket
|
||||
|
||||
# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
|
||||
# microsoft:
|
||||
# service: AzureStorage
|
||||
# storage_account_name: your_account_name
|
||||
# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
|
||||
# container: your_container_name
|
||||
|
||||
# mirror:
|
||||
# service: Mirror
|
||||
# primary: local
|
||||
# mirrors: [ amazon, google, microsoft ]
|
Loading…
Reference in New Issue
Block a user