diff --git a/apps/server/package.json b/apps/server/package.json index b5d04309..6db80240 100644 --- a/apps/server/package.json +++ b/apps/server/package.json @@ -48,7 +48,7 @@ "@nestjs/platform-socket.io": "^11.0.10", "@nestjs/terminus": "^11.0.0", "@nestjs/websockets": "^11.0.10", - "@node-saml/passport-saml": "^5.0.0", + "@node-saml/passport-saml": "^5.0.1", "@react-email/components": "0.0.28", "@react-email/render": "1.0.2", "@socket.io/redis-adapter": "^8.3.0", diff --git a/apps/server/src/core/workspace/services/workspace-invitation.service.ts b/apps/server/src/core/workspace/services/workspace-invitation.service.ts index d7cb6bec..9b22a048 100644 --- a/apps/server/src/core/workspace/services/workspace-invitation.service.ts +++ b/apps/server/src/core/workspace/services/workspace-invitation.service.ts @@ -24,6 +24,10 @@ import { nanoIdGen } from '../../../common/helpers'; import { PaginationOptions } from '@docmost/db/pagination/pagination-options'; import { executeWithPagination } from '@docmost/db/pagination/pagination'; import { DomainService } from 'src/integrations/environment/domain.service'; +import { InjectQueue } from '@nestjs/bullmq'; +import { QueueJob, QueueName } from '../../../integrations/queue/constants'; +import { Queue } from 'bullmq'; +import { EnvironmentService } from '../../../integrations/environment/environment.service'; @Injectable() export class WorkspaceInvitationService { @@ -35,6 +39,8 @@ export class WorkspaceInvitationService { private domainService: DomainService, private tokenService: TokenService, @InjectKysely() private readonly db: KyselyDB, + @InjectQueue(QueueName.BILLING_QUEUE) private billingQueue: Queue, + private readonly environmentService: EnvironmentService, ) {} async getInvitations(workspaceId: string, pagination: PaginationOptions) { @@ -266,6 +272,10 @@ export class WorkspaceInvitationService { }); } + if (this.environmentService.isCloud()) { + await this.billingQueue.add(QueueJob.STRIPE_SEATS_SYNC, { workspaceId }); + } + return this.tokenService.generateAccessToken(newUser); } diff --git a/apps/server/src/ee b/apps/server/src/ee index 21c5f129..337854ce 160000 --- a/apps/server/src/ee +++ b/apps/server/src/ee @@ -1 +1 @@ -Subproject commit 21c5f1295a05366c388e9de1f75ed8c68b689c9c +Subproject commit 337854ce96e8c81876794cb964676af7ec2b558d diff --git a/apps/server/src/integrations/queue/constants/queue.constants.ts b/apps/server/src/integrations/queue/constants/queue.constants.ts index 57219b78..596feb78 100644 --- a/apps/server/src/integrations/queue/constants/queue.constants.ts +++ b/apps/server/src/integrations/queue/constants/queue.constants.ts @@ -2,6 +2,7 @@ export enum QueueName { EMAIL_QUEUE = '{email-queue}', ATTACHMENT_QUEUE = '{attachment-queue}', GENERAL_QUEUE = '{general-queue}', + BILLING_QUEUE = '{billing-queue}', } export enum QueueJob { @@ -11,6 +12,6 @@ export enum QueueJob { PAGE_CONTENT_UPDATE = 'page-content-update', PAGE_BACKLINKS = 'page-backlinks', + + STRIPE_SEATS_SYNC = 'sync-stripe-seats', } - - diff --git a/apps/server/src/integrations/queue/constants/queue.interface.ts b/apps/server/src/integrations/queue/constants/queue.interface.ts index d16061b1..ce105f1c 100644 --- a/apps/server/src/integrations/queue/constants/queue.interface.ts +++ b/apps/server/src/integrations/queue/constants/queue.interface.ts @@ -5,4 +5,8 @@ export interface IPageBacklinkJob { pageId: string; workspaceId: string; mentions: MentionNode[]; +} + +export interface IStripeSeatsSyncJob { + workspaceId: string; } \ No newline at end of file diff --git a/apps/server/src/integrations/queue/queue.module.ts b/apps/server/src/integrations/queue/queue.module.ts index aa2ce845..3531a204 100644 --- a/apps/server/src/integrations/queue/queue.module.ts +++ b/apps/server/src/integrations/queue/queue.module.ts @@ -24,13 +24,13 @@ import { BacklinksProcessor } from './processors/backlinks.processor'; attempts: 3, backoff: { type: 'exponential', - delay: 20000, + delay: 20 * 1000, }, removeOnComplete: { - count: 500, + count: 200, }, removeOnFail: { - count: 500, + count: 100, }, }, }; @@ -46,6 +46,9 @@ import { BacklinksProcessor } from './processors/backlinks.processor'; BullModule.registerQueue({ name: QueueName.GENERAL_QUEUE, }), + BullModule.registerQueue({ + name: QueueName.BILLING_QUEUE, + }), ], exports: [BullModule], providers: [BacklinksProcessor],