1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-20 14:54:15 +01:00

(fix) replaces custom ServerLocale middleware with sidekiq i18n middleware

This commit is contained in:
Nicolas Florentin 2023-11-02 13:54:40 +01:00
parent 7e2b4593f5
commit 835f3b6ec3
3 changed files with 8 additions and 18 deletions

View File

@ -10,6 +10,7 @@
- do not log Notifications#polling action anymore, by default, can be enable via env variable ENABLE_NOTIFICATIONS_POLLING_LOGGING=true
- Fix a bug: api/products/index bug when sorting by amount
- adds a rake task to regenerate invoices by ids (see maintenance.rake)
- Fix a bug: replaces custom ServerLocale middleware with sidekiq i18n middleware
## v6.2.0 2023 October 13

View File

@ -3,7 +3,6 @@
require 'sidekiq'
require 'sidekiq-scheduler'
require 'sidekiq/middleware/i18n'
require 'sidekiq/server_locale'
redis_host = ENV.fetch('REDIS_HOST', 'localhost')
redis_url = "redis://#{redis_host}:6379"
@ -11,11 +10,17 @@ redis_url = "redis://#{redis_host}:6379"
Sidekiq.configure_server do |config|
config.redis = { url: redis_url }
# client_middleware is also configured in configure_server block
# because jobs running in the Sidekiq server can themselves push
# new jobs to Sidekiq, thus acting as clients
# see https://github.com/sidekiq/sidekiq/wiki/Middleware for more details
config.client_middleware do |chain|
chain.add Sidekiq::Middleware::I18n::Client
chain.add SidekiqUniqueJobs::Middleware::Client
end
config.server_middleware do |chain|
chain.add Sidekiq::Middleware::I18n::Server
chain.add SidekiqUniqueJobs::Middleware::Server
end
@ -36,11 +41,9 @@ Sidekiq.configure_client do |config|
config.redis = { url: redis_url }
config.client_middleware do |chain|
chain.add Sidekiq::Middleware::I18n::Client
chain.add SidekiqUniqueJobs::Middleware::Client
end
config.server_middleware do |chain|
chain.add FabManager::Middleware::ServerLocale
end
end
# Quieting logging in the test environment

View File

@ -1,14 +0,0 @@
# frozen_string_literal: true
# module definition
module FabManager::Middleware; end
# Provides localization in workers
class FabManager::Middleware::ServerLocale
def call(_worker_class, job, _queue)
locale = job['locale'] || Rails.application.secrets.rails_locale
I18n.with_locale(locale) do
yield
end
end
end