3d6653f73b
* Update to new specklepy (#1173) * Publish images for all branches but limit tagging * only tag 'latest' and '2' when 'SHOULD_PUBLISH' variable is 'true' * Publishing helm chart should check for `SHOULD_PUBLISH` * Move blocking step to publish-helm chart, and allow images to be published * Pin python requirements and bump to latest versions * Fix EOL whitespace * use valid version for psycopg2-binary (the clue is in the 2!) * fix(fileimports): add exception printing to file imports * fix(fileimports): bump specklepy version move to a specklepy version that contains a fix for send without writing to disk Co-authored-by: Iain Sproat <68657+iainsproat@users.noreply.github.com> * Fixes liveness and readiness checks to prevent CSRF error message (#1169) - provides content-type header - check that status code is 200 * Fixes broken helm template by adding quotation marks around liveness probe command (#1171) * fix(server activities): make sure the stream events are properly dispatched * feat(server webhooks): add scheduled orphaned webhook cleanup * test(server webhooks): add test to webhook cleanup service * feat(server webhooks): drop foreign key reference for webhooks schema to streams * refactor(server req context): refactor req context to have the ip attribute for all requests * feat(server objects rest api): add ratelimits to objects rest api endpoints * fix(server rest api): properly handle returning 419 Co-authored-by: Iain Sproat <68657+iainsproat@users.noreply.github.com>
28 lines
966 B
TypeScript
28 lines
966 B
TypeScript
import cron from 'node-cron'
|
|
import { SpeckleModule } from '@/modules/shared/helpers/typeHelper'
|
|
import { modulesDebug } from '@/modules/shared/utils/logger'
|
|
import { scheduleExecution } from '@/modules/core/services/taskScheduler'
|
|
import { cleanOrphanedWebhookConfigs } from '@/modules/webhooks/services/cleanup'
|
|
|
|
const webhooksDebug = modulesDebug.extend('activities')
|
|
|
|
const scheduleWebhookCleanup = () => {
|
|
const cronExpression = '0 4 * * 1'
|
|
return scheduleExecution(cronExpression, 'weeklyWebhookCleanup', async () => {
|
|
webhooksDebug('Starting weekly webhooks cleanup')
|
|
await cleanOrphanedWebhookConfigs()
|
|
webhooksDebug('Finished cleanup')
|
|
})
|
|
}
|
|
|
|
let scheduledTask: cron.ScheduledTask | null = null
|
|
|
|
export const init: SpeckleModule['init'] = () => {
|
|
modulesDebug('🎣 Init webhooks module')
|
|
scheduledTask = scheduleWebhookCleanup()
|
|
}
|
|
|
|
export const shutdown: SpeckleModule['shutdown'] = () => {
|
|
if (scheduledTask) scheduledTask.stop()
|
|
}
|