mozilla / openbadges-backpack

Mozilla Open Badges Backpack
https://backpack.openbadges.org/
Other
862 stars 263 forks source link

create a postsave function for badges #644

Open davelester opened 11 years ago

davelester commented 11 years ago

Add a postsave function in mysql-base.js for actions to be performed after data is added to the database. Currently, there is only a presave function.

The postsave function will also be added to the badges model, so that each time a badge is added to the backpack it checks if that user has given Facebook autopush permission. If they have, the autopushing will be triggered in the background. This directly relates to issue #548.

davelester commented 11 years ago

Postsave should be called for badges, checking if a user has an entry for fb_access_token (meaning that they've enabled facebook autopush and have a token). If true, call publishBadge in the Facebook library.

davelester commented 11 years ago

Here's a gist of something I previously started to create a postsave function: https://gist.github.com/davelester/5140329

Does not yet incl check if user has autopush permission (which is just a matter of seeing if they have an access token saved to the database), and push a badge to FB. Up for grabs if someone wants to tackle this.