zuora_connect 2.0.60g → 2.0.60l
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/zuora_connect/app_instance_base.rb +49 -2
- data/config/initializers/postgresql_adapter.rb +38 -1
- data/lib/resque/dynamic_queues.rb +1 -1
- data/lib/zuora_connect/controllers/helpers.rb +14 -3
- data/lib/zuora_connect/railtie.rb +15 -0
- data/lib/zuora_connect/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00f68595c6354e9924c2e73bdb81246bdc858874f49830f94111e0d46b6e8298
|
4
|
+
data.tar.gz: 1b01b3c05190970c9ad92c461f64b89787b790f3e2ffb6394831ccce425e0d1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e58fc8cd5b36a2be218afab342507a78acb5221001cdc712e61a7e80ad0615797ed42c7ae413d4d5dc179d14784e91eb621ea5be9466a45e904ed97bd5996076
|
7
|
+
data.tar.gz: df3730519a5b2b1e8b3778866bd6ac59255633666522fe7ec8522e6815a1c87d5aba89fd733ec1eaecf6caeccf74fde010ea40a9d882b20d6fe2cfc4f1ee46a2
|
@@ -11,7 +11,7 @@ module ZuoraConnect
|
|
11
11
|
before_destroy :prune_data
|
12
12
|
|
13
13
|
self.table_name = "zuora_connect_app_instances"
|
14
|
-
attr_accessor :options, :mode, :logins, :task_data, :last_refresh, :username, :password, :s3_client, :api_version, :drop_message, :new_session_message, :connect_user, :logitems
|
14
|
+
attr_accessor :options, :mode, :logins, :task_data, :last_refresh, :username, :password, :s3_client, :api_version, :drop_message, :new_session_message, :connect_user, :logitems, :user_timezone
|
15
15
|
@@telegraf_host = nil
|
16
16
|
REFRESH_TIMEOUT = 2.minute #Used to determine how long to wait on current refresh call before executing another
|
17
17
|
INSTANCE_REFRESH_WINDOW = 1.hours #Used to set how how long till app starts attempting to refresh cached task connect data
|
@@ -240,7 +240,50 @@ module ZuoraConnect
|
|
240
240
|
rescue I18n::InvalidLocale => ex
|
241
241
|
ZuoraConnect.logger.error(ex) if !IGNORED_LOCALS.include?(ex.locale.to_s.downcase)
|
242
242
|
end
|
243
|
-
|
243
|
+
|
244
|
+
begin
|
245
|
+
sql = <<-eos
|
246
|
+
SELECT zuora_users.zuora_identity_response
|
247
|
+
FROM "#{self.id}".zuora_users
|
248
|
+
ORDER BY zuora_users.updated_at DESC
|
249
|
+
LIMIT 1;
|
250
|
+
eos
|
251
|
+
user = ActiveRecord::Base.connection.execute(sql).to_a.first
|
252
|
+
|
253
|
+
if user.present?
|
254
|
+
zuora_identity_response = JSON.parse(user.fetch('zuora_identity_response', '{}'))
|
255
|
+
self.user_timezone = zuora_identity_response.values.first&.dig('timeZone')
|
256
|
+
end
|
257
|
+
rescue => ex
|
258
|
+
Rails.logger.error('Failed to get users while setting app instance timezone', ex)
|
259
|
+
end
|
260
|
+
|
261
|
+
if self.user_timezone.present?
|
262
|
+
# connect instance which has a custom timezone
|
263
|
+
if !self.auto_deployed? && (
|
264
|
+
ActiveSupport::TimeZone[self.task_data.dig('user_settings', 'timezone') || '']&.utc_offset !=
|
265
|
+
ActiveSupport::TimeZone[self.user_timezone]&.utc_offset
|
266
|
+
)
|
267
|
+
if self.environment == 'Production'
|
268
|
+
ZuoraConnect.logger.error(
|
269
|
+
"Instance and user timezones are different. User has '#{self.user_timezone}' and " \
|
270
|
+
"instance has '#{self.task_data.dig('user_settings', 'timezone')}'",
|
271
|
+
app_instance_id: self.id
|
272
|
+
)
|
273
|
+
end
|
274
|
+
self.user_timezone = nil
|
275
|
+
Time.zone = self.timezone
|
276
|
+
else
|
277
|
+
begin
|
278
|
+
Time.zone = self.user_timezone
|
279
|
+
rescue ArgumentError
|
280
|
+
Time.zone = self.timezone
|
281
|
+
end
|
282
|
+
end
|
283
|
+
else
|
284
|
+
Time.zone = self.timezone
|
285
|
+
end
|
286
|
+
|
244
287
|
if self.task_data.present?
|
245
288
|
tenants = self.task_data.fetch('tenant_ids', [])
|
246
289
|
organizations = self.task_data.fetch('organizations', [])
|
@@ -272,6 +315,10 @@ module ZuoraConnect
|
|
272
315
|
end
|
273
316
|
end
|
274
317
|
|
318
|
+
def auto_deployed?
|
319
|
+
self.id >= 25000000
|
320
|
+
end
|
321
|
+
|
275
322
|
def refresh(session: {})
|
276
323
|
refresh_count ||= 0
|
277
324
|
skip_connect ||= false
|
@@ -1,9 +1,15 @@
|
|
1
1
|
module ActiveRecord
|
2
2
|
module ConnectionAdapters
|
3
3
|
class PostgreSQLAdapter < AbstractAdapter
|
4
|
+
|
5
|
+
SCHEMA_ADDITIONAL_TYPES = 'SchemaAdditionalTypes'.freeze
|
6
|
+
|
4
7
|
private
|
5
8
|
def load_additional_types_latest(oids = nil)
|
6
9
|
initializer = OID::TypeMapInitializer.new(type_map)
|
10
|
+
|
11
|
+
return if loaded_from_cache?(initializer)
|
12
|
+
|
7
13
|
if supports_ranges?
|
8
14
|
query = <<-SQL
|
9
15
|
SELECT DISTINCT on (t.typname) t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, t.typtype, t.typbasetype
|
@@ -20,16 +26,20 @@ module ActiveRecord
|
|
20
26
|
if oids
|
21
27
|
query += "WHERE t.oid::integer IN (%s)" % oids.join(", ")
|
22
28
|
else
|
23
|
-
query += initializer.query_conditions_for_initial_load
|
29
|
+
query += initializer.query_conditions_for_initial_load(type_map)
|
24
30
|
end
|
25
31
|
|
26
32
|
execute_and_clear(query, "SCHEMA", []) do |records|
|
33
|
+
cache_additional_types(records)
|
27
34
|
initializer.run(records)
|
28
35
|
end
|
29
36
|
end
|
30
37
|
|
31
38
|
def load_additional_types_deprecated(type_map, oids = nil)
|
32
39
|
initializer = OID::TypeMapInitializer.new(type_map)
|
40
|
+
|
41
|
+
return if loaded_from_cache?(initializer)
|
42
|
+
|
33
43
|
if supports_ranges?
|
34
44
|
query = <<-SQL
|
35
45
|
SELECT DISTINCT on (t.typname) t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, t.typtype, t.typbasetype
|
@@ -50,10 +60,37 @@ module ActiveRecord
|
|
50
60
|
end
|
51
61
|
|
52
62
|
execute_and_clear(query, "SCHEMA", []) do |records|
|
63
|
+
cache_additional_types(records)
|
53
64
|
initializer.run(records)
|
54
65
|
end
|
55
66
|
end
|
56
67
|
|
68
|
+
def loaded_from_cache?(initializer)
|
69
|
+
if defined?(Redis.current)
|
70
|
+
begin
|
71
|
+
if Redis.current.exists(SCHEMA_ADDITIONAL_TYPES)
|
72
|
+
initializer.run(JSON.parse(Redis.current.get(SCHEMA_ADDITIONAL_TYPES)))
|
73
|
+
return true
|
74
|
+
end
|
75
|
+
rescue => ex
|
76
|
+
Rails.logger.warn('Exception occurred while loading additional types', ex)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
false
|
81
|
+
end
|
82
|
+
|
83
|
+
def cache_additional_types(records)
|
84
|
+
if defined?(Redis.current)
|
85
|
+
begin
|
86
|
+
Redis.current.setex(SCHEMA_ADDITIONAL_TYPES, 1.hour.to_i, records.to_json)
|
87
|
+
rescue => ex
|
88
|
+
Rails.logger.warn('Exception occurred while caching additional types', ex)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
|
57
94
|
rails_version = Rails.version.split('.').map { |x| x.to_i }
|
58
95
|
if (rails_version <=> [5, 2, 0]) >= 1
|
59
96
|
alias :load_additional_types :load_additional_types_latest
|
@@ -124,14 +124,24 @@ module ZuoraConnect
|
|
124
124
|
ElasticAPM.set_user(session["#{@appinstance.id}::user::email"]) if defined?(ElasticAPM) && ElasticAPM.running?
|
125
125
|
PaperTrail.whodunnit = session["#{@appinstance.id}::user::email"] if defined?(PaperTrail)
|
126
126
|
end
|
127
|
+
|
128
|
+
locale = (session["#{@appinstance.id}::user::locale"] || "").gsub("_", "-")
|
127
129
|
begin
|
128
|
-
locale = session["#{@appinstance.id}::user::locale"]
|
129
130
|
I18n.locale = locale.present? ? locale : @appinstance.locale
|
130
131
|
rescue I18n::InvalidLocale => ex
|
132
|
+
if locale.include?("-")
|
133
|
+
locale = locale.split("-").first
|
134
|
+
retry
|
135
|
+
elsif locale != session["#{@appinstance.id}::user::language"]
|
136
|
+
locale = session["#{@appinstance.id}::user::language"]
|
137
|
+
retry
|
138
|
+
end
|
131
139
|
ZuoraConnect.logger.error(ex) if !ZuoraConnect::AppInstance::IGNORED_LOCALS.include?(ex.locale.to_s.downcase)
|
132
140
|
end
|
133
141
|
begin
|
134
|
-
|
142
|
+
if @appinstance.user_timezone.blank?
|
143
|
+
Time.zone = session["#{@appinstance.id}::user::timezone"] ? session["#{@appinstance.id}::user::timezone"] : @appinstance.timezone
|
144
|
+
end
|
135
145
|
rescue
|
136
146
|
ZuoraConnect.logger.error(ex)
|
137
147
|
end
|
@@ -435,7 +445,8 @@ module ZuoraConnect
|
|
435
445
|
session["#{@appinstance.id}::user::localUserId"] = @zuora_user.id
|
436
446
|
session["#{@appinstance.id}::user::email"] = session['ZuoraCurrentIdentity']["username"]
|
437
447
|
session["#{@appinstance.id}::user::timezone"] = session['ZuoraCurrentIdentity']["timeZone"]
|
438
|
-
session["#{@appinstance.id}::user::
|
448
|
+
session["#{@appinstance.id}::user::language"] = session['ZuoraCurrentIdentity']["language"]
|
449
|
+
session["#{@appinstance.id}::user::locale"] = session['ZuoraCurrentIdentity']["locale"]
|
439
450
|
session["appInstance"] = @appinstance.id
|
440
451
|
|
441
452
|
#We have multiple, user must pick
|
@@ -81,6 +81,21 @@ module ZuoraConnect
|
|
81
81
|
request_headers =
|
82
82
|
event.payload[:headers].env.
|
83
83
|
reject { |key| key.to_s.include?('.') || REQUEST_HEADERS_TO_IGNORE.include?(key.to_s) }
|
84
|
+
begin
|
85
|
+
if request_headers["HTTP_AUTHORIZATION"].present?
|
86
|
+
if request_headers["HTTP_AUTHORIZATION"].include?("Basic")
|
87
|
+
user_password = request_headers["HTTP_AUTHORIZATION"].split("Basic").last.strip
|
88
|
+
user, password = Base64.decode64(user_password).split(":")
|
89
|
+
request_headers["HTTP_AUTHORIZATION"] = "Basic #{user}:ValueFiltered"
|
90
|
+
elsif
|
91
|
+
request_headers["HTTP_AUTHORIZATION"] = "ValueFiltered"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
request_headers["HTTP_API_TOKEN"] = "ValueFiltered" if request_headers["HTTP_API_TOKEN"].present?
|
95
|
+
rescue
|
96
|
+
request_headers.delete("HTTP_API_TOKEN")
|
97
|
+
request_headers.delete("HTTP_AUTHORIZATION")
|
98
|
+
end
|
84
99
|
items.merge!({ headers: request_headers.to_s })
|
85
100
|
end
|
86
101
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zuora_connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.60l
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Connect Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apartment
|