th: TH_DROP_ALL_MAIL, TH_MAILER_SIDEKIQ_RETRY_LIMIT

th: TH_DROP_ADMIN_MAIL, TH_DROP_ALL_ADMIN_MAIL
treehouse-4.3
kouhai 2025-03-02 15:04:53 -08:00 committed by mokou
parent be4ea3af43
commit 54747e6f0c
Signed by: mokou
SSH Key Fingerprint: SHA256:x1kuZDvluYZGLSwrJg+IlmA7tkPz9BPIAEKPAc5NqwE
6 changed files with 34 additions and 1 deletions

View File

@ -4,6 +4,7 @@
- quote posting - quote posting
- Treehouse::Automod (experimental feature flagged) - Treehouse::Automod (experimental feature flagged)
- TH_MAILER_SIDEKIQ_RETRY_LIMIT=2
## Other Changes ## Other Changes

View File

@ -13,7 +13,11 @@ class AdminMailer < ApplicationMailer
default to: -> { @me.user_email } default to: -> { @me.user_email }
self.delivery_job = Treehouse::DeliveryJob
def new_report(report) def new_report(report)
# HACK: remove this when mail works again
return if Rails.configuration.x.th_drop_admin_mail
@report = report @report = report
locale_for_account(@me) do locale_for_account(@me) do
@ -22,6 +26,8 @@ class AdminMailer < ApplicationMailer
end end
def new_appeal(appeal) def new_appeal(appeal)
# HACK: remove this when mail works again
return if Rails.configuration.x.th_drop_admin_mail
@appeal = appeal @appeal = appeal
locale_for_account(@me) do locale_for_account(@me) do
@ -30,6 +36,8 @@ class AdminMailer < ApplicationMailer
end end
def new_pending_account(user) def new_pending_account(user)
# HACK: remove this when mail works again
return if Rails.configuration.x.th_drop_admin_mail
@account = user.account @account = user.account
locale_for_account(@me) do locale_for_account(@me) do
@ -38,6 +46,8 @@ class AdminMailer < ApplicationMailer
end end
def new_trends(links, tags, statuses) def new_trends(links, tags, statuses)
# HACK: remove this when mail works again
return if Rails.configuration.x.th_drop_admin_mail
@links = links @links = links
@tags = tags @tags = tags
@statuses = statuses @statuses = statuses
@ -48,6 +58,8 @@ class AdminMailer < ApplicationMailer
end end
def new_software_updates def new_software_updates
# HACK: remove this when mail works again
return if Rails.configuration.x.th_drop_admin_mail
@software_updates = SoftwareUpdate.all.to_a.sort_by(&:gem_version) @software_updates = SoftwareUpdate.all.to_a.sort_by(&:gem_version)
locale_for_account(@me) do locale_for_account(@me) do
@ -56,6 +68,8 @@ class AdminMailer < ApplicationMailer
end end
def new_critical_software_updates def new_critical_software_updates
# HACK: remove this when mail works again
return if Rails.configuration.x.th_drop_all_admin_mail
@software_updates = SoftwareUpdate.where(urgent: true).to_a.sort_by(&:gem_version) @software_updates = SoftwareUpdate.where(urgent: true).to_a.sort_by(&:gem_version)
locale_for_account(@me) do locale_for_account(@me) do
@ -64,6 +78,8 @@ class AdminMailer < ApplicationMailer
end end
def auto_close_registrations def auto_close_registrations
# HACK: remove this when mail works again
return if Rails.configuration.x.th_drop_all_admin_mail
locale_for_account(@me) do locale_for_account(@me) do
mail subject: default_i18n_subject(instance: @instance) mail subject: default_i18n_subject(instance: @instance)
end end

View File

@ -14,6 +14,8 @@ class UserMailer < Devise::Mailer
default to: -> { @resource.email } default to: -> { @resource.email }
self.delivery_job = Treehouse::DeliveryJob
def confirmation_instructions(user, token, *, **) def confirmation_instructions(user, token, *, **)
@resource = user @resource = user
@token = token @token = token

View File

@ -57,6 +57,7 @@ require_relative '../lib/arel/union_parenthesizing'
require_relative '../lib/simple_navigation/item_extensions' require_relative '../lib/simple_navigation/item_extensions'
require_relative '../lib/treehouse/automod' require_relative '../lib/treehouse/automod'
require_relative '../lib/treehouse/delivery_job'
Dotenv::Railtie.load Dotenv::Railtie.load
@ -128,6 +129,15 @@ module Mastodon
Devise::FailureApp.include Localized Devise::FailureApp.include Localized
end end
config.x.th_mailer_sidekiq_retry_limit = ENV.fetch('TH_MAILER_SIDEKIQ_RETRY_LIMIT', '2').to_i
config.x.th_drop_all_mail = !ENV.fetch('TH_DROP_ALL_MAIL', '').strip.empty?
config.action_mailer.perform_deliveries = !config.x.th_drop_all_mail
config.x.th_drop_all_admin_mail = !ENV.fetch('TH_DROP_ALL_ADMIN_MAIL', '').strip.empty? || config.x.th_drop_all_mail
config.x.th_drop_admin_mail = !ENV.fetch('TH_DROP_ADMIN_MAIL', '').strip.empty? || config.x.th_drop_all_admin_mail
config.x.th_automod.automod_account_username = ENV['TH_STAFF_ACCOUNT'] config.x.th_automod.automod_account_username = ENV['TH_STAFF_ACCOUNT']
config.x.th_automod.account_service_heuristic_auto_suspend_active = ENV.fetch('TH_ACCOUNT_SERVICE_HEURISTIC_AUTO_SUSPEND', '') == 'that-one-spammer' config.x.th_automod.account_service_heuristic_auto_suspend_active = ENV.fetch('TH_ACCOUNT_SERVICE_HEURISTIC_AUTO_SUSPEND', '') == 'that-one-spammer'
config.x.th_automod.mention_spam_heuristic_auto_limit_active = ENV.fetch('TH_MENTION_SPAM_HEURISTIC_AUTO_LIMIT_ACTIVE', '') == 'can-spam' config.x.th_automod.mention_spam_heuristic_auto_limit_active = ENV.fetch('TH_MENTION_SPAM_HEURISTIC_AUTO_LIMIT_ACTIVE', '') == 'can-spam'

View File

@ -68,3 +68,7 @@ SidekiqUniqueJobs.configure do |config|
config.reaper_timeout = 150 config.reaper_timeout = 150
config.lock_ttl = 50.days.to_i config.lock_ttl = 50.days.to_i
end end
ActiveSupport.on_load(:active_job) do
include ::Sidekiq::Worker::Options unless respond_to?(:sidekiq_options)
end

View File

@ -316,7 +316,7 @@ RSpec.describe User do
user = Fabricate(:user) user = Fabricate(:user)
ActiveJob::Base.queue_adapter = :test ActiveJob::Base.queue_adapter = :test
expect { user.send_confirmation_instructions }.to have_enqueued_job(ActionMailer::MailDeliveryJob) expect { user.send_confirmation_instructions }.to have_enqueued_job(Treehouse::DeliveryJob)
end end
end end