mirror of
https://github.com/docmost/docmost.git
synced 2026-05-08 23:33:09 +08:00
fix keys
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -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',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user