Files
speckle-server/packages/server/modules/cli/commands/bull/test-push.ts
T
Gergő Jedlicska 2fdcf1bd1d refactor(shared): unified queue handling (#4691)
* feat(shared): unified queue initialization in shared

* feat(queues): use the new queue creation everywhere

* chore(shared): move to redis module

* chore(shared): fix export maps

* chore(fileimport): add deps properly

* fix(shared): import fix

* fix(everything): moear imports

* fix(server): cjs imports
2025-05-08 16:58:43 +02:00

44 lines
1.3 KiB
TypeScript

import { cliLogger } from '@/observability/logging'
import {
MentionedInCommentData,
NotificationType
} from '@/modules/notifications/helpers/types'
import { publishNotification } from '@/modules/notifications/services/publication'
import { initializeQueue } from '@/modules/notifications/services/queue'
import { CommandModule } from 'yargs'
const command: CommandModule = {
command: 'test-push [message] [error]',
describe: 'Push a fake notification onto the queue',
builder(yargs) {
return yargs
.positional('message', {
describe: 'Random message to push',
type: 'string',
default: 'Hello world!'
})
.positional('error', {
describe: 'Whether to throw error in handler, causing a re-queue',
type: 'boolean',
default: false
})
},
handler: async (argv) => {
await initializeQueue()
// we don't want to submit a real mentions payload, this is for testing only
await publishNotification(NotificationType.MentionedInComment, {
targetUserId: '123',
data: {
text: argv.message,
timestamp: new Date().toISOString(),
error: argv.error
} as unknown as MentionedInCommentData
})
cliLogger.info('Queued a fake notification...')
}
}
export = command