summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2023-11-21 06:45:54 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2023-11-21 06:45:54 +0000
commitfd3843d821582772db1dcc0ec0a202b0aa99be64 (patch)
tree7eb091ed9879c0ac3aea165decabb098138e25df /app/models
parentf5d68651a06abf004552654dfdcd9c41f57ffb05 (diff)
downloadredmine-fd3843d821582772db1dcc0ec0a202b0aa99be64.tar.gz
redmine-fd3843d821582772db1dcc0ec0a202b0aa99be64.zip
Replace request_store with ActiveSupport::CurrentAttributes (#39110).
Patch by Takashi Kato. git-svn-id: https://svn.redmine.org/redmine/trunk@22473 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/mailer.rb8
-rw-r--r--app/models/user.rb8
2 files changed, 14 insertions, 2 deletions
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 558c280ec..689e31901 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -28,6 +28,14 @@ class Mailer < ActionMailer::Base
include Redmine::I18n
include Roadie::Rails::Automatic
+ class DeliveryJob < ActionMailer::MailDeliveryJob
+ include Redmine::JobWrapper
+
+ around_enqueue :keep_current_user
+ end
+
+ self.delivery_job = DeliveryJob
+
# Overrides ActionMailer::Base#process in order to set the recipient as the current user
# and his language as the default locale.
# The first argument of all actions of this Mailer must be a User (the recipient),
diff --git a/app/models/user.rb b/app/models/user.rb
index 90dbea6b1..cd923e46b 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -854,12 +854,16 @@ class User < Principal
self.pref.notify_about_high_priority_issues
end
+ class CurrentUser < ActiveSupport::CurrentAttributes
+ attribute :user
+ end
+
def self.current=(user)
- RequestStore.store[:current_user] = user
+ CurrentUser.user = user
end
def self.current
- RequestStore.store[:current_user] ||= User.anonymous
+ CurrentUser.user ||= User.anonymous
end
# Returns the anonymous user. If the anonymous user does not exist, it is created. There can be only