mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 21:35:48 +08:00
5aaf7e3316
Our instance used for template rendering needs a lock to ensure there is no race condition where rendering happens on 2 threads at the same time. This can lead to local poisoning which can cause unexpected results in emails
20 lines
401 B
Ruby
20 lines
401 B
Ruby
# frozen_string_literal: true
|
|
|
|
class UserNotificationRenderer < ActionView::Base
|
|
include ApplicationHelper
|
|
include UserNotificationsHelper
|
|
include EmailHelper
|
|
|
|
LOCK = Mutex.new
|
|
|
|
def self.render(*args)
|
|
LOCK.synchronize do
|
|
@instance ||= UserNotificationRenderer.with_view_paths(
|
|
Rails.configuration.paths["app/views"]
|
|
)
|
|
@instance.render(*args)
|
|
end
|
|
end
|
|
|
|
end
|