Send questInvited webhook to the inviter too (#13111)

This commit is contained in:
Carl Vuorinen
2021-04-29 22:34:17 +03:00
committed by GitHub
parent fea39e7c9b
commit 1d3cf368a1
2 changed files with 31 additions and 0 deletions

View File

@@ -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);
});
});
});
});

View File

@@ -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',