mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
disable push notifications and fix buying gems
This commit is contained in:
@@ -6,7 +6,7 @@ import {
|
|||||||
} from './email';
|
} from './email';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import nconf from 'nconf';
|
import nconf from 'nconf';
|
||||||
import pushNotify from './pushNotifications';
|
import sendPushNotification from './pushNotifications';
|
||||||
import shared from '../../../../common' ;
|
import shared from '../../../../common' ;
|
||||||
|
|
||||||
const IS_PROD = nconf.get('IS_PROD');
|
const IS_PROD = nconf.get('IS_PROD');
|
||||||
@@ -102,7 +102,7 @@ api.createSubscription = async function createSubscription (data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (data.gift.member._id !== data.user._id) { // Only send push notifications if sending to a user other than yourself
|
if (data.gift.member._id !== data.user._id) { // Only send push notifications if sending to a user other than yourself
|
||||||
pushNotify.sendNotify(data.gift.member, shared.i18n.t('giftedSubscription'), `${months} months - by ${byUserName}`);
|
sendPushNotification(data.gift.member, shared.i18n.t('giftedSubscription'), `${months} months - by ${byUserName}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ api.buyGems = async function buyGems (data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (data.gift.member._id !== data.user._id) { // Only send push notifications if sending to a user other than yourself
|
if (data.gift.member._id !== data.user._id) { // Only send push notifications if sending to a user other than yourself
|
||||||
pushNotify.sendNotify(data.gift.member, shared.i18n.t('giftedGems'), `${gemAmount} Gems - by ${byUsername}`);
|
sendPushNotification(data.gift.member, shared.i18n.t('giftedGems'), `${gemAmount} Gems - by ${byUsername}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await data.gift.member.save();
|
await data.gift.member.save();
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import nconf from 'nconf';
|
import nconf from 'nconf';
|
||||||
import pushNotify from 'push-notify';
|
import pushNotify from 'push-notify';
|
||||||
@@ -26,9 +28,12 @@ if (gcm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = function sendNotification (user, title, message, timeToLive = 15) {
|
module.exports = function sendNotification (user, title, message, timeToLive = 15) {
|
||||||
if (!user) return;
|
return; // TODO push notifications are not currently enabled
|
||||||
|
|
||||||
_.each(user.pushDevices, pushDevice => {
|
if (!user) return;
|
||||||
|
let pushDevices = user.pushDevices.toObject ? user.pushDevices.toObject() : user.pushDevices;
|
||||||
|
|
||||||
|
_.each(pushDevices, pushDevice => {
|
||||||
switch (pushDevice.type) {
|
switch (pushDevice.type) {
|
||||||
case 'android':
|
case 'android':
|
||||||
if (gcm) {
|
if (gcm) {
|
||||||
|
|||||||
Reference in New Issue
Block a user