fix: webhook failed since not working as intended (#550)

* fix: webhook failed since not working as intended

* fix: match to milliseconds
This commit is contained in:
SKINMAKER 2023-04-07 22:34:39 +09:00 committed by GitHub
parent 4648c3e84b
commit 72843bfeb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -134,17 +134,17 @@ export const sendWebhook = async (target: Bot | Server, payload: WebhookPayload)
} }
} }
if(Date.now() - webhook.failedSince > 1000 * 60 * 60 * 24) { if(!webhook.failedSince) {
await update.webhook(id, isBot ? 'bots' : 'servers', {
failedSince: Math.floor(Date.now() / 1000)
})
} else if(Date.now() - webhook.failedSince * 1000 > 1000 * 60 * 60 * 24) {
await update.webhook(id, isBot ? 'bots' : 'servers', { await update.webhook(id, isBot ? 'bots' : 'servers', {
status: WebhookStatus.Disabled, status: WebhookStatus.Disabled,
failedSince: null, failedSince: null,
secret: null secret: null
}) })
sendFailedMessage(target) sendFailedMessage(target)
} else if(!webhook.failedSince) {
await update.webhook(id, isBot ? 'bots' : 'servers', {
failedSince: Date.now()
})
} }
return false return false
} }