remove session party invitation. Implement the same feature using a query string when signing up

This commit is contained in:
Matteo Pagliazzi
2016-02-26 19:18:18 +01:00
parent bb461f0c5a
commit d2ba8e223c
3 changed files with 49 additions and 26 deletions
+7 -9
View File
@@ -459,7 +459,6 @@ api.removeGroupMember = {
};
async function _inviteByUUID (uuid, group, inviter, req, res) {
// TODO: Add Push Notifications
let userToInvite = await User.findById(uuid).exec();
if (!userToInvite) {
@@ -493,7 +492,6 @@ async function _inviteByUUID (uuid, group, inviter, req, res) {
if (userToInvite.preferences.emailNotifications[`invited${groupLabel}`] !== false) {
let emailVars = [
{name: 'INVITER', content: inviter.profile.name},
{name: 'REPLY_TO_ADDRESS', content: inviter.email},
];
if (group.type === 'guild') {
@@ -541,16 +539,16 @@ async function _inviteByEmail (invite, group, inviter, req, res) {
userReturnInfo = await _inviteByUUID(userToContact._id, group, inviter, req, res);
} else {
userReturnInfo = invite.email;
// yeah, it supports guild too but for backward compatibility we'll use partyInvite as query
// TODO absolutely refactor this horrible code
const partyQueryString = JSON.stringify({id: group._id, inviter, name: group.name});
const encryptedPartyqueryString = encrypt(partyQueryString);
let link = `?partyInvite=${encryptedPartyqueryString}`;
const groupQueryString = JSON.stringify({
id: group._id,
inviter: inviter._id,
sentAt: Date.now(), // so we can let it expire
});
let link = `?groupInvite=${encrypt(groupQueryString)}`;
let variables = [
{name: 'LINK', content: link},
{name: 'INVITER', content: inviter || inviter.profile.name},
{name: 'REPLY_TO_ADDRESS', content: inviter.email},
{name: 'INVITER', content: inviter.profile.name},
];
if (group.type === 'guild') {