Merge pull request #1481 from gradido/fix_elopage_hook_crash2

Fix: Elopage Hook Crash 2
This commit is contained in:
Ulf Gebhardt 2022-02-15 15:01:28 +01:00 committed by GitHub
commit bfbe052f4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,6 +53,19 @@ export const elopageWebhook = async (req: any, res: any): Promise<void> => {
membership,
} = req.body
// Do not process certain events
if (['lesson.viewed', 'lesson.completed', 'lesson.commented'].includes(event)) {
// eslint-disable-next-line no-console
console.log('User viewed, completed or commented - not saving hook')
return
}
if (!product || !publisher || !membership || !payer) {
// eslint-disable-next-line no-console
console.log('Elopage Hook: Not an event we can process')
return
}
loginElopageBuy.affiliateProgramId = parseInt(product.affiliate_program_id) || null
loginElopageBuy.publisherId = parseInt(publisher.id) || null
loginElopageBuy.orderId = parseInt(order_id) || null
@ -72,13 +85,6 @@ export const elopageWebhook = async (req: any, res: any): Promise<void> => {
const firstName = payer.first_name
const lastName = payer.last_name
// Do not process certain events
if (['lesson.viewed', 'lesson.completed', 'lesson.commented'].includes(loginElopageBuy.event)) {
// eslint-disable-next-line no-console
console.log('User viewed, completed or commented - not saving hook')
return
}
// Save the hook data
try {
await LoginElopageBuys.save(loginElopageBuy)