notifiable-core 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/notifiable/notification.rb +10 -2
- data/lib/notifiable/notification_status.rb +8 -0
- data/lib/notifiable/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98c5713043730258b62c23e08942daba07ec2d600373c65d64494f6fd34d9a01
|
4
|
+
data.tar.gz: 33bdabb3ed2d2a8dbf0fb61dbb5eaa0eeb83972f22ba1f3f31b666afbd3739b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ca200e50537f583ebadb0145431254eb4fa071fa3874371f963a67251661234dbb64ab7c76e75cf36d497b3c29a577803ef1d7395138117fd65082aeaf1e21c
|
7
|
+
data.tar.gz: 89d927957447f6de3d02bb0fed70768f589295836785aee0b40d57f382d13a0eff662b7cb7d47a4c5cab042252e93b811d94adad401eec2749adeb7d767bd2cf
|
@@ -48,13 +48,21 @@ module Notifiable
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def delivered!(device_token)
|
51
|
+
if notification_statuses.exists?(device_token: device_token)
|
52
|
+
s = notification_statuses.find_by(device_token: device_token)
|
53
|
+
return if s.delivered?
|
54
|
+
s.delivered!
|
55
|
+
end
|
51
56
|
increment!(:delivered_count)
|
52
|
-
notification_statuses.find_by(device_token: device_token).delivered! if notification_statuses.exists?(device_token: device_token)
|
53
57
|
end
|
54
58
|
|
55
59
|
def opened!(device_token)
|
60
|
+
if notification_statuses.exists?(device_token: device_token)
|
61
|
+
s = notification_statuses.find_by(device_token: device_token)
|
62
|
+
return if s.opened?
|
63
|
+
s.opened!
|
64
|
+
end
|
56
65
|
increment!(:opened_count)
|
57
|
-
notification_statuses.find_by(device_token: device_token).opened! if notification_statuses.exists?(device_token: device_token)
|
58
66
|
end
|
59
67
|
|
60
68
|
private
|
@@ -27,8 +27,16 @@ module Notifiable
|
|
27
27
|
update_attributes(status: DELIVERED_STATUS)
|
28
28
|
end
|
29
29
|
|
30
|
+
def delivered?
|
31
|
+
status == DELIVERED_STATUS
|
32
|
+
end
|
33
|
+
|
30
34
|
def opened!
|
31
35
|
update_attributes(status: OPENED_STATUS)
|
32
36
|
end
|
37
|
+
|
38
|
+
def opened?
|
39
|
+
status == OPENED_STATUS
|
40
|
+
end
|
33
41
|
end
|
34
42
|
end
|
data/lib/notifiable/version.rb
CHANGED