This commit is contained in:
Philipinho
2026-03-31 01:23:14 +01:00
parent d034fce11b
commit bd42dec6be
5 changed files with 30 additions and 16 deletions
@@ -12,7 +12,17 @@ export type NotificationType =
export type NotificationSettingKey =
| 'page.updated'
| 'page.user_mention'
| 'comment.user_mention'
| 'page.userMention'
| 'comment.userMention'
| 'comment.created'
| 'comment.resolved';
export const NotificationTypeToSettingKey: Partial<
Record<NotificationType, NotificationSettingKey>
> = {
[NotificationType.PAGE_UPDATED]: 'page.updated',
[NotificationType.PAGE_USER_MENTION]: 'page.userMention',
[NotificationType.COMMENT_USER_MENTION]: 'comment.userMention',
[NotificationType.COMMENT_CREATED]: 'comment.created',
[NotificationType.COMMENT_RESOLVED]: 'comment.resolved',
};
@@ -6,7 +6,7 @@ import { InsertableNotification } from '@docmost/db/types/entity.types';
import { PaginationOptions } from '@docmost/db/pagination/pagination-options';
import { WsGateway } from '../../ws/ws.gateway';
import { MailService } from '../../integrations/mail/mail.service';
import { NotificationType } from './notification.constants';
import { NotificationType, NotificationTypeToSettingKey } from './notification.constants';
@Injectable()
export class NotificationService {
@@ -78,8 +78,11 @@ export class NotificationService {
if (!user?.email) return;
if (type) {
const settings = user.settings as any;
if (settings?.notifications?.[type] === false) return;
const settingKey = NotificationTypeToSettingKey[type];
if (settingKey) {
const settings = user.settings as any;
if (settings?.notifications?.[settingKey] === false) return;
}
}
await this.mailService.sendToQueue({
+2 -2
View File
@@ -63,8 +63,8 @@ export class UserService {
const notificationSettings: Record<string, NotificationSettingKey> = {
notificationPageUpdates: 'page.updated',
notificationPageUserMention: 'page.user_mention',
notificationCommentUserMention: 'comment.user_mention',
notificationPageUserMention: 'page.userMention',
notificationCommentUserMention: 'comment.userMention',
notificationCommentCreated: 'comment.created',
notificationCommentResolved: 'comment.resolved',
};