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:
Matteo Pagliazzi
2016-06-23 00:19:37 +02:00
committed by GitHub
parent 09c7c45cd5
commit 08d7727881
26 changed files with 626 additions and 293 deletions

View File

@@ -20,7 +20,6 @@ import { removeFromArray } from '../../libs/api-v3/collectionManipulators';
import * as firebase from '../../libs/api-v3/firebase';
import { sendTxn as sendTxnEmail } from '../../libs/api-v3/email';
import { encrypt } from '../../libs/api-v3/encryption';
import common from '../../../../common';
import sendPushNotification from '../../libs/api-v3/pushNotifications';
let api = {};
@@ -537,11 +536,18 @@ async function _inviteByUUID (uuid, group, inviter, req, res) {
sendTxnEmail(userToInvite, `invited-${groupTemplate}`, emailVars);
}
sendPushNotification(
userToInvite,
common.i18n.t(group.type === 'guild' ? 'invitedGuild' : 'invitedParty'),
group.name
);
if (userToInvite.preferences.pushNotifications[`invited${groupLabel}`] !== false) {
let identifier = group.type === 'guild' ? 'invitedGuild' : 'invitedParty';
sendPushNotification(
userToInvite,
{
title: group.name,
message: res.t(identifier),
identifier,
payload: {groupID: group._id},
}
);
}
let userInvited = await userToInvite.save();
if (group.type === 'guild') {