Skip to content

Commit

Permalink
Fixed issue where push notifications would get sent out for narmal st…
Browse files Browse the repository at this point in the history
…ates when the node server starts up
  • Loading branch information
sbender9 committed Jan 5, 2017
1 parent 512256e commit bcf8ba4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = function(app) {
context: "vessels.self",
subscribe: [{
path: "notifications.*",
minPeriod: 1000
policy: 'instant'
}]
}

Expand Down Expand Up @@ -192,13 +192,17 @@ function handleNotificationDelta(app, id, notification, last_states)
&& typeof value.value.message != 'undefined'
&& value.value.message != null )
{
if ( last_states[value.path] == null
|| last_states[value.path] != value.value.state )
if ( (last_states[value.path] == null
&& value.value.state != 'normal')
|| ( last_states[value.path] != null
&& last_states[value.path] != value.value.state) )
{
last_states[value.path] = value.value.state
debug("message:" + value.value.message)
send_push(app, device, value.value.message, value.path)
}
else
debug("skipped")
}
else if ( last_states[value.path] )
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "signalk-push-notifications",
"version": "1.0.0",
"version": "1.0.2",
"description": "sognalk-node-server plugin that pushes SignalK notifications to Amazon SNS",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit bcf8ba4

Please sign in to comment.