Skip to content

Instantly share code, notes, and snippets.

@weepy
Created July 8, 2016 10:16
Show Gist options
  • Save weepy/a2f53fd7be36235ee50f264d22bef75c to your computer and use it in GitHub Desktop.
Save weepy/a2f53fd7be36235ee50f264d22bef75c to your computer and use it in GitHub Desktop.
function createNotifications() {
var activities = Activity.findAll({notified: false})
var notifications = activities.map(createNotifications)
notifications = flatten(notifications)
// later => notifications = simplify(notifications)
sendBulk(notifications, function() {
notifications.forEach((notification) => {
notification.set({notifed: true})
})
})
}
function createNotifications(activity) {
user = User.find(activity.userId)
return user.followers.map( id {
return new Notification(activity.type, activity, user.messagingId )
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment