maia 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTU2MWJjMTUwZWIwMDg1MWY5NmFmYTM2ZGQ3ZDdmNTg5NTAzYWYxZg==
4
+ NjQwZjhhYTUxZDIyODAzZmFmOGIwMWQ1Mjc5MTc2NWYxOTYyZjI4OQ==
5
5
  data.tar.gz: !binary |-
6
- ZDMzNmZkOTI5MTM4ZGYzMTAzYzI3MTMwZWRlZWFlNGUwMWQ3MzJiZQ==
6
+ MTYzNmRiZDJmNmI2NjJjZDMzNGVjZmJjN2I1OGMxMzc4ZmUzNTdhYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NGM0ZTJhYzczMDU3YjYyY2QzYjgyMmYyN2Y5ZTIzNzQ2YTFlYjgxYjI3ZGYy
10
- MmFlNmNkYmJiNDE3ZDUzZTk5MTNmZmQ3MzlmN2RlMDhiYmIwYzQyMWIxYmYz
11
- NjdlYWZkYmFlNzk4ZWMzNzgzZmNkYTUxMjQ0NmY1Yzk4NjJlYzQ=
9
+ Zjk0YWZiZTQzMzBlNWY4MzQxMTY0NGE5YjdiMzg2MWI1NjFiMTNkOGU5YjEz
10
+ OWU2NTUyYWY2YzY4Y2Y2MGYxM2RjMjA3OWI0YmMzMTBkZDMyNDk5NTYzNmI3
11
+ NjA5MDhhZWEyMDc2NDA5YjA2ZDgyZTE5ZjNiMDY3Y2E0M2I5ODA=
12
12
  data.tar.gz: !binary |-
13
- ZTUwYmE2NTA2NDI5NWI3NTM0NWE2NDRmMmE5NTdjODUyNzVhZTVkNTVkMzc2
14
- NjhmNDdkNDBhOTU1NTY4MDA3MDFhOTkzYmNiZWE1YmQ0ZTMyMTBiZjAyNDYy
15
- OTRhYTJjNjlkOTk0MDVlNzFhN2ViYTQyYWU0ZWY3OGIxNGRlM2I=
13
+ OWYxMzI0ZmYwYjhiZmE5NGI5MjAwYjNlZDk0NTc0YmQwMjNhMTk0ZWUxNTMy
14
+ MTYwNjE4MDIzNzZkZDBiMGQwYmMzZDczYjg4MWE0ZTE5ZGIyMzAwNDQ3ZDAw
15
+ YWEyZGIyOTQ2N2U3NTdiYTU1NTg3YWQ1MzZiMTEyNjQxYWRmMmY=
@@ -30,10 +30,11 @@ module Maia
30
30
  def handle_failed_tokens(results)
31
31
  results.each do |result|
32
32
  device = Maia::Device.find_by(token: result.token)
33
- logger.info "#{result.token} failed: #{result.error}"
34
- if device && invalid_token_error?(result.error)
35
- logger.info "Invalid token #{device.token} - destroying device #{device.id}."
33
+ if device && device_unrecoverable?(result.error)
34
+ log_error "Destroying device #{device.id}", result, device
36
35
  device.destroy
36
+ else
37
+ log_error "Push to device #{device.id} failed", result, device
37
38
  end
38
39
  end
39
40
  end
@@ -50,12 +51,16 @@ module Maia
50
51
  end
51
52
  end
52
53
 
53
- def invalid_token_error?(error)
54
- error =~ /InvalidRegistration|NotRegistered/
54
+ def device_unrecoverable?(error)
55
+ error =~ /InvalidRegistration|NotRegistered|MismatchSenderId/
55
56
  end
56
57
 
57
58
  def user_already_has_token_registered?(user, token)
58
59
  user.devices.exists? token: token
59
60
  end
61
+
62
+ def log_error(message, result, device)
63
+ logger.info "#{message} (error: #{result.error}, token: #{device.token})"
64
+ end
60
65
  end
61
66
  end
data/lib/maia/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Maia
2
- VERSION = '1.0.2'.freeze
2
+ VERSION = '1.0.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maia
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Logan Serman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-31 00:00:00.000000000 Z
11
+ date: 2016-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails