Allow different remote translation keys per tenant
Note we don't need to update the tests; the tests themselves help us confirm that `Rails.application.secrets` and `Tenant.current_secrets` return the same object on single-tenant applications.
This commit is contained in:
@@ -26,6 +26,6 @@ module RemotelyTranslatable
|
||||
end
|
||||
|
||||
def api_key_has_been_set_in_secrets?
|
||||
Rails.application.secrets.microsoft_api_key.present?
|
||||
Tenant.current_secrets.microsoft_api_key.present?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -57,7 +57,8 @@ staging:
|
||||
# my_tenant_subdomain:
|
||||
# secret_key: my_secret_value
|
||||
#
|
||||
# Currently you can overwrite SMTP, SMS and manager settings.
|
||||
# Currently you can overwrite SMTP, SMS, manager and microsoft API
|
||||
# settings.
|
||||
<<: *maps
|
||||
<<: *apis
|
||||
|
||||
@@ -92,7 +93,8 @@ preproduction:
|
||||
# my_tenant_subdomain:
|
||||
# secret_key: my_secret_value
|
||||
#
|
||||
# Currently you can overwrite SMTP, SMS and manager settings.
|
||||
# Currently you can overwrite SMTP, SMS, manager and microsoft API
|
||||
# settings.
|
||||
twitter_key: ""
|
||||
twitter_secret: ""
|
||||
facebook_key: ""
|
||||
@@ -132,7 +134,8 @@ production:
|
||||
# my_tenant_subdomain:
|
||||
# secret_key: my_secret_value
|
||||
#
|
||||
# Currently you can overwrite SMTP, SMS and manager settings.
|
||||
# Currently you can overwrite SMTP, SMS, manager and microsoft API
|
||||
# settings.
|
||||
twitter_key: ""
|
||||
twitter_secret: ""
|
||||
facebook_key: ""
|
||||
|
||||
@@ -36,7 +36,7 @@ class RemoteTranslations::Microsoft::AvailableLocales
|
||||
uri = URI(host + path)
|
||||
|
||||
request = Net::HTTP::Get.new(uri)
|
||||
request["Ocp-Apim-Subscription-Key"] = Rails.application.secrets.microsoft_api_key
|
||||
request["Ocp-Apim-Subscription-Key"] = Tenant.current_secrets.microsoft_api_key
|
||||
|
||||
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |http|
|
||||
http.request(request)
|
||||
|
||||
@@ -6,7 +6,7 @@ class RemoteTranslations::Microsoft::Client
|
||||
PREVENTING_TRANSLATION_KEY = "notranslate".freeze
|
||||
|
||||
def initialize
|
||||
api_key = Rails.application.secrets.microsoft_api_key
|
||||
api_key = Tenant.current_secrets.microsoft_api_key
|
||||
@client = TranslatorText::Client.new(api_key)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user