zuora_connect 2.0.60f → 2.0.60k
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 +42 -2
- data/config/initializers/postgresql_adapter.rb +38 -1
- data/lib/resque/dynamic_queues.rb +1 -1
- data/lib/zuora_connect/controllers/helpers.rb +13 -5
- 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: fe61d354796bd1cf1935f2787db0611bb2858393767db78230efb191cf64eabc
|
4
|
+
data.tar.gz: c5b22daf266f3cc696c1a85ac46e7b4242d75a59f094f2103edb1fa0da729df2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04b0bf5d380361c58279910595d0967fde34c00b05db703d2c4dda02a8205487eb8b0fd3c8bfc44d0c0997854cfacca9585c778e96000e938a19b8ee6604271c
|
7
|
+
data.tar.gz: 510d4eb2cd734f1082f887ff3924ce580658d4419929ee12db35acec17338785b8e9ecb64588307f3a6fe26adb29a8ed45c04df51a2964f1be9480880c2f2813
|
@@ -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,43 @@ 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? && self.task_data.dig('user_settings', 'timezone') != self.user_timezone
|
264
|
+
if self.environment == 'Production'
|
265
|
+
ZuoraConnect.logger.error('Instance and user timezones are different', app_instance_id: self.id)
|
266
|
+
end
|
267
|
+
self.user_timezone = nil
|
268
|
+
Time.zone = self.timezone
|
269
|
+
else
|
270
|
+
begin
|
271
|
+
Time.zone = self.user_timezone
|
272
|
+
rescue ArgumentError
|
273
|
+
Time.zone = self.timezone
|
274
|
+
end
|
275
|
+
end
|
276
|
+
else
|
277
|
+
Time.zone = self.timezone
|
278
|
+
end
|
279
|
+
|
244
280
|
if self.task_data.present?
|
245
281
|
tenants = self.task_data.fetch('tenant_ids', [])
|
246
282
|
organizations = self.task_data.fetch('organizations', [])
|
@@ -272,6 +308,10 @@ module ZuoraConnect
|
|
272
308
|
end
|
273
309
|
end
|
274
310
|
|
311
|
+
def auto_deployed?
|
312
|
+
self.id >= 25000000
|
313
|
+
end
|
314
|
+
|
275
315
|
def refresh(session: {})
|
276
316
|
refresh_count ||= 0
|
277
317
|
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,21 @@ 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
|
+
end
|
131
136
|
ZuoraConnect.logger.error(ex) if !ZuoraConnect::AppInstance::IGNORED_LOCALS.include?(ex.locale.to_s.downcase)
|
132
137
|
end
|
133
138
|
begin
|
134
|
-
|
139
|
+
if @appinstance.user_timezone.blank?
|
140
|
+
Time.zone = session["#{@appinstance.id}::user::timezone"] ? session["#{@appinstance.id}::user::timezone"] : @appinstance.timezone
|
141
|
+
end
|
135
142
|
rescue
|
136
143
|
ZuoraConnect.logger.error(ex)
|
137
144
|
end
|
@@ -435,7 +442,8 @@ module ZuoraConnect
|
|
435
442
|
session["#{@appinstance.id}::user::localUserId"] = @zuora_user.id
|
436
443
|
session["#{@appinstance.id}::user::email"] = session['ZuoraCurrentIdentity']["username"]
|
437
444
|
session["#{@appinstance.id}::user::timezone"] = session['ZuoraCurrentIdentity']["timeZone"]
|
438
|
-
session["#{@appinstance.id}::user::
|
445
|
+
session["#{@appinstance.id}::user::language"] = session['ZuoraCurrentIdentity']["language"]
|
446
|
+
session["#{@appinstance.id}::user::locale"] = session['ZuoraCurrentIdentity']["locale"]
|
439
447
|
session["appInstance"] = @appinstance.id
|
440
448
|
|
441
449
|
#We have multiple, user must pick
|
@@ -566,8 +574,8 @@ module ZuoraConnect
|
|
566
574
|
|
567
575
|
rescue ZuoraAPI::Exceptions::ZuoraAPIError, Exception => ex
|
568
576
|
if ex.message.include?("Referenced User resource(s) not found") && ex.class == ZuoraAPI::Exceptions::ZuoraAPIError
|
569
|
-
locals = {title: "Provisioning Error", message: "New
|
570
|
-
render "zuora_connect/static/error_handled", locals: locals, status:
|
577
|
+
locals = {title: "Provisioning Error", message: "New tenants need to be provisioned by API Gateway('#{ex.message}'). Please contact support."}
|
578
|
+
render "zuora_connect/static/error_handled", locals: locals, status: 200, layout: false
|
571
579
|
else
|
572
580
|
session.clear
|
573
581
|
if defined?(ex.response) && ex.response.present? && defined?(ex.response.body)
|
@@ -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.60k
|
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-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apartment
|