From 5ba33bc5a1fd30ebdc794b60a57b79f56f3515b7 Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Thu, 19 May 2016 22:43:11 +0200 Subject: [PATCH] v3: iap accessible under /api/v3, fixes to spells and groups invitations --- website/server/controllers/api-v3/groups.js | 3 ++- website/server/controllers/api-v3/iap.js | 4 ++++ website/server/controllers/api-v3/user.js | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 website/server/controllers/api-v3/iap.js diff --git a/website/server/controllers/api-v3/groups.js b/website/server/controllers/api-v3/groups.js index 196e3721d8..07e9b5be54 100644 --- a/website/server/controllers/api-v3/groups.js +++ b/website/server/controllers/api-v3/groups.js @@ -513,6 +513,7 @@ async function _inviteByUUID (uuid, group, inviter, req, res) { } let groupLabel = group.type === 'guild' ? 'Guild' : 'Party'; + let groupTemplate = group.type === 'guild' ? 'guild' : 'party'; if (userToInvite.preferences.emailNotifications[`invited${groupLabel}`] !== false) { let emailVars = [ {name: 'INVITER', content: inviter.profile.name}, @@ -530,7 +531,7 @@ async function _inviteByUUID (uuid, group, inviter, req, res) { ); } - sendTxnEmail(userToInvite, `invited-${groupLabel}`, emailVars); + sendTxnEmail(userToInvite, `invited-${groupTemplate}`, emailVars); } sendPushNotification( diff --git a/website/server/controllers/api-v3/iap.js b/website/server/controllers/api-v3/iap.js new file mode 100644 index 0000000000..daaef0cef8 --- /dev/null +++ b/website/server/controllers/api-v3/iap.js @@ -0,0 +1,4 @@ +// NOTE: this file is only used because the mobile apps expect IAP routes +// to be found at /api/v3/iap instead of /iap. + +module.exports = require('../top-level/payments/iap'); \ No newline at end of file diff --git a/website/server/controllers/api-v3/user.js b/website/server/controllers/api-v3/user.js index 3e6bd8b8da..058e5297c3 100644 --- a/website/server/controllers/api-v3/user.js +++ b/website/server/controllers/api-v3/user.js @@ -378,7 +378,10 @@ api.castSpell = { spell.cast(user, tasks, req); - let toSave = tasks.filter(t => t.isModified()); + let toSave = tasks + .filter(t => t.isModified()) + .map(t => t.save()); + toSave.unshift(user.save()); let saved = await Bluebird.all(toSave);