port push notifications in api v3

This commit is contained in:
Matteo Pagliazzi
2016-02-19 20:34:55 +01:00
parent 624c0da5ab
commit fb343f8feb
10 changed files with 34 additions and 13 deletions
+8 -1
View File
@@ -21,7 +21,8 @@ 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 { sendNotification as sendPushNotification } from '../../libs/api-v3/pushNotifications';
let api = {};
// TODO shall we accept party as groupId in all routes?
@@ -510,6 +511,12 @@ async function _inviteByUUID (uuid, group, inviter, req, res) {
sendTxnEmail(userToInvite, `invited-${groupLabel}`, emailVars);
}
sendPushNotification(
userToInvite,
common.i18n.t(group.type === 'guild' ? 'invitedGuild' : 'invitedParty'),
group.name
);
let userInvited = await userToInvite.save();
if (group.type === 'guild') {
return userInvited.invitations.guilds[userToInvite.invitations.guilds.length - 1];