rhosync 2.1.17 → 2.1.18.beta1

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.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ ## 2.1.18.beta1
2
+ * #31161737 - PingJob handles missing user ids or users with no clients
3
+
1
4
  ## 2.1.17
2
5
  * Reset device attributes if Android ping returns "Not Registered" Error
3
6
  * #29214293 - do not execute ping if the platform is not configured
@@ -25,42 +25,47 @@ module Rhosync
25
25
  # all errors are recorded here
26
26
  errors = []
27
27
  user = User.load(user_id)
28
- user.clients.members.each do |client_id|
29
- client = Client.load(client_id,{:source_name => '*'})
30
- params.merge!('device_port' => client.device_port, 'device_pin' => client.device_pin, 'phone_id' => client.phone_id,
31
- 'client_id' => client_id)
32
- send_push = false
33
- if client.device_type and client.device_type.size > 0
34
- if client.phone_id and client.phone_id.size > 0
35
- unless phone_ids.include? client.phone_id
36
- phone_ids << client.phone_id
37
- send_push = true
38
- end
39
- elsif client.device_pin and client.device_pin.size > 0
40
- unless device_pins.include? client.device_pin
41
- device_pins << client.device_pin
42
- send_push = true
28
+ clients = user.clients if user
29
+ if clients
30
+ clients.members.each do |client_id|
31
+ client = Client.load(client_id,{:source_name => '*'})
32
+ params.merge!('device_port' => client.device_port, 'device_pin' => client.device_pin, 'phone_id' => client.phone_id,
33
+ 'client_id' => client_id)
34
+ send_push = false
35
+ if client.device_type and client.device_type.size > 0
36
+ if client.phone_id and client.phone_id.size > 0
37
+ unless phone_ids.include? client.phone_id
38
+ phone_ids << client.phone_id
39
+ send_push = true
40
+ end
41
+ elsif client.device_pin and client.device_pin.size > 0
42
+ unless device_pins.include? client.device_pin
43
+ device_pins << client.device_pin
44
+ send_push = true
45
+ end
46
+ else
47
+ log "Skipping ping for non-registered client_id '#{client_id}'..."
48
+ next
43
49
  end
44
- else
45
- log "Skipping ping for non-registered client_id '#{client_id}'..."
46
- next
47
- end
48
- if send_push
49
- klass = Object.const_get(camelize(client.device_type.downcase))
50
- if klass
51
- params['vibrate'] = params['vibrate'].to_s
52
- begin
53
- klass.ping(params)
54
- rescue Exception => e
55
- errors << e
50
+ if send_push
51
+ klass = Object.const_get(camelize(client.device_type.downcase))
52
+ if klass
53
+ params['vibrate'] = params['vibrate'].to_s
54
+ begin
55
+ klass.ping(params)
56
+ rescue Exception => e
57
+ errors << e
58
+ end
56
59
  end
60
+ else
61
+ log "Dropping ping request for client_id '#{client_id}' because it's already in user's device pin or phone_id list."
57
62
  end
58
63
  else
59
- log "Dropping ping request for client_id '#{client_id}' because it's already in user's device pin or phone_id list."
64
+ log "Skipping ping for non-registered client_id '#{client_id}'..."
60
65
  end
61
- else
62
- log "Skipping ping for non-registered client_id '#{client_id}'..."
63
66
  end
67
+ else
68
+ log "Skipping ping for unknown user '#{user_id}' or '#{user_id}' has no registered clients..."
64
69
  end
65
70
  errors
66
71
  end
@@ -1,3 +1,3 @@
1
1
  module Rhosync
2
- VERSION = '2.1.17'
2
+ VERSION = '2.1.18.beta1'
3
3
  end
@@ -110,5 +110,11 @@ describe "PingJob" do
110
110
  exception_raised.should == true
111
111
  end
112
112
 
113
-
113
+ it "should skip ping for unknown user or user with no clients" do
114
+ params = {"user_id" => [ 'fake_user' ], "api_token" => @api_token,
115
+ "sources" => [@s.name], "message" => 'hello world',
116
+ "vibrate" => '5', "badge" => '5', "sound" => 'hello.mp3', 'phone_id' => nil }
117
+ PingJob.should_receive(:log).once.with(/Skipping ping for unknown user 'fake_user' or 'fake_user' has no registered clients.../)
118
+ PingJob.perform(params)
119
+ end
114
120
  end
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhosync
3
3
  version: !ruby/object:Gem::Version
4
- hash: 41
5
- prerelease:
4
+ hash: 2417247871
5
+ prerelease: 7
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
- - 17
10
- version: 2.1.17
9
+ - 18
10
+ - beta
11
+ - 1
12
+ version: 2.1.18.beta1
11
13
  platform: ruby
12
14
  authors:
13
15
  - Rhomobile
@@ -15,7 +17,7 @@ autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2012-05-28 00:00:00 Z
20
+ date: 2012-06-13 00:00:00 Z
19
21
  dependencies:
20
22
  - !ruby/object:Gem::Dependency
21
23
  name: sinatra
@@ -585,12 +587,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
585
587
  required_rubygems_version: !ruby/object:Gem::Requirement
586
588
  none: false
587
589
  requirements:
588
- - - ">="
590
+ - - ">"
589
591
  - !ruby/object:Gem::Version
590
- hash: 3
592
+ hash: 25
591
593
  segments:
592
- - 0
593
- version: "0"
594
+ - 1
595
+ - 3
596
+ - 1
597
+ version: 1.3.1
594
598
  requirements: []
595
599
 
596
600
  rubyforge_project: