Push event not triggered
syphernl opened this issue · 3 comments
The push event is not being triggered because it is being sent as a tickle, not a message.
Some logging from my test script:
Pushbullet: message received: {"subtype":"push","type":"tickle"}
Pushbullet: tickle received: "push"
It seems to me that the code should become:
else if (data.type === 'tickle') {
if(data.subtype === 'push') {
self.emit('push');
} else {
self.emit('tickle', data.subtype);
}
}
The push-tickle contains no data, an API call is required to load the actual push AFAIK.
That is how the streaming API works. Take a look at the "Push message type definitions" on http://docs.pushbullet.com/stream/ and you'll see there's only mirror
and dismiss
, nothing relating to new pushes.
The tickle
event is only meant to notify of something changing on the server. You can then request what's changed using the modified_after
parameter when requesting the pushes as mentioned in "Reacting to tickles" in the API docs.
A little odd API design on their part I guess, so the 'push' trigger will only trigger when something is being mirrored or dismissed from an Android device. Would've been more practical if the non-mirror pushes were also fully pushed without requiring an additional API call.
Either way it would still be nice if this module could trigger when a new push is available (which needs to be obtained via /v2/pushes
) instead of having to listen for tickles and the need for extra parsing in the script itself.
I guess it depends on what your use case is. If you want to monitor all pushes, no matter what device they're sent to, then yes it would be useful to automatically grab new pushes. If you're wanting to have a script as a device then that's a different matter.