zuora_connect 2.0.60q → 2.0.60v
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be544177acd9fb2c32ff1e1924980726c9b68ee3d8461e5f1721e5333f9ef60e
|
4
|
+
data.tar.gz: 15951349ed0a7064eff31fbb79d63585bc69a64408c0065993575925f01eb493
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c43e5c4d523ced8219b069aca21d3273d001ca2816be985dbca23827a3203bf415f9b77423056d226ad2cb8cdaff2442e36831d2e1833350ee2e5b5791fc9665
|
7
|
+
data.tar.gz: 72672400172011e402715935ee443594461b73d43ba15bd51c9b4f00061bd1d485aa22ec46f0fe181857cad49a109bdd65d7e31ced60f22c9678f381ff4cde5c
|
@@ -25,6 +25,8 @@ module ZuoraConnect
|
|
25
25
|
CATALOG_LOOKUP_CACHE_TIME_KEY = 'CatalogCachedAt'
|
26
26
|
CATALOG_LOOKUP_TTL = 60.seconds
|
27
27
|
CATALOG_LOOKUP_CACHE_RESULT_KEY = 'CatalogCache'
|
28
|
+
TIMEZONE_LOG_RATE_LIMIT_KEY = 'TimezoneLoggedAt'
|
29
|
+
TIMEZONE_LOG_PERIOD = 4.hours
|
28
30
|
IGNORED_LOCALS = ['fr', 'ja', 'es', 'zh', 'de']
|
29
31
|
INTERNAL_HOSTS = []
|
30
32
|
LOGIN_TENANT_DESTINATION = 'target_login'
|
@@ -245,48 +247,7 @@ module ZuoraConnect
|
|
245
247
|
ZuoraConnect.logger.error(ex) if !IGNORED_LOCALS.include?(ex.locale.to_s.downcase)
|
246
248
|
end
|
247
249
|
|
248
|
-
|
249
|
-
sql = <<-eos
|
250
|
-
SELECT zuora_users.zuora_identity_response
|
251
|
-
FROM "#{self.id}".zuora_users
|
252
|
-
ORDER BY zuora_users.updated_at DESC
|
253
|
-
LIMIT 1;
|
254
|
-
eos
|
255
|
-
user = ActiveRecord::Base.connection.execute(sql).to_a.first
|
256
|
-
|
257
|
-
if user.present?
|
258
|
-
zuora_identity_response = JSON.parse(user.fetch('zuora_identity_response', '{}'))
|
259
|
-
self.user_timezone = zuora_identity_response.values.first&.dig('timeZone')
|
260
|
-
end
|
261
|
-
rescue => ex
|
262
|
-
Rails.logger.error('Failed to get users while setting app instance timezone', ex)
|
263
|
-
end
|
264
|
-
|
265
|
-
if self.user_timezone.present?
|
266
|
-
# connect instance which has a custom timezone
|
267
|
-
if !self.auto_deployed? && (
|
268
|
-
ActiveSupport::TimeZone[self.task_data.dig('user_settings', 'timezone') || '']&.utc_offset !=
|
269
|
-
ActiveSupport::TimeZone[self.user_timezone]&.utc_offset
|
270
|
-
)
|
271
|
-
if self.environment == 'Production'
|
272
|
-
ZuoraConnect.logger.error(
|
273
|
-
"Instance and user timezones are different. User has '#{self.user_timezone}' and " \
|
274
|
-
"instance has '#{self.task_data.dig('user_settings', 'timezone')}'",
|
275
|
-
app_instance_id: self.id
|
276
|
-
)
|
277
|
-
end
|
278
|
-
self.user_timezone = nil
|
279
|
-
Time.zone = self.timezone
|
280
|
-
else
|
281
|
-
begin
|
282
|
-
Time.zone = self.user_timezone
|
283
|
-
rescue ArgumentError
|
284
|
-
Time.zone = self.timezone
|
285
|
-
end
|
286
|
-
end
|
287
|
-
else
|
288
|
-
Time.zone = self.timezone
|
289
|
-
end
|
250
|
+
self.set_timezone
|
290
251
|
|
291
252
|
if self.task_data.present?
|
292
253
|
tenants = self.task_data.fetch('tenant_ids', [])
|
@@ -319,6 +280,70 @@ module ZuoraConnect
|
|
319
280
|
end
|
320
281
|
end
|
321
282
|
|
283
|
+
def set_timezone(timezone: self.timezone, type: :default)
|
284
|
+
if timezone.blank?
|
285
|
+
timezone = self.timezone
|
286
|
+
end
|
287
|
+
|
288
|
+
if type == :default
|
289
|
+
Time.zone = timezone
|
290
|
+
elsif type == :user
|
291
|
+
begin
|
292
|
+
sql = <<-eos
|
293
|
+
SELECT zuora_users.zuora_identity_response
|
294
|
+
FROM "#{self.id}".zuora_users
|
295
|
+
ORDER BY zuora_users.updated_at DESC
|
296
|
+
LIMIT 1;
|
297
|
+
eos
|
298
|
+
user = ActiveRecord::Base.connection.execute(sql).to_a.first
|
299
|
+
|
300
|
+
if user.present?
|
301
|
+
zuora_identity_response = JSON.parse(user.fetch('zuora_identity_response', '{}'))
|
302
|
+
self.user_timezone = zuora_identity_response.values.first&.dig('timeZone')
|
303
|
+
else
|
304
|
+
if (Redis.current.hget(TIMEZONE_LOG_RATE_LIMIT_KEY, self.id).to_i + TIMEZONE_LOG_PERIOD.to_i) <= Time.now.to_i
|
305
|
+
Rails.logger.error('Cannot find any user to set the timezone', app_instance_id: self.id)
|
306
|
+
Redis.current.hset(TIMEZONE_LOG_RATE_LIMIT_KEY, self.id, Time.now.to_i)
|
307
|
+
end
|
308
|
+
end
|
309
|
+
rescue => ex
|
310
|
+
Rails.logger.error('There is an error while getting timezone users', ex)
|
311
|
+
end
|
312
|
+
|
313
|
+
if self.user_timezone.present?
|
314
|
+
# connect instance which has a custom timezone
|
315
|
+
if !self.auto_deployed? && (
|
316
|
+
ActiveSupport::TimeZone[self.task_data.dig('user_settings', 'timezone') || '']&.utc_offset !=
|
317
|
+
ActiveSupport::TimeZone[self.user_timezone]&.utc_offset
|
318
|
+
)
|
319
|
+
if self.environment == 'Production' &&
|
320
|
+
(Redis.current.hget(TIMEZONE_LOG_RATE_LIMIT_KEY, self.id).to_i + TIMEZONE_LOG_PERIOD.to_i) <= Time.now.to_i
|
321
|
+
ZuoraConnect.logger.error(
|
322
|
+
"Instance and user timezones are different. User has '#{self.user_timezone}' and " \
|
323
|
+
"instance has '#{self.task_data.dig('user_settings', 'timezone')}'",
|
324
|
+
app_instance_id: self.id
|
325
|
+
)
|
326
|
+
Redis.current.hset(TIMEZONE_LOG_RATE_LIMIT_KEY, self.id, Time.now.to_i)
|
327
|
+
end
|
328
|
+
self.user_timezone = nil
|
329
|
+
Time.zone = timezone
|
330
|
+
else
|
331
|
+
begin
|
332
|
+
Time.zone = self.user_timezone
|
333
|
+
rescue ArgumentError
|
334
|
+
Rails.logger.error('Malformed user timezone', app_instance_id: self.id)
|
335
|
+
Time.zone = timezone
|
336
|
+
end
|
337
|
+
end
|
338
|
+
else
|
339
|
+
Time.zone = timezone
|
340
|
+
end
|
341
|
+
end
|
342
|
+
rescue => e
|
343
|
+
Rails.logger.error('Malformed timezone used', e, app_instance_id: self.id)
|
344
|
+
Time.zone = self.timezone
|
345
|
+
end
|
346
|
+
|
322
347
|
def auto_deployed?
|
323
348
|
self.id >= 25000000
|
324
349
|
end
|
@@ -138,12 +138,8 @@ module ZuoraConnect
|
|
138
138
|
end
|
139
139
|
ZuoraConnect.logger.error(ex) if !ZuoraConnect::AppInstance::IGNORED_LOCALS.include?(ex.locale.to_s.downcase)
|
140
140
|
end
|
141
|
-
|
142
|
-
|
143
|
-
Time.zone = session["#{@appinstance.id}::user::timezone"] ? session["#{@appinstance.id}::user::timezone"] : @appinstance.timezone
|
144
|
-
end
|
145
|
-
rescue
|
146
|
-
ZuoraConnect.logger.error(ex)
|
141
|
+
if @appinstance.user_timezone.blank?
|
142
|
+
@appinstance.set_timezone(timezone: session["#{@appinstance.id}::user::timezone"], type: :default)
|
147
143
|
end
|
148
144
|
end
|
149
145
|
rescue ZuoraConnect::Exceptions::InvalidCredentialSet => ex
|
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.60v
|
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-
|
11
|
+
date: 2020-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apartment
|