mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 20:12:19 +00:00
parent
c32cd57c92
commit
ad146d6d88
1 changed files with 1 additions and 64 deletions
|
|
@ -10,7 +10,6 @@ var User = require('./../models/user').model;
|
||||||
var ga = require('./../utils').ga;
|
var ga = require('./../utils').ga;
|
||||||
var logging = require('./../logging');
|
var logging = require('./../logging');
|
||||||
var userAPI = require('./user');
|
var userAPI = require('./user');
|
||||||
var request = require('request');
|
|
||||||
var api = module.exports;
|
var api = module.exports;
|
||||||
var isProduction = nconf.get("NODE_ENV") === "production";
|
var isProduction = nconf.get("NODE_ENV") === "production";
|
||||||
|
|
||||||
|
|
@ -55,37 +54,6 @@ function createSubscription(user, data) {
|
||||||
revealMysteryItems(user);
|
revealMysteryItems(user);
|
||||||
user.purchased.txnCount++;
|
user.purchased.txnCount++;
|
||||||
ga.event('subscribe', data.paymentMethod).send()
|
ga.event('subscribe', data.paymentMethod).send()
|
||||||
if(isProduction){
|
|
||||||
var email, name;
|
|
||||||
if(user.auth.local){
|
|
||||||
email = user.auth.local.email;
|
|
||||||
name = user.profile.name || user.auth.local.username;
|
|
||||||
}else if(user.auth.facebook && user.auth.facebook.emails && user.auth.facebook.emails[0] && user.auth.facebook.emails[0].value){
|
|
||||||
email = user.auth.facebook.emails[0].value;
|
|
||||||
name = user.auth.facebook.displayName || user.auth.facebook.username;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(email){
|
|
||||||
request({
|
|
||||||
url: nconf.get('EMAIL_SERVER_URL') + '/job',
|
|
||||||
method: 'POST',
|
|
||||||
auth: {
|
|
||||||
user: nconf.get('EMAIL_SERVER_AUTH_USER'),
|
|
||||||
pass: nconf.get('EMAIL_SERVER_AUTH_PASSWORD')
|
|
||||||
},
|
|
||||||
json: {
|
|
||||||
type: 'email',
|
|
||||||
data: {
|
|
||||||
emailType: 'subscription-begins',
|
|
||||||
to: {
|
|
||||||
name: req.user.displayName || req.user.username,
|
|
||||||
email: req.user.emails[0].value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ga.transaction(data.customerId, 5).item(5, 1, data.paymentMethod.toLowerCase() + '-subscription', data.paymentMethod + " > Stripe").send();
|
ga.transaction(data.customerId, 5).item(5, 1, data.paymentMethod.toLowerCase() + '-subscription', data.paymentMethod + " > Stripe").send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,37 +74,6 @@ function buyGems(user, data) {
|
||||||
user.purchased.txnCount++;
|
user.purchased.txnCount++;
|
||||||
ga.event('checkout', data.paymentMethod).send();
|
ga.event('checkout', data.paymentMethod).send();
|
||||||
ga.transaction(data.customerId, 5).item(5, 1, data.paymentMethod.toLowerCase() + "-checkout", "Gems > " + data.paymentMethod).send();
|
ga.transaction(data.customerId, 5).item(5, 1, data.paymentMethod.toLowerCase() + "-checkout", "Gems > " + data.paymentMethod).send();
|
||||||
if(isProduction){
|
|
||||||
var email, name;
|
|
||||||
if(user.auth.local){
|
|
||||||
email = user.auth.local.email;
|
|
||||||
name = user.profile.name || user.auth.local.username;
|
|
||||||
}else if(user.auth.facebook && user.auth.facebook.emails && user.auth.facebook.emails[0] && user.auth.facebook.emails[0].value){
|
|
||||||
email = user.auth.facebook.emails[0].value;
|
|
||||||
name = user.auth.facebook.displayName || user.auth.facebook.username;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(email){
|
|
||||||
request({
|
|
||||||
url: nconf.get('EMAIL_SERVER_URL') + '/job',
|
|
||||||
method: 'POST',
|
|
||||||
auth: {
|
|
||||||
user: nconf.get('EMAIL_SERVER_AUTH_USER'),
|
|
||||||
pass: nconf.get('EMAIL_SERVER_AUTH_PASSWORD')
|
|
||||||
},
|
|
||||||
json: {
|
|
||||||
type: 'email',
|
|
||||||
data: {
|
|
||||||
emailType: 'donation',
|
|
||||||
to: {
|
|
||||||
name: req.user.displayName || req.user.username,
|
|
||||||
email: req.user.emails[0].value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expose some functions for tests
|
// Expose some functions for tests
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue