2
0

Move self destruct check to config_for and add constant for verifier string (#32943)

This commit is contained in:
Matt Jankowski
2024-11-18 04:57:16 -05:00
committed by GitHub
parent 911d7dbbf6
commit c0c34d35e2
4 changed files with 19 additions and 12 deletions

View File

@@ -1,9 +1,11 @@
# frozen_string_literal: true
module SelfDestructHelper
VERIFY_PURPOSE = 'self-destruct'
def self.self_destruct?
value = ENV.fetch('SELF_DESTRUCT', nil)
value.present? && Rails.application.message_verifier('self-destruct').verify(value) == ENV['LOCAL_DOMAIN']
value = Rails.configuration.x.mastodon.self_destruct_value
value.present? && Rails.application.message_verifier(VERIFY_PURPOSE).verify(value) == ENV['LOCAL_DOMAIN']
rescue ActiveSupport::MessageVerifier::InvalidSignature
false
end