mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
cancel hook on certain events before calculating data
ensure all required fields are present and cancel when thats not the case
This commit is contained in:
parent
d433d7df9f
commit
a62b7e0d28
@ -53,6 +53,18 @@ 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 +84,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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user