th: TH_DROP_ALL_MAIL, TH_MAILER_SIDEKIQ_RETRY_LIMIT

th: TH_DROP_ADMIN_MAIL, TH_DROP_ALL_ADMIN_MAIL
treehouse-4.3-dev
kouhai 2025-03-06 00:35:56 -08:00 committed by mokou
parent be4ea3af43
commit afb0b86039
7 changed files with 45 additions and 1 deletions

View File

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

View File

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

View File

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

View File

@ -57,6 +57,7 @@ require_relative '../lib/arel/union_parenthesizing'
require_relative '../lib/simple_navigation/item_extensions'
require_relative '../lib/treehouse/automod'
require_relative '../lib/treehouse/delivery_job'
Dotenv::Railtie.load
@ -128,6 +129,15 @@ module Mastodon
Devise::FailureApp.include Localized
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.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'

View File

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

View File

@ -0,0 +1,11 @@
# frozen_string_literal: true
ActiveSupport.on_load(:active_job) do
include ::Sidekiq::Worker::Options unless respond_to?(:sidekiq_options)
end
module Treehouse
class DeliveryJob < ActionMailer::MailDeliveryJob
sidekiq_options retry: ENV.fetch('TH_MAILER_SIDEKIQ_RETRY_LIMIT', '2').to_i
end
end

View File

@ -316,7 +316,7 @@ RSpec.describe User do
user = Fabricate(:user)
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