eco-helpers 2.4.2 → 2.4.3

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: d2b034981dcaa5e5ecfb1778df6fed175e4631d1244372c475bd5049e8e97c67
4
- data.tar.gz: ca64274315a6da975781f3d8198b3a58956e9f665a674392ba03090feb284488
3
+ metadata.gz: 84e0b3626647d968a77ecc7dbc9dbe052be392ff7590f9f32c2402d4a0fdb45b
4
+ data.tar.gz: cfd6e253e91d50bd62ffb4cbad8556214a3519ccaf9fdd148c681170ad150466
5
5
  SHA512:
6
- metadata.gz: 33d6ba24ecab02c3bb10d11577ed067b7eab05e4c1fa0af17c72405cb16fd135b253a0414d33a14821b0684129e921eee0cb65eec8ac88558e3931c5d3bbcb8c
7
- data.tar.gz: db51965c0d7b2a607a3cd6a1fbbdac48430be4804367d9746d448141c5fe00e04e835c202e696b42bc68e6c153b511f45c3a11b38ee7c6c1701fbb46d3cf9f23
6
+ metadata.gz: 4162b785935a8f161ad5030e8ffbd72defd3ed10f50b6d4944b219c0faed84f5cd57efee5a1c43ed41c2f4efdbbcb5ab7356c426dbecd2ebaca2a0da79bba90a
7
+ data.tar.gz: 5c5ad42b25f53b92fcac214555fb7b2ab9b5af0c033367b375b6ae55334ce0ffa7ecca74d05bac7dd3a75aba7761d9f7be91d5fab44310eb664eeed3df758f83
data/CHANGELOG.md CHANGED
@@ -1,12 +1,19 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [2.4.3] - 2023-03-xx
4
+ ## [2.4.4] - 2023-03-xx
5
5
 
6
6
  ### Added
7
7
  ### Changed
8
8
  ### Fixed
9
9
 
10
+ ## [2.4.3] - 2023-03-23
11
+
12
+ ### Fixed
13
+ - `Eco::API::MicroCases#take_email_from_account` it was failing at the very (when restoring the original account)
14
+ - Comes from back-end issue. Adding account with preferences.kiosk_enabled would return:
15
+ - `{"errors"=>["account > preferences > kiosk_enabled is an unknown field"]}`
16
+
10
17
  ## [2.4.2] - 2023-03-17
11
18
 
12
19
  ### Fixed
@@ -36,27 +36,33 @@ module Eco
36
36
  return false if dest_email.to_s.strip.empty?
37
37
  end
38
38
 
39
- account_json = JSON.parse(account.to_json)
39
+ account_json = _take_email_account_json(account)
40
40
  person.email = account_email
41
41
 
42
42
  if success = _take_email_remove_account!(person, context: context)
43
43
  if success = _take_email_acquire_account!(person, target_email, account: {}, context: context)
44
44
  if success = _take_email_email_free_up!(person, dest_email: dest_email, context: context)
45
45
  if success = _take_email_remove_account!(person, context: context)
46
+ # Bring back the original account
46
47
  if success = _take_email_acquire_account!(person, account_email, account: account_json, context: context)
48
+ success = true
47
49
  person.email = target_email
48
50
  end
49
51
  end
50
52
  else # free up target email
51
53
  # restore
52
- if _take_email_remove_account!(person, context: context)
53
- _take_email_acquire_account!(person, account_email, account: account_json, context: context)
54
+ reverted = false
55
+ if reverted ||= _take_email_remove_account!(person, context: context)
56
+ reverted ||= _take_email_acquire_account!(person, account_email, account: account_json, context: context)
54
57
  end
58
+ puts "Could not revert back to the original account #{person.identify}" unless reverted
55
59
  success = false
56
60
  end
57
61
  else # aquire other account
58
62
  # restore
59
- _take_email_acquire_account!(person, account_email, account: account_json, context: context)
63
+ unless _take_email_acquire_account!(person, account_email, account: account_json, context: context)
64
+ puts "Could not bring back the original account we want to update the email to '#{target_email}' #{person.identify}"
65
+ end
60
66
  success = false
61
67
  end
62
68
  end
@@ -65,6 +71,21 @@ module Eco
65
71
 
66
72
  private
67
73
 
74
+ def _take_email_account_json(account)
75
+ JSON.parse(account.to_json).tap do |hash|
76
+ hash.delete("user_id")
77
+ hash.delete("permissions_merged")
78
+ hash.delete("permissions_preset")
79
+ hash.delete("prefilter")
80
+ if pref = hash["preferences"]
81
+ hash["preferences"] = pref.reject do |attr, value|
82
+ attr.start_with?("kiosk")
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+ # Bring the account of the `target_email` taken, so we can change the email of this account
68
89
  def _take_email_acquire_account!(person, target_email, account: {}, context: "Session")
69
90
  person.account = account
70
91
  person.account.send_invites = false
@@ -72,6 +93,7 @@ module Eco
72
93
  micro.person_update!(person, reason: "bring account with email '#{target_email}'", context: context)
73
94
  end
74
95
 
96
+ # Free up the email (`target_email`) of the account that has it taken to `dest_email`
75
97
  def _take_email_email_free_up!(person, dest_email:, target_email: nil, context: "Session")
76
98
  target_email ||= person.email
77
99
  person.email = dest_email.is_a?(Proc)? dest_email.call(target_email) : dest_email
@@ -83,7 +105,6 @@ module Eco
83
105
  person.account = nil
84
106
  micro.person_update!(person, reason: "remove account", context: context)
85
107
  end
86
-
87
108
  end
88
109
  end
89
110
  end
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "2.4.2"
2
+ VERSION = "2.4.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eco-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.2
4
+ version: 2.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura