Skip to content

Instantly share code, notes, and snippets.

@claudiopro
Created October 9, 2014 21:36
Show Gist options
  • Save claudiopro/636b21bdb00082a103bb to your computer and use it in GitHub Desktop.
Save claudiopro/636b21bdb00082a103bb to your computer and use it in GitHub Desktop.
Poll Activity Stream notifications and print the total count (action required + unread mentions + unread notifications)
(function poll_notifications() {
var dfd = dojo.xhrGet({
url : '/connections/opensocial/basic/rest/activitystreams/@me/@actions',
handleAs : 'json'
});
dfd.addCallback(function(response, ioargs) {
var count = response.totalResults + response.connections.unreadMentions + response.connections.unreadNotifications;
console.log(count);
setTimeout(poll_notifications, 30000);
});
dfd.addErrback(function(response, ioargs) {
console.error(response);
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment