flexite 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d7bada1d5045fd4b95cb1dd115062cd966a1649
4
- data.tar.gz: 29c5ae3a83840ff6acb5e77d92df35fd6bcbffd1
3
+ metadata.gz: 93abeafc1fb15b62e131eead8ee95aa2c947ae1f
4
+ data.tar.gz: b9d52aa9cf10452949e3c0b79f9313ced090e2a0
5
5
  SHA512:
6
- metadata.gz: 4b49b3cc5018d207ac1f6517e5d76ffa75fe50ded089e5b7835b874ac9824e933ac5aa9bb7761b793bbd08f4c6dafcc263b198d7948051175343097e53128c02
7
- data.tar.gz: 1bbd4ba48643870ae320f184a1cc493c2d21c68a8a3c5aee25200871deb5073af44c5163f47c29681157d400678258bfa36bc480b099d6dfd796942a13649894
6
+ metadata.gz: d1603f09285642a4c41a5bacc996374fcf88eaa74a81b9aeaabd995623c536fd3794eccfc4d5a9c5639e61b4cc0ec412f291eb7ead7b6977006b34ffbb739052
7
+ data.tar.gz: de6215c0a7c55e1ca1dabb5472528d3e7711e64b5c1f2b606a9e1e3ea8782830f5dde0248a38390869fbfa1f4c46588f95654d805349393ff1f9f69c778d2bb7
@@ -8,7 +8,7 @@ module Flexite
8
8
  end
9
9
 
10
10
  def apply
11
- render json: ServiceFactory.instance.get(:apply_diff, params[:stage], params[:checksum]).call
11
+ render json: ServiceFactory.instance.get(:apply_diff, params[:token], params[:stage], params[:checksum]).call
12
12
  end
13
13
 
14
14
  def push
@@ -1,12 +1,17 @@
1
1
  module Flexite
2
2
  class Diff
3
3
  class ApplyService
4
- def initialize(stage, checksum)
4
+ def initialize(token, stage, checksum)
5
5
  @stage = stage
6
+ @token = Token.new(token)
6
7
  @checksum = checksum
7
8
  end
8
9
 
9
10
  def call
11
+ if @token.invalid?
12
+ return { error: 'Invalid token', code: 401 }
13
+ end
14
+
10
15
  diffs = Flexite.cache.read("#{Flexite.state_digest}-#{@checksum}-#{@stage}-diffs")
11
16
 
12
17
  if diffs.blank?
@@ -9,11 +9,11 @@ module Flexite
9
9
  end
10
10
 
11
11
  expire_old
12
- nodes = File.read(File.join(Rails.root, 'tmp', 'nodes.json'))
13
- checksum = Digest::MD5.hexdigest(nodes)
12
+ nodes = Config.t_nodes
13
+ checksum = Digest::MD5.hexdigest(nodes.to_json)
14
14
  Flexite.cache.write("#{Flexite.state_digest}-#{@stage}-diff-checksum", checksum)
15
- @remote_diff.check({ token: 'test', tree: JSON.parse(f.read), stage: Flexite.config.stagename, checksum: checksum })
16
- ActionService::Result.new(flash: { type: :warning, message: "You will be notified via #{Flexite.config.async_diff_handler.notifier} when difference check will be completed" },
15
+ @remote_diff.check({ token: Flexite.config.migration_token, tree: nodes, stage: Flexite.config.stagename, checksum: checksum })
16
+ ActionService::Result.new(flash: { type: :warning, message: "You will be notified via #{Flexite.config.async_diff_handler&.notifier} when difference check will be completed" },
17
17
  endpoint: { partial: 'flexite/shared/show_flash' })
18
18
  end
19
19
  end
@@ -17,7 +17,7 @@ module Flexite
17
17
  return ActionService::Result.new(flash: { type: :warning, message: 'Settings were changed and difference should be revalidated' })
18
18
  end
19
19
 
20
- response = @remote_diff.apply({ stage: Flexite.config.stagename, checksum: checksum })
20
+ response = @remote_diff.apply({ token: Flexite.config.migration_token, stage: Flexite.config.stagename, checksum: checksum })
21
21
 
22
22
  if response[:error].blank?
23
23
  ActionService::Result.new(flash: { type: :success, message: response[:message] })
@@ -12,10 +12,10 @@ module Flexite
12
12
 
13
13
  if response.nil?
14
14
  expire_old
15
- nodes = Config.t_nodes.to_json
16
- checksum = Digest::MD5.hexdigest(nodes)
15
+ nodes = Config.t_nodes
16
+ checksum = Digest::MD5.hexdigest(nodes.to_json)
17
17
  Flexite.cache.write("#{@state_digest}-#{@stage}-diff-checksum", checksum)
18
- response = @remote_diff.check({ token: Flexite.config.migration_token, tree: JSON.parse(nodes), stage: Flexite.config.stagename, checksum: checksum })
18
+ response = @remote_diff.check({ token: Flexite.config.migration_token, tree: nodes, stage: Flexite.config.stagename, checksum: checksum })
19
19
  Flexite.cache.write("#{@state_digest}-#{@stage}-show-diff", response)
20
20
  end
21
21
 
@@ -31,6 +31,7 @@ module Flexite
31
31
 
32
32
  def result(response)
33
33
  if response[:error].present?
34
+ expire_old
34
35
  ActionService::Result.new(success: false, flash: { type: :danger, message: response[:error] }, endpoint: { partial: 'flexite/shared/show_flash' })
35
36
  else
36
37
  ActionService::Result.new(data: response[:diffs], endpoint: { action: :sync_show })
@@ -1,3 +1,3 @@
1
1
  module Flexite
2
- VERSION = '0.0.10'
2
+ VERSION = '0.0.11'
3
3
  end
Binary file