maia 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/app/controllers/concerns/maia/controller.rb +12 -2
- data/lib/maia.rb +1 -0
- data/lib/maia/dry_run.rb +11 -0
- data/lib/maia/message.rb +9 -2
- data/lib/maia/messenger.rb +9 -1
- data/lib/maia/version.rb +1 -1
- metadata +26 -25
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZDNmY2UwNzgxMGIzMWY4MTU1MTg2OGUyMDMxYWYyNjc3NmFjZjllYw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NzIzMzg4Njg2MGJjYTk5MjQ0ODU4ODhlMjU1OWI0NDliYTFkYzIxOA==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YmYwMDYxMzFkODg1ZWEwOTg1MjYyOTY2ZGQ0YTg2YzE2NzQ4ZDk1N2JiNmEw
|
10
|
+
MGEzMmNkODg2ZWM4YjIwOGJiYWM4OGE5MmM3OTcwN2U4ZDg4OTA4MDFkOGYy
|
11
|
+
YjZlMzQ2ZWU2MzA4MDIzMjcxNGMwNGZhYmRiMTQyZDNjYWJlMDg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZTM2YzkxMjNkOWNmYjU1MmFiNjI4OGIxY2Q5NDBhNWQ2NGE0NzM4M2M1ZTFl
|
14
|
+
MjNjOGE3OTI5OTA4MGVkZjk0Yjc0NjUxODljNGI0MmIwMmE4MGU1MmM1YzVi
|
15
|
+
YTc0ZmY4NjI2NmE1MjcxZDNiOTUxMmQ0MGY2ZjFmZDE4ZGViMDQ=
|
@@ -3,16 +3,22 @@ module Maia
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
def create
|
6
|
-
if
|
6
|
+
if device_exists?
|
7
|
+
@device = find_device
|
7
8
|
update_token_expiration @device
|
8
9
|
else
|
9
10
|
@device = create_device_token
|
11
|
+
send_dry_run_to current_user
|
10
12
|
end
|
11
13
|
respond_with @device
|
12
14
|
end
|
13
15
|
|
14
16
|
private
|
15
|
-
def
|
17
|
+
def device_exists?
|
18
|
+
current_user.devices.exists? token: params[:device][:token]
|
19
|
+
end
|
20
|
+
|
21
|
+
def find_device
|
16
22
|
current_user.devices.find_by token: params[:device][:token]
|
17
23
|
end
|
18
24
|
|
@@ -25,6 +31,10 @@ module Maia
|
|
25
31
|
current_user.devices.create permitted_params
|
26
32
|
end
|
27
33
|
|
34
|
+
def send_dry_run_to(user)
|
35
|
+
Maia::DryRun.new.send_to user
|
36
|
+
end
|
37
|
+
|
28
38
|
def permitted_params
|
29
39
|
params.require(:device).permit :token
|
30
40
|
end
|
data/lib/maia.rb
CHANGED
data/lib/maia/dry_run.rb
ADDED
data/lib/maia/message.rb
CHANGED
@@ -42,10 +42,13 @@ module Maia
|
|
42
42
|
false
|
43
43
|
end
|
44
44
|
|
45
|
+
def dry_run?
|
46
|
+
false
|
47
|
+
end
|
48
|
+
|
45
49
|
def to_h
|
46
|
-
{
|
50
|
+
hash = {
|
47
51
|
data: other,
|
48
|
-
content_available: content_available?,
|
49
52
|
notification: {
|
50
53
|
title: alert,
|
51
54
|
body: alert,
|
@@ -53,6 +56,10 @@ module Maia
|
|
53
56
|
badge: badge
|
54
57
|
}.compact
|
55
58
|
}
|
59
|
+
|
60
|
+
hash.merge!(dry_run: true) if dry_run?
|
61
|
+
hash.merge!(content_available: true) if content_available?
|
62
|
+
hash
|
56
63
|
end
|
57
64
|
end
|
58
65
|
end
|
data/lib/maia/messenger.rb
CHANGED
@@ -37,7 +37,11 @@ module Maia
|
|
37
37
|
def update_devices_to_use_canonical_ids(results)
|
38
38
|
results.each do |result|
|
39
39
|
device = Maia::Device.find_by token: result.token
|
40
|
-
device.
|
40
|
+
if user_already_has_token_registered?(device.pushable, result.canonical_id)
|
41
|
+
device.destroy
|
42
|
+
else
|
43
|
+
device.update token: result.canonical_id
|
44
|
+
end
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
@@ -48,5 +52,9 @@ module Maia
|
|
48
52
|
def connection
|
49
53
|
nil # use the default
|
50
54
|
end
|
55
|
+
|
56
|
+
def user_already_has_token_registered?(user, token)
|
57
|
+
user.devices.exists? token: token
|
58
|
+
end
|
51
59
|
end
|
52
60
|
end
|
data/lib/maia/version.rb
CHANGED
metadata
CHANGED
@@ -1,153 +1,153 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Logan Serman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activejob
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '4.2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '4.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: responders
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '2.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: mercurius
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.1.9
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ! '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.1.9
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: sqlite3
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ! '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ! '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec-rails
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ! '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ! '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: capybara
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ! '>='
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ! '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: capybara-webkit
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ! '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ! '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: launchy
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ! '>='
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - ! '>='
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: webmock
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - ! '>='
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- -
|
150
|
+
- - ! '>='
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
description: Manage device tokens and push messaging with Rails and Mercurius.
|
@@ -167,6 +167,7 @@ files:
|
|
167
167
|
- config/routes.rb
|
168
168
|
- db/migrate/20150302191320_create_maia_devices.rb
|
169
169
|
- lib/maia.rb
|
170
|
+
- lib/maia/dry_run.rb
|
170
171
|
- lib/maia/engine.rb
|
171
172
|
- lib/maia/error.rb
|
172
173
|
- lib/maia/message.rb
|
@@ -183,17 +184,17 @@ require_paths:
|
|
183
184
|
- lib
|
184
185
|
required_ruby_version: !ruby/object:Gem::Requirement
|
185
186
|
requirements:
|
186
|
-
- -
|
187
|
+
- - ! '>='
|
187
188
|
- !ruby/object:Gem::Version
|
188
189
|
version: '0'
|
189
190
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
191
|
requirements:
|
191
|
-
- -
|
192
|
+
- - ! '>='
|
192
193
|
- !ruby/object:Gem::Version
|
193
194
|
version: '0'
|
194
195
|
requirements: []
|
195
196
|
rubyforge_project:
|
196
|
-
rubygems_version: 2.4.5
|
197
|
+
rubygems_version: 2.4.5
|
197
198
|
signing_key:
|
198
199
|
specification_version: 4
|
199
200
|
summary: Manage device tokens and push messaging with Rails and Mercurius.
|