3ca4a11ca3
* feat: basic notification listener sturcuture * feat: clean up generated gql * chore: edited structure * feat: added basic repo * feat: ported comment email to job queue * feat: ported stream access request accepted * feat: added notification insertion * fix: minor typings * feat: delayed notifications * updated types * feat: fixed gql * notifications are listed * index on notifications * feat: while loop skiping for update locked * delayed notification for access request * take into account user prefrences * on comment view, notification is marked as read * feat: added gql notifications * feat: avoid raising errors * fix: error added scopes * fix: mr comments * fix: cursor and service method * feat: added stronger types to notifications and versioning logic * minor: rows updated
35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
import type { CommandModule } from 'yargs'
|
|
import { initializePublicationQueue } from '@/modules/notifications/services/publication/queue'
|
|
import { publishNotification } from '@/modules/notifications/services/publication/publishNotification'
|
|
import { cliLogger } from '@/observability/logging'
|
|
import { sendActivityNotificationsFactory } from '@/modules/activitystream/services/summary'
|
|
import { getActiveUserStreamsFactory } from '@/modules/activitystream/repositories'
|
|
import { db } from '@/db/knex'
|
|
|
|
const command: CommandModule = {
|
|
command: 'send [days]',
|
|
describe:
|
|
'Send activity summary notifications for the past days specified in the argument.',
|
|
builder(yargs) {
|
|
return yargs.positional('days', {
|
|
describe: 'Number of days to look for activities',
|
|
type: 'number',
|
|
default: 7
|
|
})
|
|
},
|
|
handler: async (argv) => {
|
|
await initializePublicationQueue()
|
|
const numberOfDays = argv.days as number
|
|
const end = new Date()
|
|
const start = new Date(end.getTime())
|
|
start.setDate(start.getDate() - numberOfDays)
|
|
await sendActivityNotificationsFactory({
|
|
publishNotification,
|
|
getActiveUserStreams: getActiveUserStreamsFactory({ db })
|
|
})(start, end)
|
|
cliLogger.info('Sent activity notifications')
|
|
}
|
|
}
|
|
|
|
export = command
|