feat(donate): Add donate api (#17459)

* feat(donate): Add donate api

* feat(donation): Add ability to track donations via email
This commit is contained in:
Stuart Taylor
2018-06-07 22:35:06 +01:00
committed by Quincy Larson
parent 3f61c1356f
commit 4f77da02be
12 changed files with 332 additions and 21 deletions

View File

@ -518,6 +518,25 @@ module.exports = function(User) {
)({ ttl });
};
User.prototype.createDonation = function createDonation(donation = {}) {
return Observable.fromNodeCallback(
this.donations.create.bind(this.donations)
)(donation)
.do(() => this.update$({
$set: {
isDonating: true
},
$push: {
donationEmails: donation.email
}
})
)
.do(() => {
this.isDonating = true;
this.donationEmails = [ ...this.donationEmails, donation.email ];
});
};
User.prototype.getEncodedEmail = function getEncodedEmail(email) {
if (!email) {
return null;