notificon 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/notificon/controller.rb +10 -6
- data/lib/notificon/version.rb +1 -1
- metadata +1 -1
data/lib/notificon/controller.rb
CHANGED
@@ -2,14 +2,18 @@
|
|
2
2
|
#
|
3
3
|
# class ApplicationController
|
4
4
|
# include Notificon::Controller
|
5
|
-
# before_filter :notificon_tracker
|
6
5
|
#
|
7
6
|
# end
|
8
7
|
module Notificon
|
9
8
|
module Controller
|
10
9
|
|
11
10
|
def self.included(base)
|
12
|
-
|
11
|
+
if base.respond_to?(:before_filter)
|
12
|
+
base.before_filter :notificon_tracker
|
13
|
+
Notificon.logger.info { "Notificon::Controller.included wired up before_filter :notificon_tracker" }
|
14
|
+
else
|
15
|
+
Notificon.logger.info { "Notificon::Controller.included before_filter method not found" }
|
16
|
+
end
|
13
17
|
end
|
14
18
|
|
15
19
|
# Public : method to use as a before filter on the application controller to track read status
|
@@ -19,18 +23,18 @@ module Notificon
|
|
19
23
|
def notificon_tracker
|
20
24
|
request.get? && (_track_explicit_read | _track_implicit_read)
|
21
25
|
rescue => e
|
22
|
-
Notificon.logger.
|
26
|
+
Notificon.logger.info { "Notificon::Controller#notificon_tracker error processing notification params - #{params.inspect} error - #{e.inspect}" }
|
23
27
|
end
|
24
28
|
|
25
29
|
# Private : uses notificon explicit parameters to track reads for items
|
26
30
|
def _track_explicit_read
|
27
31
|
if params[Notificon.notification_item_id_param] && params[Notificon.notification_username_param]
|
28
32
|
Notificon.mark_all_read_for_item(params[Notificon.notification_username_param], params[Notificon.notification_item_id_param], _notificon_read_at)
|
29
|
-
Notificon.logger.
|
33
|
+
Notificon.logger.info { "Notificon::Controller#_track_explicit_read - all for item #{params[Notificon.notification_item_id_param]} #{params[Notificon.notification_username_param]}" }
|
30
34
|
true
|
31
35
|
elsif id = params[Notificon.notification_id_param]
|
32
36
|
Notificon.mark_notification_read(id, _notificon_read_at)
|
33
|
-
Notificon.logger.
|
37
|
+
Notificon.logger.info { "Notificon::Controller#_track_explicit_read - specific notification #{params[Notificon.notification_id_param]}" }
|
34
38
|
true
|
35
39
|
end
|
36
40
|
end
|
@@ -39,7 +43,7 @@ module Notificon
|
|
39
43
|
def _track_implicit_read
|
40
44
|
if respond_to?(:current_username) && respond_to?(:current_item_id) && current_username && current_item_id
|
41
45
|
Notificon.mark_all_read_for_item(current_username, current_item_id, _notificon_read_at)
|
42
|
-
Notificon.logger.
|
46
|
+
Notificon.logger.info { "Notificon::Controller#_track_implicit_read - for user #{current_username} and item #{current_item_id}" }
|
43
47
|
true
|
44
48
|
end
|
45
49
|
end
|
data/lib/notificon/version.rb
CHANGED