notifiable-gcm-spacialdb 0.4.2 → 0.4.3

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: cd98a6be8783100300154e6dabfe514771630524
4
- data.tar.gz: 53a027e3e0315e4b3305ce3f8220aac020b5bc03
3
+ metadata.gz: 39da622a652408c9b14236037e7c5f3277b47ccb
4
+ data.tar.gz: 4b077b4d0e543dfbea5d478619bb6d9ea2eaa471
5
5
  SHA512:
6
- metadata.gz: 680d7722e66bfe5ce3d270bb323af11c62900c8a57d57017b9395ac81029684d9ba489204fb02dcff5056b899cc66d0bc5905378697df48e7b4d6b60f6902e73
7
- data.tar.gz: 9893300d74883628afe35ff2e040f287dede7b6e8e5ae45ffc02fc7fb3e38f2d1ca6dd04f044bf82484cc30fda999cf3b6405d3ea56c21ade2a03f7cad5f22b9
6
+ metadata.gz: 887884ce3c312cb2b85f7fbf0a81101f1bee97c6884d47947d2d764e259c9a3c15013a4df2315e2f9ff01c7f61be108f1c9264fd2b5ae78d09ac29a0eb4d77a4
7
+ data.tar.gz: 3882e1069905b53f58541148a5094a35d52969d0438c87478397f0cf19b3f2b4f1aafd282a4260451408ebb12d38aa551898e24f54a0d95b8a9cfc4a3b1204e2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- notifiable-gcm-spacialdb (0.4.2)
4
+ notifiable-gcm-spacialdb (0.4.3)
5
5
  gcm (~> 0.0.6)
6
6
  notifiable-rails (>= 0.6.0)
7
7
 
@@ -45,22 +45,26 @@ module Notifiable
45
45
 
46
46
  # send
47
47
  response = gcm.send_notification(device_tokens.collect{|dt| dt.token}, {:data => data})
48
- body = JSON.parse(response.fetch(:body, "{}"))
49
- results = body.fetch("results", [])
50
- results.each_with_index do |result, idx|
51
- # Remove the token if it is marked NotRegistered (user deleted the App for example)
52
- if ["InvalidRegistration", "NotRegistered"].include? result["error"]
53
- device_tokens[idx].update_attribute('is_valid', false)
54
- else
48
+ if response[:status_code] == 200
49
+ body = JSON.parse(response.fetch(:body, "{}"))
50
+ results = body.fetch("results", [])
51
+ results.each_with_index do |result, idx|
52
+ # Remove the token if it is marked NotRegistered (user deleted the App for example)
53
+ if ["InvalidRegistration", "NotRegistered"].include? result["error"]
54
+ device_tokens[idx].update_attribute('is_valid', false)
55
+ else
55
56
 
56
- # Update the token if a canonical ID is returned
57
- if result["registration_id"]
58
- device_tokens[idx].update_attribute('token', result["registration_id"])
59
- end
60
- end
57
+ # Update the token if a canonical ID is returned
58
+ if result["registration_id"]
59
+ device_tokens[idx].update_attribute('token', result["registration_id"])
60
+ end
61
+ end
61
62
 
62
- processed(notification, device_tokens[idx], error_code(result["error"]))
63
- end
63
+ processed(notification, device_tokens[idx], error_code(result["error"]))
64
+ end
65
+ else
66
+ Rails.logger.error "Sending notification id: #{notification.id} code: #{response[:status_code]} response: #{response[:response]}"
67
+ end
64
68
  end
65
69
  self.batch.delete(notification.id)
66
70
  end
@@ -1,7 +1,7 @@
1
1
  module Notifiable
2
2
  module Gcm
3
3
  module Spacialdb
4
- VERSION = "0.4.2"
4
+ VERSION = "0.4.3"
5
5
  end
6
6
  end
7
7
  end
@@ -70,6 +70,14 @@ describe Notifiable::Gcm::Spacialdb::Batch do
70
70
  d.token.should eql "GHJ12345"
71
71
  end
72
72
 
73
+ it "deals gracefully with an unauthenticated key" do
74
+ stub_request(:post, "https://android.googleapis.com/gcm/send").to_return(:body => '<html>Message</html>', :status => 401)
75
+
76
+ Notifiable.batch {|b| b.add(n, u)}
77
+
78
+ Notifiable::NotificationStatus.count.should == 0
79
+ end
80
+
73
81
  end
74
82
 
75
83
  User = Struct.new(:device_token) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notifiable-gcm-spacialdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kamil Kocemba
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-14 00:00:00.000000000 Z
12
+ date: 2014-02-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: notifiable-rails