From 308ce923cc4c15fdefebb22b23f4083db1aefa65 Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Mon, 30 Mar 2026 20:51:15 +0100 Subject: [PATCH] clean up --- .../server/src/collaboration/processors/history.processor.ts | 3 +-- apps/server/src/core/notification/notification.processor.ts | 3 +-- .../notification/services/page-update-email-rate-limiter.ts | 5 ++--- .../src/core/notification/services/page.notification.ts | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/apps/server/src/collaboration/processors/history.processor.ts b/apps/server/src/collaboration/processors/history.processor.ts index c2153b65..daec4eaf 100644 --- a/apps/server/src/collaboration/processors/history.processor.ts +++ b/apps/server/src/collaboration/processors/history.processor.ts @@ -12,7 +12,6 @@ import { PageRepo } from '@docmost/db/repos/page/page.repo'; import { isDeepStrictEqual } from 'node:util'; import { CollabHistoryService } from '../services/collab-history.service'; import { WatcherService } from '../../core/watcher/watcher.service'; -import { NotificationType } from '../../core/notification/notification.constants'; @Processor(QueueName.HISTORY_QUEUE) export class HistoryProcessor extends WorkerHost implements OnModuleDestroy { @@ -72,7 +71,7 @@ export class HistoryProcessor extends WorkerHost implements OnModuleDestroy { if (contributorIds.length > 0 && lastHistory?.content) { await this.notificationQueue - .add(NotificationType.PAGE_UPDATED, { + .add(QueueJob.PAGE_UPDATED, { pageId, spaceId: page.spaceId, workspaceId: page.workspaceId, diff --git a/apps/server/src/core/notification/notification.processor.ts b/apps/server/src/core/notification/notification.processor.ts index f24503a1..e3d3a883 100644 --- a/apps/server/src/core/notification/notification.processor.ts +++ b/apps/server/src/core/notification/notification.processor.ts @@ -14,7 +14,6 @@ import { import { CommentNotificationService } from './services/comment.notification'; import { PageNotificationService } from './services/page.notification'; import { DomainService } from '../../integrations/environment/domain.service'; -import { NotificationType } from './notification.constants'; @Processor(QueueName.NOTIFICATION_QUEUE) export class NotificationProcessor @@ -79,7 +78,7 @@ export class NotificationProcessor break; } - case NotificationType.PAGE_UPDATED: { + case QueueJob.PAGE_UPDATED: { await this.pageNotificationService.processPageUpdate( job.data as IPageUpdateNotificationJob, appUrl, diff --git a/apps/server/src/core/notification/services/page-update-email-rate-limiter.ts b/apps/server/src/core/notification/services/page-update-email-rate-limiter.ts index f91c54d6..8989b1d3 100644 --- a/apps/server/src/core/notification/services/page-update-email-rate-limiter.ts +++ b/apps/server/src/core/notification/services/page-update-email-rate-limiter.ts @@ -24,10 +24,9 @@ export class PageUpdateEmailRateLimiter { async addToDigest(userId: string, notificationId: string): Promise { const key = DIGEST_PREFIX + userId; - const isNew = (await this.redis.llen(key)) === 0; - await this.redis.rpush(key, notificationId); + const len = await this.redis.rpush(key, notificationId); await this.redis.expire(key, TTL_SECONDS); - return isNew; + return len === 1; } async popDigest(userId: string): Promise { diff --git a/apps/server/src/core/notification/services/page.notification.ts b/apps/server/src/core/notification/services/page.notification.ts index bf4b631e..40b817cb 100644 --- a/apps/server/src/core/notification/services/page.notification.ts +++ b/apps/server/src/core/notification/services/page.notification.ts @@ -392,7 +392,7 @@ export class PageNotificationService { await this.notificationService.queueEmail( userId, notificationIds[0], - `Your digest: ${pageUpdates.length} page updates`, + `Your digest: ${pageUpdates.length} page ${pageUpdates.length === 1 ? 'update' : 'updates'}`, PageUpdateDigestEmail({ userName: user.name, pageUpdates,