draisine 0.7.10 → 0.7.12

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: d532674344caaa230a569619645f1741bc250576
4
- data.tar.gz: dfa98a38eaace1c4358310a3580c87020d8ee016
3
+ metadata.gz: e02084ec5e958abc727a572424931988333da60c
4
+ data.tar.gz: 263bfc31d6f0f5728cefaae6533f929b1a23b4e7
5
5
  SHA512:
6
- metadata.gz: 7c94c9310d3dea3f8d4a64f2c07bd162dc8409ad18fa715f575c80e271656d43e37e8335e2d146c27447ba6d6cfea50375313cf1503d76daa533508b2f37a1e9
7
- data.tar.gz: df7c45a1aace9a9775ac5ea2bf0e3b1f8cecf260e72d3593c02778b602c647a08e65ed828930d02353ad4477d9172c6028e1ce8a0be90859e96bfb5aa497a8ca
6
+ metadata.gz: 667c1187aa466afe49c43335ca603786db538985481a288d4c14f781226ee05ff009ace0c970c603e61d027f146f7426b8b53ffd3e3727ab6a017742e2ef7ce1
7
+ data.tar.gz: babbfc5d421361b6ff4d6cc7cfd6e70ffd1c615df1611dc675b0b7c6c9a4a6bad1b3e5efc967444cf94bd32f5c51f554911ccb00adafd07124d3933ff28d2347
@@ -5,7 +5,7 @@ module Draisine
5
5
  before_filter :validate_ip
6
6
 
7
7
  def update
8
- message = request.body.read
8
+ message = incoming_xml
9
9
  if Draisine.sync_soap_operations?
10
10
  Draisine::SoapUpdateJob.perform_now(message)
11
11
  else
@@ -16,7 +16,7 @@ module Draisine
16
16
  end
17
17
 
18
18
  def delete
19
- message = request.body.read
19
+ message = incoming_xml
20
20
  if Draisine.sync_soap_operations?
21
21
  Draisine::SoapDeleteJob.perform_now(message)
22
22
  else
@@ -45,5 +45,9 @@ module Draisine
45
45
  </soapenv:Envelope>
46
46
  EOF
47
47
  end
48
+
49
+ def incoming_xml
50
+ Draisine::Encoding.convert_to_utf_and_sanitize(request.body.read)
51
+ end
48
52
  end
49
53
  end
@@ -33,6 +33,7 @@ module Draisine
33
33
  end
34
34
 
35
35
  def deserialize(job_data)
36
+ super
36
37
  @retry_attempt = job_data.fetch('_retry_attempt', 0)
37
38
  end
38
39
  end
@@ -44,7 +44,7 @@ module Draisine
44
44
  when String
45
45
  Hash.from_xml(message_xml)
46
46
  else
47
- raise ArgumentError
47
+ fail ArgumentError, "unknown message type: #{message_xml.inspect}"
48
48
  end
49
49
  end
50
50
 
@@ -57,13 +57,13 @@ module Draisine
57
57
  def assert_valid_organization_id!(message)
58
58
  unless diggable_to?(message, ['Envelope', 'Body', 'notifications', 'OrganizationId']) &&
59
59
  message['Envelope']['Body']['notifications']['OrganizationId'] == Draisine.organization_id
60
- fail InvalidOrganizationError, "a message from invalid organization id received"
60
+ fail InvalidOrganizationError, "a message from invalid organization id received, source xml: #{message.inspect}"
61
61
  end
62
62
  end
63
63
 
64
64
  def assert_valid_message!(message)
65
65
  unless diggable_to?(message, ['Envelope', 'Body', 'notifications', 'Notification'])
66
- fail ArgumentError, "malformed xml inbound message from salesforce"
66
+ fail ArgumentError, "malformed xml inbound message from salesforce, source xml: #{message.inspect}"
67
67
  end
68
68
  assert_valid_organization_id!(message)
69
69
  end
@@ -0,0 +1,7 @@
1
+ module Draisine
2
+ module Encoding
3
+ def self.convert_to_utf_and_sanitize(string)
4
+ string.encode("UTF-8", invalid: :replace, undef: :replace, replace: "?")
5
+ end
6
+ end
7
+ end
@@ -24,7 +24,7 @@ module Draisine
24
24
  def salesforce_cleanup(value)
25
25
  case value
26
26
  when String
27
- value.encode("UTF-8", invalid: :replace, undef: :replace, replace: "?")
27
+ Draisine::Encoding.convert_to_utf_and_sanitize(value)
28
28
  else
29
29
  value
30
30
  end
@@ -1,3 +1,3 @@
1
1
  module Draisine
2
- VERSION = "0.7.10"
2
+ VERSION = "0.7.12"
3
3
  end
data/lib/draisine.rb CHANGED
@@ -2,6 +2,7 @@ require "active_support"
2
2
  require "active_support/core_ext"
3
3
  require "active_support/concern"
4
4
  require "active_job/base"
5
+ require "ext/active_job"
5
6
 
6
7
  require "databasedotcom"
7
8
  require "ext/databasedotcom"
@@ -25,6 +26,7 @@ require "draisine/util/hash_diff"
25
26
  require "draisine/util/parse_time"
26
27
  require "draisine/util/salesforce_comparisons"
27
28
  require "draisine/util/caching_client"
29
+ require "draisine/util/encoding"
28
30
 
29
31
  require "draisine/query_mechanisms"
30
32
  require "draisine/partitioner"
@@ -0,0 +1,31 @@
1
+ # Borrowed from:
2
+ # https://github.com/isaacseymour/activejob-retry/blob/master/lib/active_job/retry/deserialize_monkey_patch.rb
3
+ # Unneccessary after rails 5+
4
+
5
+ # In Rails 4.2, ActiveJob externally applies deserialized job ID, queue name, arguments to
6
+ # the instantiated job in `ActiveJob::Base.deserialize`, which cannot be overridden in
7
+ # subclasses. https://github.com/rails/rails/pull/18260 changes this to delegate as much
8
+ # of the deserialization as possible to the instance, i.e. `ActiveJob::Base#deserialize`,
9
+ # which can be overridden. This allows us to store extra information in the queue (i.e.
10
+ # retry_attempt), which is essential for ActiveJob::Retry.
11
+ #
12
+ # This monkey patch is automatically applied if necessary when ActiveJob::Retry is
13
+ # required.
14
+
15
+ unless ActiveJob::Base.method_defined?(:deserialize)
16
+ module ActiveJob
17
+ class Base
18
+ def self.deserialize(job_data)
19
+ job = job_data['job_class'].constantize.new
20
+ job.deserialize(job_data)
21
+ job
22
+ end
23
+
24
+ def deserialize(job_data)
25
+ self.job_id = job_data['job_id']
26
+ self.queue_name = job_data['queue_name']
27
+ self.serialized_arguments = job_data['arguments']
28
+ end
29
+ end
30
+ end
31
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: draisine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.10
4
+ version: 0.7.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Abramov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-23 00:00:00.000000000 Z
11
+ date: 2017-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -203,10 +203,12 @@ files:
203
203
  - lib/draisine/syncer.rb
204
204
  - lib/draisine/type_mapper.rb
205
205
  - lib/draisine/util/caching_client.rb
206
+ - lib/draisine/util/encoding.rb
206
207
  - lib/draisine/util/hash_diff.rb
207
208
  - lib/draisine/util/parse_time.rb
208
209
  - lib/draisine/util/salesforce_comparisons.rb
209
210
  - lib/draisine/version.rb
211
+ - lib/ext/active_job.rb
210
212
  - lib/ext/databasedotcom.rb
211
213
  - lib/generators/draisine/delta_migration_generator.rb
212
214
  - lib/generators/draisine/integration_generator.rb