mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
fix keys
This commit is contained in:
@@ -2,7 +2,7 @@ import { userAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||
import { updateUser } from "@/features/user/services/user-service.ts";
|
||||
import { IUser, IUserSettings } from "@/features/user/types/user.types.ts";
|
||||
import { Switch, Text, Title, Stack } from "@mantine/core";
|
||||
import { useAtom } from "jotai/index";
|
||||
import { useAtom } from "jotai";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
@@ -26,13 +26,13 @@ const notificationItems: {
|
||||
description: "Get notified when pages you watch are updated.",
|
||||
},
|
||||
{
|
||||
key: "page.user_mention",
|
||||
key: "page.userMention",
|
||||
dtoField: "notificationPageUserMention",
|
||||
label: "Page mentions",
|
||||
description: "Get notified when someone mentions you on a page.",
|
||||
},
|
||||
{
|
||||
key: "comment.user_mention",
|
||||
key: "comment.userMention",
|
||||
dtoField: "notificationCommentUserMention",
|
||||
label: "Comment mentions",
|
||||
description: "Get notified when someone mentions you in a comment.",
|
||||
@@ -41,7 +41,8 @@ const notificationItems: {
|
||||
key: "comment.created",
|
||||
dtoField: "notificationCommentCreated",
|
||||
label: "New comments",
|
||||
description: "Get notified about new comments on threads you participate in.",
|
||||
description:
|
||||
"Get notified about new comments on threads you participate in.",
|
||||
},
|
||||
{
|
||||
key: "comment.resolved",
|
||||
|
||||
@@ -39,11 +39,11 @@ export interface IUserSettings {
|
||||
pageEditMode: string;
|
||||
};
|
||||
notifications?: {
|
||||
'page.updated'?: boolean;
|
||||
'page.user_mention'?: boolean;
|
||||
'comment.user_mention'?: boolean;
|
||||
'comment.created'?: boolean;
|
||||
'comment.resolved'?: boolean;
|
||||
"page.updated"?: boolean;
|
||||
"page.userMention"?: boolean;
|
||||
"comment.userMention"?: boolean;
|
||||
"comment.created"?: boolean;
|
||||
"comment.resolved"?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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 settingKey = NotificationTypeToSettingKey[type];
|
||||
if (settingKey) {
|
||||
const settings = user.settings as any;
|
||||
if (settings?.notifications?.[type] === false) return;
|
||||
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