rhosync 2.1.17 → 2.1.18.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/lib/rhosync/jobs/ping_job.rb +35 -30
- data/lib/rhosync/version.rb +1 -1
- data/spec/jobs/ping_job_spec.rb +7 -1
- metadata +13 -9
data/CHANGELOG
CHANGED
@@ -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
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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 "
|
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
|
data/lib/rhosync/version.rb
CHANGED
data/spec/jobs/ping_job_spec.rb
CHANGED
@@ -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:
|
5
|
-
prerelease:
|
4
|
+
hash: 2417247871
|
5
|
+
prerelease: 7
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
|
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-
|
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:
|
592
|
+
hash: 25
|
591
593
|
segments:
|
592
|
-
-
|
593
|
-
|
594
|
+
- 1
|
595
|
+
- 3
|
596
|
+
- 1
|
597
|
+
version: 1.3.1
|
594
598
|
requirements: []
|
595
599
|
|
596
600
|
rubyforge_project:
|