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
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { db } from '@/db/knex'
|
|
import { moduleLogger } from '@/observability/logging'
|
|
import { initializeEventListenerFactory } from '@/modules/accessrequests/services/eventListener'
|
|
import { getStreamCollaboratorsFactory } from '@/modules/core/repositories/streams'
|
|
import { publishNotification } from '@/modules/notifications/services/publication/publishNotification'
|
|
import type { Optional, SpeckleModule } from '@/modules/shared/helpers/typeHelper'
|
|
import { getEventBus } from '@/modules/shared/services/eventBus'
|
|
|
|
let quitListeners: Optional<() => void> = undefined
|
|
|
|
const ServerAccessRequestsModule: SpeckleModule = {
|
|
init({ isInitial }) {
|
|
moduleLogger.info('🔐 Init access request module')
|
|
|
|
if (isInitial) {
|
|
const initializeEventListener = initializeEventListenerFactory({
|
|
getStreamCollaborators: getStreamCollaboratorsFactory({ db }),
|
|
publishNotification,
|
|
eventBus: getEventBus()
|
|
})
|
|
quitListeners = initializeEventListener()
|
|
}
|
|
},
|
|
shutdown() {
|
|
quitListeners?.()
|
|
}
|
|
}
|
|
|
|
export default ServerAccessRequestsModule
|