From 1d3cf368a186b09f9923e9f77a9e0275af3b0ec8 Mon Sep 17 00:00:00 2001 From: Carl Vuorinen Date: Thu, 29 Apr 2021 22:34:17 +0300 Subject: [PATCH] Send questInvited webhook to the inviter too (#13111) --- .../POST-groups_groupId_quests_invite.test.js | 24 +++++++++++++++++++ website/server/controllers/api-v3/quests.js | 7 ++++++ 2 files changed, 31 insertions(+) diff --git a/test/api/v3/integration/quests/POST-groups_groupId_quests_invite.test.js b/test/api/v3/integration/quests/POST-groups_groupId_quests_invite.test.js index 170f9a4c21..dd6256661a 100644 --- a/test/api/v3/integration/quests/POST-groups_groupId_quests_invite.test.js +++ b/test/api/v3/integration/quests/POST-groups_groupId_quests_invite.test.js @@ -240,6 +240,30 @@ describe('POST /groups/:groupId/quests/invite/:questKey', () => { expect(body.group.name).to.eql(questingGroup.name); expect(body.quest.key).to.eql(PET_QUEST); }); + + it('sends quest invited webhook to the inviter too', async () => { + const uuid = generateUUID(); + + await leader.post('/user/webhook', { + url: `http://localhost:${server.port}/webhooks/${uuid}`, + type: 'questActivity', + enabled: true, + options: { + questInvited: true, + }, + }); + + await leader.post(`/groups/${questingGroup._id}/quests/invite/${PET_QUEST}`); + + await sleep(); + + const body = server.getWebhookData(uuid); + + expect(body.type).to.eql('questInvited'); + expect(body.group.id).to.eql(questingGroup.id); + expect(body.group.name).to.eql(questingGroup.name); + expect(body.quest.key).to.eql(PET_QUEST); + }); }); }); }); diff --git a/website/server/controllers/api-v3/quests.js b/website/server/controllers/api-v3/quests.js index bcf62a0969..9e7bc1d09f 100644 --- a/website/server/controllers/api-v3/quests.js +++ b/website/server/controllers/api-v3/quests.js @@ -149,6 +149,13 @@ api.inviteToQuest = { { name: 'PARTY_URL', content: '/party' }, ]); + // Send webhook to the inviter too + questActivityWebhook.send(user, { + type: 'questInvited', + group, + quest, + }); + // track that the inviting user has accepted the quest analytics.track('quest', { category: 'behavior',