mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Push notifications (#7682)
* Fix Social Push notifications * Fix code formatting issues * Fix commented issues * Fix Syntax errors * update push notify dependency * specify push-notify version * change how apn key is loaded * feat(push-notifications): improve logging * feat(push-notifications): disable v2 push notifications * test(push-notifications): add unit tests and improve integration ones * fix(push-notifications): throw when required params are missing * fix(tests): correct descriptions and remove wrong comment * fix(push-notifications): trim APN key * fix(apn): log feedback only if it has data * fix(apn): load cert and key differently * fix(tests): correctly load apn during tests * download creds from S3 and create AWS lib * convert s3 buffer to a string * fix(apn): remove console.log and do not use cert twice * invert key and cert, disable failing test * invert key and cert
This commit is contained in:
@@ -105,7 +105,16 @@ 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
|
||||
sendPushNotification(data.gift.member, shared.i18n.t('giftedSubscription'), `${months} months - by ${byUserName}`);
|
||||
if (data.gift.member.preferences.pushNotifications.giftedSubscription !== false) {
|
||||
sendPushNotification(data.gift.member,
|
||||
{
|
||||
title: shared.i18n.t('giftedSubscription'),
|
||||
message: shared.i18n.t('giftedSubscriptionInfo', {months, name: byUserName}),
|
||||
identifier: 'giftedSubscription',
|
||||
payload: {replyTo: data.user._id},
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +187,16 @@ 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
|
||||
sendPushNotification(data.gift.member, shared.i18n.t('giftedGems'), `${gemAmount} Gems - by ${byUsername}`);
|
||||
if (data.gift.member.preferences.pushNotifications.giftedGems !== false) {
|
||||
sendPushNotification(
|
||||
data.gift.member,
|
||||
{
|
||||
title: shared.i18n.t('giftedGems'),
|
||||
message: shared.i18n.t('giftedGemsInfo', {amount: gemAmount, name: byUsername}),
|
||||
identifier: 'giftedGems',
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
await data.gift.member.save();
|
||||
|
||||
Reference in New Issue
Block a user