fix(webhook): fix webhook logger crash and webhook logs mapping in admin dashboard
Build and Deploy (Gitea) / build-and-deploy (push) Successful in 1m15s
Details
Build and Deploy (Gitea) / build-and-deploy (push) Successful in 1m15s
Details
This commit is contained in:
parent
9a51bc3dd0
commit
2288eb2784
16
server.ts
16
server.ts
|
|
@ -902,11 +902,9 @@ app.get('/api/admin/dashboard', authenticateToken, requireAdmin, async (req: Aut
|
||||||
recentPayments: recentPaymentsFormatted,
|
recentPayments: recentPaymentsFormatted,
|
||||||
webhookLogs: webhookLogs.map(w => ({
|
webhookLogs: webhookLogs.map(w => ({
|
||||||
id: w.id,
|
id: w.id,
|
||||||
event: w.type,
|
event: w.event,
|
||||||
paymentId: '',
|
payload: w.payload,
|
||||||
customer: w.userId,
|
receivedAt: w.receivedAt
|
||||||
receivedAt: w.createdAt,
|
|
||||||
status: w.read ? 'READ' : 'UNREAD'
|
|
||||||
}))
|
}))
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -1375,12 +1373,10 @@ app.post('/api/webhooks/asaas', async (req: Request, res: Response) => {
|
||||||
const { event, payment } = req.body;
|
const { event, payment } = req.body;
|
||||||
|
|
||||||
if (event) {
|
if (event) {
|
||||||
await prisma.notification.create({
|
await prisma.webhookLog.create({
|
||||||
data: {
|
data: {
|
||||||
userId: 'ALL', // Log events to ALL as webhookLogs
|
event: event,
|
||||||
type: event,
|
payload: JSON.stringify(req.body)
|
||||||
message: JSON.stringify(req.body),
|
|
||||||
read: false
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue