mirror of
https://github.com/docmost/docmost.git
synced 2026-05-09 07:43:06 +08:00
Compare commits
8 Commits
mrl
..
editor-972
| Author | SHA1 | Date | |
|---|---|---|---|
| 2fe2c0e6c1 | |||
| 388572f689 | |||
| a8335475fd | |||
| 6a90b318e5 | |||
| 8b4cc82e5a | |||
| cda7cc9a57 | |||
| 59c5f25502 | |||
| b9d58081b8 |
@@ -25,7 +25,7 @@
|
|||||||
"@tabler/icons-react": "^3.40.0",
|
"@tabler/icons-react": "^3.40.0",
|
||||||
"@tanstack/react-query": "5.90.17",
|
"@tanstack/react-query": "5.90.17",
|
||||||
"alfaaz": "^1.1.0",
|
"alfaaz": "^1.1.0",
|
||||||
"axios": "1.13.6",
|
"axios": "^1.13.6",
|
||||||
"blueimp-load-image": "^5.16.0",
|
"blueimp-load-image": "^5.16.0",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"emoji-mart": "^5.6.0",
|
"emoji-mart": "^5.6.0",
|
||||||
|
|||||||
@@ -674,24 +674,6 @@
|
|||||||
"<bold>{{name}}</bold> mentioned you on a page": "<bold>{{name}}</bold> mentioned you on a page.",
|
"<bold>{{name}}</bold> mentioned you on a page": "<bold>{{name}}</bold> mentioned you on a page.",
|
||||||
"<bold>{{name}}</bold> gave you edit access to a page": "<bold>{{name}}</bold> gave you edit access to a page.",
|
"<bold>{{name}}</bold> gave you edit access to a page": "<bold>{{name}}</bold> gave you edit access to a page.",
|
||||||
"<bold>{{name}}</bold> gave you view access to a page": "<bold>{{name}}</bold> gave you view access to a page.",
|
"<bold>{{name}}</bold> gave you view access to a page": "<bold>{{name}}</bold> gave you view access to a page.",
|
||||||
"<bold>{{name}}</bold> updated a page": "<bold>{{name}}</bold> updated a page.",
|
|
||||||
"Watch page": "Watch page",
|
|
||||||
"Stop watching": "Stop watching",
|
|
||||||
"Email notifications": "Email notifications",
|
|
||||||
"Page updates": "Page updates",
|
|
||||||
"Get notified when pages you watch are updated.": "Get notified when pages you watch are updated.",
|
|
||||||
"Page mentions": "Page mentions",
|
|
||||||
"Get notified when someone mentions you on a page.": "Get notified when someone mentions you on a page.",
|
|
||||||
"Comment mentions": "Comment mentions",
|
|
||||||
"Get notified when someone mentions you in a comment.": "Get notified when someone mentions you in a comment.",
|
|
||||||
"New comments": "New comments",
|
|
||||||
"Get notified about new comments on threads you participate in.": "Get notified about new comments on threads you participate in.",
|
|
||||||
"Resolved comments": "Resolved comments",
|
|
||||||
"Get notified when your comment is resolved.": "Get notified when your comment is resolved.",
|
|
||||||
"You are now watching this page": "You are now watching this page",
|
|
||||||
"You are no longer watching this page": "You are no longer watching this page",
|
|
||||||
"Direct": "Direct",
|
|
||||||
"Updates": "Updates",
|
|
||||||
"Today": "Today",
|
"Today": "Today",
|
||||||
"Yesterday": "Yesterday",
|
"Yesterday": "Yesterday",
|
||||||
"This week": "This week",
|
"This week": "This week",
|
||||||
@@ -751,5 +733,7 @@
|
|||||||
"Publish": "Publish.",
|
"Publish": "Publish.",
|
||||||
"Security": "Security.",
|
"Security": "Security.",
|
||||||
"Enforce SSO": "Enforce SSO.",
|
"Enforce SSO": "Enforce SSO.",
|
||||||
"Once enforced, members will not be able to login with email and password.": "Once enforced, members will not be able to log in with email and password."
|
"Once enforced, members will not be able to login with email and password.": "Once enforced, members will not be able to log in with email and password.",
|
||||||
|
"Uploading {{name}}": "Uploading {{name}}",
|
||||||
|
"Uploading file": "Uploading file"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ function CommentMenu({
|
|||||||
{isResolved ? t("Re-open comment") : t("Resolve comment")}
|
{isResolved ? t("Re-open comment") : t("Resolve comment")}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
) : (
|
) : (
|
||||||
<Tooltip label={upgradeLabel} position="left" withinPortal={false}>
|
<Tooltip label={upgradeLabel} position="left" withPortal={false}>
|
||||||
<Menu.Item disabled leftSection={<IconCircleCheck size={14} />}>
|
<Menu.Item disabled leftSection={<IconCircleCheck size={14} />}>
|
||||||
{t("Resolve comment")}
|
{t("Resolve comment")}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { useCallback } from "react";
|
|||||||
export default function AttachmentView(props: NodeViewProps) {
|
export default function AttachmentView(props: NodeViewProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { editor, node, getPos, selected } = props;
|
const { editor, node, getPos, selected } = props;
|
||||||
const { url, name, size, mime, attachmentId, placeholder } = node.attrs;
|
const { url, name, size, mime, attachmentId } = node.attrs;
|
||||||
const { hovered, ref } = useHover();
|
const { hovered, ref } = useHover();
|
||||||
|
|
||||||
const isPdf = mime === "application/pdf" || name?.toLowerCase().endsWith(".pdf");
|
const isPdf = mime === "application/pdf" || name?.toLowerCase().endsWith(".pdf");
|
||||||
@@ -49,14 +49,14 @@ export default function AttachmentView(props: NodeViewProps) {
|
|||||||
h={25}
|
h={25}
|
||||||
>
|
>
|
||||||
<Group wrap="nowrap" gap="sm" style={{ minWidth: 0, flex: 1 }}>
|
<Group wrap="nowrap" gap="sm" style={{ minWidth: 0, flex: 1 }}>
|
||||||
{!url && placeholder ? (
|
{url ? (
|
||||||
<Loader size={20} style={{ flexShrink: 0 }} />
|
|
||||||
) : (
|
|
||||||
<IconPaperclip size={20} style={{ flexShrink: 0 }} />
|
<IconPaperclip size={20} style={{ flexShrink: 0 }} />
|
||||||
|
) : (
|
||||||
|
<Loader size={20} style={{ flexShrink: 0 }} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Text component="span" size="md" truncate="end" style={{ minWidth: 0 }}>
|
<Text component="span" size="md" truncate="end" style={{ minWidth: 0 }}>
|
||||||
{!url && placeholder ? t("Uploading {{name}}", { name }) : name}
|
{url ? name : t("Uploading {{name}}", { name })}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<Text component="span" size="sm" c="dimmed" style={{ flexShrink: 0 }}>
|
<Text component="span" size="sm" c="dimmed" style={{ flexShrink: 0 }}>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export default function AudioView(props: NodeViewProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<NodeViewWrapper data-drag-handle>
|
<NodeViewWrapper data-drag-handle>
|
||||||
<div className={`${classes.audioWrapper} ${!safeSrc && placeholder ? classes.skeleton : ''}`}>
|
<div className={`${classes.audioWrapper} ${!safeSrc ? classes.skeleton : ''}`}>
|
||||||
{safeSrc && (
|
{safeSrc && (
|
||||||
<audio
|
<audio
|
||||||
className={classes.audio}
|
className={classes.audio}
|
||||||
@@ -49,7 +49,7 @@ export default function AudioView(props: NodeViewProps) {
|
|||||||
<Loader size={20} pos="absolute" top={6} right={6} />
|
<Loader size={20} pos="absolute" top={6} right={6} />
|
||||||
</Group>
|
</Group>
|
||||||
)}
|
)}
|
||||||
{!safeSrc && !previewSrc && placeholder && (
|
{!safeSrc && !previewSrc && (
|
||||||
<Group justify="center" wrap="nowrap" gap="xs" maw="100%" px="md" h={54}>
|
<Group justify="center" wrap="nowrap" gap="xs" maw="100%" px="md" h={54}>
|
||||||
<Loader size={20} style={{ flexShrink: 0 }} />
|
<Loader size={20} style={{ flexShrink: 0 }} />
|
||||||
<Text component="span" size="sm" truncate="end">
|
<Text component="span" size="sm" truncate="end">
|
||||||
@@ -59,9 +59,6 @@ export default function AudioView(props: NodeViewProps) {
|
|||||||
</Text>
|
</Text>
|
||||||
</Group>
|
</Group>
|
||||||
)}
|
)}
|
||||||
{!safeSrc && !previewSrc && !placeholder && (
|
|
||||||
<audio className={classes.audio} controls />
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</NodeViewWrapper>
|
</NodeViewWrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export default function ImageView(props: NodeViewProps) {
|
|||||||
className={clsx(
|
className={clsx(
|
||||||
selected && "ProseMirror-selectednode",
|
selected && "ProseMirror-selectednode",
|
||||||
classes.imageWrapper,
|
classes.imageWrapper,
|
||||||
!src && placeholder && classes.skeleton,
|
!src && classes.skeleton,
|
||||||
alignClass,
|
alignClass,
|
||||||
)}
|
)}
|
||||||
style={{
|
style={{
|
||||||
@@ -55,7 +55,7 @@ export default function ImageView(props: NodeViewProps) {
|
|||||||
<Loader size={20} pos="absolute" bottom={6} right={6} />
|
<Loader size={20} pos="absolute" bottom={6} right={6} />
|
||||||
</Group>
|
</Group>
|
||||||
)}
|
)}
|
||||||
{!src && !previewSrc && placeholder && (
|
{!src && !previewSrc && (
|
||||||
<Group justify="center" wrap="nowrap" gap="xs" maw="100%" px="md">
|
<Group justify="center" wrap="nowrap" gap="xs" maw="100%" px="md">
|
||||||
<Loader size={20} style={{ flexShrink: 0 }} />
|
<Loader size={20} style={{ flexShrink: 0 }} />
|
||||||
<Text component="span" size="sm" truncate="end">
|
<Text component="span" size="sm" truncate="end">
|
||||||
|
|||||||
@@ -294,7 +294,6 @@ const MentionList = forwardRef<any, MentionListProps>((props, ref) => {
|
|||||||
w={popupWidth}
|
w={popupWidth}
|
||||||
scrollbars={"y"}
|
scrollbars={"y"}
|
||||||
scrollbarSize={6}
|
scrollbarSize={6}
|
||||||
overscrollBehavior={"contain"}
|
|
||||||
styles={{ content: { minWidth: 0 } }}
|
styles={{ content: { minWidth: 0 } }}
|
||||||
>
|
>
|
||||||
{renderItems?.map((item, index) => {
|
{renderItems?.map((item, index) => {
|
||||||
|
|||||||
@@ -73,17 +73,15 @@ export default function PdfView(props: NodeViewProps) {
|
|||||||
if (!src || !safeSrc) {
|
if (!src || !safeSrc) {
|
||||||
return (
|
return (
|
||||||
<NodeViewWrapper data-drag-handle>
|
<NodeViewWrapper data-drag-handle>
|
||||||
<div className={`${classes.pdfWrapper} ${placeholder ? classes.skeleton : ''}`} style={{ height: placeholder ? 600 : undefined }}>
|
<div className={`${classes.pdfWrapper} ${classes.skeleton}`} style={{ height: 600 }}>
|
||||||
{placeholder && (
|
<Group justify="center" wrap="nowrap" gap="xs" maw="100%" px="md">
|
||||||
<Group justify="center" wrap="nowrap" gap="xs" maw="100%" px="md">
|
<Loader size={20} style={{ flexShrink: 0 }} />
|
||||||
<Loader size={20} style={{ flexShrink: 0 }} />
|
<Text component="span" size="sm" truncate="end">
|
||||||
<Text component="span" size="sm" truncate="end">
|
{placeholder?.name
|
||||||
{placeholder?.name
|
? t("Uploading {{name}}", { name: placeholder.name })
|
||||||
? t("Uploading {{name}}", { name: placeholder.name })
|
: t("Uploading file")}
|
||||||
: t("Uploading file")}
|
</Text>
|
||||||
</Text>
|
</Group>
|
||||||
</Group>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</NodeViewWrapper>
|
</NodeViewWrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -87,13 +87,7 @@ const CommandList = ({
|
|||||||
|
|
||||||
return flatItems.length > 0 ? (
|
return flatItems.length > 0 ? (
|
||||||
<Paper id="slash-command" shadow="md" p="xs" withBorder>
|
<Paper id="slash-command" shadow="md" p="xs" withBorder>
|
||||||
<ScrollArea
|
<ScrollArea viewportRef={viewportRef} h={350} w={270} scrollbarSize={8}>
|
||||||
viewportRef={viewportRef}
|
|
||||||
h={350}
|
|
||||||
w={270}
|
|
||||||
scrollbarSize={8}
|
|
||||||
overscrollBehavior="contain"
|
|
||||||
>
|
|
||||||
{Object.entries(items).map(([category, categoryItems]) => (
|
{Object.entries(items).map(([category, categoryItems]) => (
|
||||||
<div key={category}>
|
<div key={category}>
|
||||||
<Text c="dimmed" mb={4} fw={500} tt="capitalize">
|
<Text c="dimmed" mb={4} fw={500} tt="capitalize">
|
||||||
@@ -109,7 +103,10 @@ const CommandList = ({
|
|||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<Group>
|
<Group>
|
||||||
<ActionIcon variant="default" component="div">
|
<ActionIcon
|
||||||
|
variant="default"
|
||||||
|
component="div"
|
||||||
|
>
|
||||||
<item.icon size={18} />
|
<item.icon size={18} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ const renderItems = () => {
|
|||||||
getReferenceClientRect = props.clientRect;
|
getReferenceClientRect = props.clientRect;
|
||||||
|
|
||||||
popup = document.createElement("div");
|
popup = document.createElement("div");
|
||||||
popup.style.zIndex = "199";
|
popup.style.zIndex = "9999";
|
||||||
popup.style.position = "absolute";
|
popup.style.position = "absolute";
|
||||||
popup.style.top = "0";
|
popup.style.top = "0";
|
||||||
popup.style.left = "0";
|
popup.style.left = "0";
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export default function VideoView(props: NodeViewProps) {
|
|||||||
className={clsx(
|
className={clsx(
|
||||||
selected && "ProseMirror-selectednode",
|
selected && "ProseMirror-selectednode",
|
||||||
classes.videoWrapper,
|
classes.videoWrapper,
|
||||||
!src && placeholder && classes.skeleton,
|
!src && classes.skeleton,
|
||||||
alignClass,
|
alignClass,
|
||||||
)}
|
)}
|
||||||
style={{
|
style={{
|
||||||
@@ -60,7 +60,7 @@ export default function VideoView(props: NodeViewProps) {
|
|||||||
<Loader size={20} pos="absolute" top={6} right={6} />
|
<Loader size={20} pos="absolute" top={6} right={6} />
|
||||||
</Group>
|
</Group>
|
||||||
)}
|
)}
|
||||||
{!src && !previewSrc && placeholder && (
|
{!src && !previewSrc && (
|
||||||
<Group justify="center" wrap="nowrap" gap="xs" maw="100%" px="md">
|
<Group justify="center" wrap="nowrap" gap="xs" maw="100%" px="md">
|
||||||
<Loader size={20} style={{ flexShrink: 0 }} />
|
<Loader size={20} style={{ flexShrink: 0 }} />
|
||||||
<Text component="span" size="sm" truncate="end">
|
<Text component="span" size="sm" truncate="end">
|
||||||
@@ -70,9 +70,6 @@ export default function VideoView(props: NodeViewProps) {
|
|||||||
</Text>
|
</Text>
|
||||||
</Group>
|
</Group>
|
||||||
)}
|
)}
|
||||||
{!src && !previewSrc && !placeholder && (
|
|
||||||
<video className={classes.video} controls />
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</NodeViewWrapper>
|
</NodeViewWrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -253,8 +253,8 @@ export const mainExtensions = [
|
|||||||
resize: {
|
resize: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
directions: ["left", "right"],
|
directions: ["left", "right"],
|
||||||
minWidth: 24,
|
minWidth: 80,
|
||||||
minHeight: 16,
|
minHeight: 40,
|
||||||
alwaysPreserveAspectRatio: true,
|
alwaysPreserveAspectRatio: true,
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
createCustomHandle: createImageHandle,
|
createCustomHandle: createImageHandle,
|
||||||
@@ -266,8 +266,8 @@ export const mainExtensions = [
|
|||||||
resize: {
|
resize: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
directions: ["left", "right"],
|
directions: ["left", "right"],
|
||||||
minWidth: 24,
|
minWidth: 80,
|
||||||
minHeight: 16,
|
minHeight: 40,
|
||||||
alwaysPreserveAspectRatio: true,
|
alwaysPreserveAspectRatio: true,
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
createCustomHandle: createResizeHandle,
|
createCustomHandle: createResizeHandle,
|
||||||
@@ -297,8 +297,8 @@ export const mainExtensions = [
|
|||||||
resize: {
|
resize: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
directions: ["left", "right"],
|
directions: ["left", "right"],
|
||||||
minWidth: 24,
|
minWidth: 80,
|
||||||
minHeight: 16,
|
minHeight: 40,
|
||||||
alwaysPreserveAspectRatio: true,
|
alwaysPreserveAspectRatio: true,
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
createCustomHandle: createResizeHandle,
|
createCustomHandle: createResizeHandle,
|
||||||
@@ -310,8 +310,8 @@ export const mainExtensions = [
|
|||||||
resize: {
|
resize: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
directions: ["left", "right"],
|
directions: ["left", "right"],
|
||||||
minWidth: 24,
|
minWidth: 80,
|
||||||
minHeight: 16,
|
minHeight: 40,
|
||||||
alwaysPreserveAspectRatio: true,
|
alwaysPreserveAspectRatio: true,
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
createCustomHandle: createResizeHandle,
|
createCustomHandle: createResizeHandle,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// adapted from: https://github.com/aguingand/tiptap-markdown/blob/main/src/extensions/tiptap/clipboard.js - MIT
|
// adapted from: https://github.com/aguingand/tiptap-markdown/blob/main/src/extensions/tiptap/clipboard.js - MIT
|
||||||
import { Extension } from "@tiptap/core";
|
import { Extension } from "@tiptap/core";
|
||||||
import { Plugin, PluginKey, TextSelection } from "@tiptap/pm/state";
|
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
||||||
import { DOMParser, DOMSerializer, Fragment, Slice } from "@tiptap/pm/model";
|
import { DOMParser, DOMSerializer, Fragment, Slice } from "@tiptap/pm/model";
|
||||||
import { find } from "linkifyjs";
|
import { find } from "linkifyjs";
|
||||||
import { markdownToHtml, htmlToMarkdown } from "@docmost/editor-ext";
|
import { markdownToHtml, htmlToMarkdown } from "@docmost/editor-ext";
|
||||||
@@ -50,46 +50,26 @@ export const MarkdownClipboard = Extension.create({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const text = event.clipboardData.getData("text/plain");
|
const text = event.clipboardData.getData("text/plain");
|
||||||
const html = event.clipboardData.getData("text/html");
|
|
||||||
const vscode = event.clipboardData.getData("vscode-editor-data");
|
const vscode = event.clipboardData.getData("vscode-editor-data");
|
||||||
const vscodeData = vscode ? JSON.parse(vscode) : undefined;
|
const vscodeData = vscode ? JSON.parse(vscode) : undefined;
|
||||||
const language = vscodeData?.mode;
|
const language = vscodeData?.mode;
|
||||||
|
|
||||||
const isVscodeMarkdown = language === "markdown";
|
if (language !== "markdown") {
|
||||||
const isPlainTextOnly = !html && !vscode && !!text;
|
|
||||||
|
|
||||||
if (!isVscodeMarkdown && !isPlainTextOnly) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPlainTextOnly) {
|
|
||||||
if ((view as any).input?.shiftKey || !this.options.transformPastedText) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const link = find(text, {
|
|
||||||
defaultProtocol: "http",
|
|
||||||
}).find((item) => item.isLink && item.value === text);
|
|
||||||
|
|
||||||
if (link) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const { tr } = view.state;
|
const { tr } = view.state;
|
||||||
const { from, to } = view.state.selection;
|
const { from, to } = view.state.selection;
|
||||||
|
|
||||||
const parsed = markdownToHtml(text.replace(/\n+$/, ""));
|
const html = markdownToHtml(text.replace(/\n+$/, ""));
|
||||||
|
|
||||||
const contentNodes = DOMParser.fromSchema(
|
const contentNodes = DOMParser.fromSchema(
|
||||||
this.editor.schema,
|
this.editor.schema,
|
||||||
).parseSlice(elementFromString(parsed), {
|
).parseSlice(elementFromString(html), {
|
||||||
preserveWhitespace: true,
|
preserveWhitespace: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
tr.replaceRange(from, to, contentNodes);
|
tr.replaceRange(from, to, contentNodes);
|
||||||
const insertEnd = tr.mapping.map(from, 1);
|
|
||||||
tr.setSelection(TextSelection.near(tr.doc.resolve(Math.max(from, insertEnd - 2)), -1));
|
|
||||||
tr.setMeta('paste', true)
|
tr.setMeta('paste', true)
|
||||||
view.dispatch(tr);
|
view.dispatch(tr);
|
||||||
return true;
|
return true;
|
||||||
@@ -125,6 +105,26 @@ export const MarkdownClipboard = Extension.create({
|
|||||||
|
|
||||||
return slice;
|
return slice;
|
||||||
},
|
},
|
||||||
|
clipboardTextParser: (text, context, plainText) => {
|
||||||
|
const link = find(text, {
|
||||||
|
defaultProtocol: "http",
|
||||||
|
}).find((item) => item.isLink && item.value === text);
|
||||||
|
|
||||||
|
if (plainText || !this.options.transformPastedText || link) {
|
||||||
|
// don't parse plaintext link to allow link paste handler to work
|
||||||
|
// pasting with shift key prevents formatting
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const parsed = markdownToHtml(text.replace(/\n+$/, ""));
|
||||||
|
return DOMParser.fromSchema(this.editor.schema).parseSlice(
|
||||||
|
elementFromString(parsed),
|
||||||
|
{
|
||||||
|
preserveWhitespace: true,
|
||||||
|
context,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -49,8 +49,6 @@ export function NotificationItem({
|
|||||||
return notification.data?.role === "writer"
|
return notification.data?.role === "writer"
|
||||||
? "<bold>{{name}}</bold> gave you edit access to a page"
|
? "<bold>{{name}}</bold> gave you edit access to a page"
|
||||||
: "<bold>{{name}}</bold> gave you view access to a page";
|
: "<bold>{{name}}</bold> gave you view access to a page";
|
||||||
case "page.updated":
|
|
||||||
return "<bold>{{name}}</bold> updated a page";
|
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -77,7 +75,6 @@ export function NotificationItem({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleMarkRead = (e: React.MouseEvent) => {
|
const handleMarkRead = (e: React.MouseEvent) => {
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
markReadIfNeeded();
|
markReadIfNeeded();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,23 +3,17 @@ import { IconBellOff } from "@tabler/icons-react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useEffect, useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
import { NotificationItem } from "./notification-item";
|
import { NotificationItem } from "./notification-item";
|
||||||
import {
|
import { INotification, NotificationFilter } from "../types/notification.types";
|
||||||
INotification,
|
|
||||||
NotificationFilter,
|
|
||||||
NotificationTab,
|
|
||||||
} from "../types/notification.types";
|
|
||||||
import { groupNotificationsByTime } from "../notification.utils";
|
import { groupNotificationsByTime } from "../notification.utils";
|
||||||
import { useNotificationsQuery } from "../queries/notification-query";
|
import { useNotificationsQuery } from "../queries/notification-query";
|
||||||
import classes from "../notification.module.css";
|
import classes from "../notification.module.css";
|
||||||
|
|
||||||
type NotificationListProps = {
|
type NotificationListProps = {
|
||||||
tab: NotificationTab;
|
|
||||||
filter: NotificationFilter;
|
filter: NotificationFilter;
|
||||||
onNavigate: () => void;
|
onNavigate: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function NotificationList({
|
export function NotificationList({
|
||||||
tab,
|
|
||||||
filter,
|
filter,
|
||||||
onNavigate,
|
onNavigate,
|
||||||
}: NotificationListProps) {
|
}: NotificationListProps) {
|
||||||
@@ -30,7 +24,7 @@ export function NotificationList({
|
|||||||
hasNextPage,
|
hasNextPage,
|
||||||
fetchNextPage,
|
fetchNextPage,
|
||||||
isFetchingNextPage,
|
isFetchingNextPage,
|
||||||
} = useNotificationsQuery(tab as string);
|
} = useNotificationsQuery();
|
||||||
|
|
||||||
const sentinelRef = useRef<HTMLDivElement>(null);
|
const sentinelRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
Menu,
|
Menu,
|
||||||
Popover,
|
Popover,
|
||||||
ScrollArea,
|
ScrollArea,
|
||||||
Tabs,
|
|
||||||
Text,
|
Text,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
@@ -19,20 +18,15 @@ import {
|
|||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { NotificationList } from "./notification-list";
|
import { NotificationList } from "./notification-list";
|
||||||
import {
|
import { NotificationFilter } from "../types/notification.types";
|
||||||
NotificationFilter,
|
|
||||||
NotificationTab,
|
|
||||||
} from "../types/notification.types";
|
|
||||||
import {
|
import {
|
||||||
useMarkAllReadMutation,
|
useMarkAllReadMutation,
|
||||||
useUnreadCountQuery,
|
useUnreadCountQuery,
|
||||||
} from "../queries/notification-query";
|
} from "../queries/notification-query";
|
||||||
import classes from "../notification.module.css";
|
|
||||||
|
|
||||||
export function NotificationPopover() {
|
export function NotificationPopover() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [opened, setOpened] = useState(false);
|
const [opened, setOpened] = useState(false);
|
||||||
const [tab, setTab] = useState<NotificationTab>("direct");
|
|
||||||
const [filter, setFilter] = useState<NotificationFilter>("all");
|
const [filter, setFilter] = useState<NotificationFilter>("all");
|
||||||
|
|
||||||
const { data: unreadData } = useUnreadCountQuery();
|
const { data: unreadData } = useUnreadCountQuery();
|
||||||
@@ -131,27 +125,13 @@ export function NotificationPopover() {
|
|||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Tabs
|
|
||||||
value={tab}
|
|
||||||
onChange={(value) => setTab(value as NotificationTab)}
|
|
||||||
variant="default"
|
|
||||||
color="dark"
|
|
||||||
>
|
|
||||||
<Tabs.List px="md">
|
|
||||||
<Tabs.Tab value="direct">{t("Direct")}</Tabs.Tab>
|
|
||||||
<Tabs.Tab value="updates">{t("Updates")}</Tabs.Tab>
|
|
||||||
</Tabs.List>
|
|
||||||
</Tabs>
|
|
||||||
|
|
||||||
<ScrollArea.Autosize
|
<ScrollArea.Autosize
|
||||||
mah={500}
|
mah={500}
|
||||||
type="auto"
|
type="auto"
|
||||||
offsetScrollbars
|
offsetScrollbars
|
||||||
scrollbarSize={6}
|
scrollbarSize={6}
|
||||||
style={{ overscrollBehavior: "contain" }}
|
|
||||||
>
|
>
|
||||||
<NotificationList
|
<NotificationList
|
||||||
tab={tab}
|
|
||||||
filter={filter}
|
filter={filter}
|
||||||
onNavigate={() => setOpened(false)}
|
onNavigate={() => setOpened(false)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -13,4 +13,3 @@
|
|||||||
.divider {
|
.divider {
|
||||||
border-color: light-dark(var(--mantine-color-gray-2), var(--mantine-color-dark-5));
|
border-color: light-dark(var(--mantine-color-gray-2), var(--mantine-color-dark-5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ import {
|
|||||||
export const NOTIFICATION_KEY = ["notifications"];
|
export const NOTIFICATION_KEY = ["notifications"];
|
||||||
export const UNREAD_COUNT_KEY = ["notifications", "unread-count"];
|
export const UNREAD_COUNT_KEY = ["notifications", "unread-count"];
|
||||||
|
|
||||||
export function useNotificationsQuery(type?: string) {
|
export function useNotificationsQuery() {
|
||||||
return useInfiniteQuery({
|
return useInfiniteQuery({
|
||||||
queryKey: [...NOTIFICATION_KEY, type],
|
queryKey: NOTIFICATION_KEY,
|
||||||
queryFn: ({ pageParam }) => getNotifications({ cursor: pageParam, type }),
|
queryFn: ({ pageParam }) => getNotifications({ cursor: pageParam }),
|
||||||
initialPageParam: undefined as string | undefined,
|
initialPageParam: undefined as string | undefined,
|
||||||
getNextPageParam: (lastPage) =>
|
getNextPageParam: (lastPage) =>
|
||||||
lastPage.meta.hasNextPage ? lastPage.meta.nextCursor : undefined,
|
lastPage.meta.hasNextPage ? lastPage.meta.nextCursor : undefined,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { IPagination } from "@/lib/types";
|
|||||||
export async function getNotifications(params: {
|
export async function getNotifications(params: {
|
||||||
limit?: number;
|
limit?: number;
|
||||||
cursor?: string;
|
cursor?: string;
|
||||||
type?: string;
|
|
||||||
}): Promise<IPagination<INotification>> {
|
}): Promise<IPagination<INotification>> {
|
||||||
const req = await api.post<IPagination<INotification>>(
|
const req = await api.post<IPagination<INotification>>(
|
||||||
"/notifications",
|
"/notifications",
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ export type NotificationType =
|
|||||||
| "comment.created"
|
| "comment.created"
|
||||||
| "comment.resolved"
|
| "comment.resolved"
|
||||||
| "page.user_mention"
|
| "page.user_mention"
|
||||||
| "page.permission_granted"
|
| "page.permission_granted";
|
||||||
| "page.updated";
|
|
||||||
|
|
||||||
export type INotification = {
|
export type INotification = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -39,5 +38,3 @@ export type INotification = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type NotificationFilter = "all" | "unread";
|
export type NotificationFilter = "all" | "unread";
|
||||||
|
|
||||||
export type NotificationTab = "direct" | "updates" | "all";
|
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ import {
|
|||||||
IconArrowRight,
|
IconArrowRight,
|
||||||
IconArrowsHorizontal,
|
IconArrowsHorizontal,
|
||||||
IconDots,
|
IconDots,
|
||||||
IconEye,
|
|
||||||
IconEyeOff,
|
|
||||||
IconFileExport,
|
IconFileExport,
|
||||||
IconHistory,
|
IconHistory,
|
||||||
IconLink,
|
IconLink,
|
||||||
@@ -42,11 +40,6 @@ import { PageStateSegmentedControl } from "@/features/user/components/page-state
|
|||||||
import MovePageModal from "@/features/page/components/move-page-modal.tsx";
|
import MovePageModal from "@/features/page/components/move-page-modal.tsx";
|
||||||
import { useTimeAgo } from "@/hooks/use-time-ago.tsx";
|
import { useTimeAgo } from "@/hooks/use-time-ago.tsx";
|
||||||
import { PageShareModal } from "@/ee/page-permission";
|
import { PageShareModal } from "@/ee/page-permission";
|
||||||
import {
|
|
||||||
useWatchStatusQuery,
|
|
||||||
useWatchPageMutation,
|
|
||||||
useUnwatchPageMutation,
|
|
||||||
} from "@/features/page/queries/watcher-query";
|
|
||||||
|
|
||||||
interface PageHeaderMenuProps {
|
interface PageHeaderMenuProps {
|
||||||
readOnly?: boolean;
|
readOnly?: boolean;
|
||||||
@@ -130,9 +123,6 @@ function PageActionMenu({ readOnly }: PageActionMenuProps) {
|
|||||||
] = useDisclosure(false);
|
] = useDisclosure(false);
|
||||||
const [pageEditor] = useAtom(pageEditorAtom);
|
const [pageEditor] = useAtom(pageEditorAtom);
|
||||||
const pageUpdatedAt = useTimeAgo(page?.updatedAt);
|
const pageUpdatedAt = useTimeAgo(page?.updatedAt);
|
||||||
const { data: watchStatus } = useWatchStatusQuery(page?.id);
|
|
||||||
const watchPage = useWatchPageMutation();
|
|
||||||
const unwatchPage = useUnwatchPageMutation();
|
|
||||||
|
|
||||||
const handleCopyLink = () => {
|
const handleCopyLink = () => {
|
||||||
const pageUrl =
|
const pageUrl =
|
||||||
@@ -195,23 +185,6 @@ function PageActionMenu({ readOnly }: PageActionMenuProps) {
|
|||||||
>
|
>
|
||||||
{t("Copy as Markdown")}
|
{t("Copy as Markdown")}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
|
|
||||||
{watchStatus?.watching ? (
|
|
||||||
<Menu.Item
|
|
||||||
leftSection={<IconEyeOff size={16} />}
|
|
||||||
onClick={() => unwatchPage.mutate(page.id)}
|
|
||||||
>
|
|
||||||
{t("Stop watching")}
|
|
||||||
</Menu.Item>
|
|
||||||
) : (
|
|
||||||
<Menu.Item
|
|
||||||
leftSection={<IconEye size={16} />}
|
|
||||||
onClick={() => watchPage.mutate(page.id)}
|
|
||||||
>
|
|
||||||
{t("Watch page")}
|
|
||||||
</Menu.Item>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Menu.Divider />
|
<Menu.Divider />
|
||||||
|
|
||||||
<Menu.Item leftSection={<IconArrowsHorizontal size={16} />}>
|
<Menu.Item leftSection={<IconArrowsHorizontal size={16} />}>
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
||||||
import {
|
|
||||||
watchPage,
|
|
||||||
unwatchPage,
|
|
||||||
getWatchStatus,
|
|
||||||
} from "@/features/page/services/watcher-service";
|
|
||||||
import { notifications } from "@mantine/notifications";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
|
|
||||||
const WATCHER_KEY = "watcher";
|
|
||||||
|
|
||||||
export function useWatchStatusQuery(pageId: string) {
|
|
||||||
return useQuery({
|
|
||||||
queryKey: [WATCHER_KEY, pageId],
|
|
||||||
queryFn: () => getWatchStatus(pageId),
|
|
||||||
enabled: !!pageId,
|
|
||||||
staleTime: 60_000,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useWatchPageMutation() {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const { t } = useTranslation();
|
|
||||||
return useMutation({
|
|
||||||
mutationFn: (pageId: string) => watchPage(pageId),
|
|
||||||
onSuccess: (_data, pageId) => {
|
|
||||||
queryClient.setQueryData([WATCHER_KEY, pageId], { watching: true });
|
|
||||||
notifications.show({ message: t("You are now watching this page") });
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useUnwatchPageMutation() {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
const { t } = useTranslation();
|
|
||||||
return useMutation({
|
|
||||||
mutationFn: (pageId: string) => unwatchPage(pageId),
|
|
||||||
onSuccess: (_data, pageId) => {
|
|
||||||
queryClient.setQueryData([WATCHER_KEY, pageId], { watching: false });
|
|
||||||
notifications.show({ message: t("You are no longer watching this page") });
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import api from "@/lib/api-client";
|
|
||||||
|
|
||||||
export async function watchPage(pageId: string): Promise<{ watching: boolean }> {
|
|
||||||
const req = await api.post<{ watching: boolean }>("/pages/watch", { pageId });
|
|
||||||
return req.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function unwatchPage(pageId: string): Promise<{ watching: boolean }> {
|
|
||||||
const req = await api.post<{ watching: boolean }>("/pages/unwatch", { pageId });
|
|
||||||
return req.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getWatchStatus(pageId: string): Promise<{ watching: boolean }> {
|
|
||||||
const req = await api.post<{ watching: boolean }>("/pages/watch-status", { pageId });
|
|
||||||
return req.data;
|
|
||||||
}
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
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";
|
|
||||||
import React, { useState } from "react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import {
|
|
||||||
ResponsiveSettingsRow,
|
|
||||||
ResponsiveSettingsContent,
|
|
||||||
ResponsiveSettingsControl,
|
|
||||||
} from "@/components/ui/responsive-settings-row";
|
|
||||||
|
|
||||||
type NotificationKey = keyof NonNullable<IUserSettings["notifications"]>;
|
|
||||||
|
|
||||||
const notificationItems: {
|
|
||||||
key: NotificationKey;
|
|
||||||
dtoField: keyof IUser;
|
|
||||||
label: string;
|
|
||||||
description: string;
|
|
||||||
}[] = [
|
|
||||||
{
|
|
||||||
key: "page.updated",
|
|
||||||
dtoField: "notificationPageUpdates",
|
|
||||||
label: "Page updates",
|
|
||||||
description: "Get notified when pages you watch are updated.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "page.userMention",
|
|
||||||
dtoField: "notificationPageUserMention",
|
|
||||||
label: "Page mentions",
|
|
||||||
description: "Get notified when someone mentions you on a page.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "comment.userMention",
|
|
||||||
dtoField: "notificationCommentUserMention",
|
|
||||||
label: "Comment mentions",
|
|
||||||
description: "Get notified when someone mentions you in a comment.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "comment.created",
|
|
||||||
dtoField: "notificationCommentCreated",
|
|
||||||
label: "New comments",
|
|
||||||
description:
|
|
||||||
"Get notified about new comments on threads you participate in.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "comment.resolved",
|
|
||||||
dtoField: "notificationCommentResolved",
|
|
||||||
label: "Resolved comments",
|
|
||||||
description: "Get notified when your comment is resolved.",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
function NotificationToggle({
|
|
||||||
settingKey,
|
|
||||||
dtoField,
|
|
||||||
label,
|
|
||||||
description,
|
|
||||||
}: {
|
|
||||||
settingKey: NotificationKey;
|
|
||||||
dtoField: keyof IUser;
|
|
||||||
label: string;
|
|
||||||
description: string;
|
|
||||||
}) {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const [user, setUser] = useAtom(userAtom);
|
|
||||||
const [checked, setChecked] = useState(
|
|
||||||
user.settings?.notifications?.[settingKey] !== false,
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
||||||
const value = event.currentTarget.checked;
|
|
||||||
setChecked(value);
|
|
||||||
try {
|
|
||||||
const updatedUser = await updateUser({ [dtoField]: value } as any);
|
|
||||||
setUser(updatedUser);
|
|
||||||
} catch {
|
|
||||||
setChecked(!value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ResponsiveSettingsRow>
|
|
||||||
<ResponsiveSettingsContent>
|
|
||||||
<Text size="md">{t(label)}</Text>
|
|
||||||
<Text size="sm" c="dimmed">
|
|
||||||
{t(description)}
|
|
||||||
</Text>
|
|
||||||
</ResponsiveSettingsContent>
|
|
||||||
|
|
||||||
<ResponsiveSettingsControl>
|
|
||||||
<Switch checked={checked} onChange={handleChange} />
|
|
||||||
</ResponsiveSettingsControl>
|
|
||||||
</ResponsiveSettingsRow>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function NotificationPref() {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Stack gap="xs">
|
|
||||||
<Title order={5}>{t("Email notifications")}</Title>
|
|
||||||
|
|
||||||
{notificationItems.map((item) => (
|
|
||||||
<NotificationToggle
|
|
||||||
key={item.key}
|
|
||||||
settingKey={item.key}
|
|
||||||
dtoField={item.dtoField}
|
|
||||||
label={item.label}
|
|
||||||
description={item.description}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -20,11 +20,6 @@ export interface IUser {
|
|||||||
deletedAt: Date;
|
deletedAt: Date;
|
||||||
fullPageWidth: boolean; // used for update
|
fullPageWidth: boolean; // used for update
|
||||||
pageEditMode: string; // used for update
|
pageEditMode: string; // used for update
|
||||||
notificationPageUpdates: boolean; // used for update
|
|
||||||
notificationPageUserMention: boolean; // used for update
|
|
||||||
notificationCommentUserMention: boolean; // used for update
|
|
||||||
notificationCommentCreated: boolean; // used for update
|
|
||||||
notificationCommentResolved: boolean; // used for update
|
|
||||||
hasGeneratedPassword?: boolean;
|
hasGeneratedPassword?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,13 +33,6 @@ export interface IUserSettings {
|
|||||||
fullPageWidth: boolean;
|
fullPageWidth: boolean;
|
||||||
pageEditMode: string;
|
pageEditMode: string;
|
||||||
};
|
};
|
||||||
notifications?: {
|
|
||||||
"page.updated"?: boolean;
|
|
||||||
"page.userMention"?: boolean;
|
|
||||||
"comment.userMention"?: boolean;
|
|
||||||
"comment.created"?: boolean;
|
|
||||||
"comment.resolved"?: boolean;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum PageEditMode {
|
export enum PageEditMode {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import AccountLanguage from "@/features/user/components/account-language.tsx";
|
|||||||
import AccountTheme from "@/features/user/components/account-theme.tsx";
|
import AccountTheme from "@/features/user/components/account-theme.tsx";
|
||||||
import PageWidthPref from "@/features/user/components/page-width-pref.tsx";
|
import PageWidthPref from "@/features/user/components/page-width-pref.tsx";
|
||||||
import PageEditPref from "@/features/user/components/page-state-pref";
|
import PageEditPref from "@/features/user/components/page-state-pref";
|
||||||
import NotificationPref from "@/features/user/components/notification-pref";
|
|
||||||
import { getAppName } from "@/lib/config.ts";
|
import { getAppName } from "@/lib/config.ts";
|
||||||
import { Divider } from "@mantine/core";
|
import { Divider } from "@mantine/core";
|
||||||
import { Helmet } from "react-helmet-async";
|
import { Helmet } from "react-helmet-async";
|
||||||
@@ -34,10 +33,6 @@ export default function AccountPreferences() {
|
|||||||
<Divider my={"md"} />
|
<Divider my={"md"} />
|
||||||
|
|
||||||
<PageEditPref />
|
<PageEditPref />
|
||||||
|
|
||||||
<Divider my={"md"} />
|
|
||||||
|
|
||||||
<NotificationPref />
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,6 @@
|
|||||||
"@langchain/core": "1.1.34",
|
"@langchain/core": "1.1.34",
|
||||||
"@langchain/textsplitters": "1.0.1",
|
"@langchain/textsplitters": "1.0.1",
|
||||||
"@modelcontextprotocol/sdk": "^1.27.1",
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
||||||
"@nest-lab/throttler-storage-redis": "^1.2.0",
|
|
||||||
"@nestjs-labs/nestjs-ioredis": "^11.0.4",
|
"@nestjs-labs/nestjs-ioredis": "^11.0.4",
|
||||||
"@nestjs/bullmq": "^11.0.4",
|
"@nestjs/bullmq": "^11.0.4",
|
||||||
"@nestjs/cache-manager": "^3.1.0",
|
"@nestjs/cache-manager": "^3.1.0",
|
||||||
@@ -59,7 +58,6 @@
|
|||||||
"@nestjs/platform-socket.io": "^11.1.17",
|
"@nestjs/platform-socket.io": "^11.1.17",
|
||||||
"@nestjs/schedule": "^6.1.1",
|
"@nestjs/schedule": "^6.1.1",
|
||||||
"@nestjs/terminus": "^11.1.1",
|
"@nestjs/terminus": "^11.1.1",
|
||||||
"@nestjs/throttler": "^6.5.0",
|
|
||||||
"@nestjs/websockets": "^11.1.17",
|
"@nestjs/websockets": "^11.1.17",
|
||||||
"@node-saml/passport-saml": "^5.1.0",
|
"@node-saml/passport-saml": "^5.1.0",
|
||||||
"@react-email/components": "1.0.10",
|
"@react-email/components": "1.0.10",
|
||||||
@@ -75,7 +73,6 @@
|
|||||||
"class-transformer": "^0.5.1",
|
"class-transformer": "^0.5.1",
|
||||||
"class-validator": "^0.15.1",
|
"class-validator": "^0.15.1",
|
||||||
"cookie": "^1.1.1",
|
"cookie": "^1.1.1",
|
||||||
"fastify-ip": "^2.0.0",
|
|
||||||
"fs-extra": "^11.3.4",
|
"fs-extra": "^11.3.4",
|
||||||
"happy-dom": "20.8.9",
|
"happy-dom": "20.8.9",
|
||||||
"ioredis": "^5.10.1",
|
"ioredis": "^5.10.1",
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import KeyvRedis from '@keyv/redis';
|
|||||||
import { LoggerModule } from './common/logger/logger.module';
|
import { LoggerModule } from './common/logger/logger.module';
|
||||||
import { ClsModule } from 'nestjs-cls';
|
import { ClsModule } from 'nestjs-cls';
|
||||||
import { NoopAuditModule } from './integrations/audit/audit.module';
|
import { NoopAuditModule } from './integrations/audit/audit.module';
|
||||||
import { ThrottleModule } from './integrations/throttle/throttle.module';
|
|
||||||
|
|
||||||
const enterpriseModules = [];
|
const enterpriseModules = [];
|
||||||
try {
|
try {
|
||||||
@@ -84,7 +83,6 @@ try {
|
|||||||
EventEmitterModule.forRoot(),
|
EventEmitterModule.forRoot(),
|
||||||
SecurityModule,
|
SecurityModule,
|
||||||
TelemetryModule,
|
TelemetryModule,
|
||||||
ThrottleModule,
|
|
||||||
...enterpriseModules,
|
...enterpriseModules,
|
||||||
],
|
],
|
||||||
controllers: [AppController],
|
controllers: [AppController],
|
||||||
|
|||||||
@@ -18,10 +18,12 @@ import { QueueJob, QueueName } from '../../integrations/queue/constants';
|
|||||||
import { Queue } from 'bullmq';
|
import { Queue } from 'bullmq';
|
||||||
import {
|
import {
|
||||||
extractMentions,
|
extractMentions,
|
||||||
|
extractPageMentions,
|
||||||
extractUserMentions,
|
extractUserMentions,
|
||||||
} from '../../common/helpers/prosemirror/utils';
|
} from '../../common/helpers/prosemirror/utils';
|
||||||
import { isDeepStrictEqual } from 'node:util';
|
import { isDeepStrictEqual } from 'node:util';
|
||||||
import {
|
import {
|
||||||
|
IPageBacklinkJob,
|
||||||
IPageHistoryJob,
|
IPageHistoryJob,
|
||||||
IPageMentionNotificationJob,
|
IPageMentionNotificationJob,
|
||||||
} from '../../integrations/queue/constants/queue.interface';
|
} from '../../integrations/queue/constants/queue.interface';
|
||||||
@@ -41,6 +43,7 @@ export class PersistenceExtension implements Extension {
|
|||||||
constructor(
|
constructor(
|
||||||
private readonly pageRepo: PageRepo,
|
private readonly pageRepo: PageRepo,
|
||||||
@InjectKysely() private readonly db: KyselyDB,
|
@InjectKysely() private readonly db: KyselyDB,
|
||||||
|
@InjectQueue(QueueName.GENERAL_QUEUE) private generalQueue: Queue,
|
||||||
@InjectQueue(QueueName.AI_QUEUE) private aiQueue: Queue,
|
@InjectQueue(QueueName.AI_QUEUE) private aiQueue: Queue,
|
||||||
@InjectQueue(QueueName.HISTORY_QUEUE) private historyQueue: Queue,
|
@InjectQueue(QueueName.HISTORY_QUEUE) private historyQueue: Queue,
|
||||||
@InjectQueue(QueueName.NOTIFICATION_QUEUE) private notificationQueue: Queue,
|
@InjectQueue(QueueName.NOTIFICATION_QUEUE) private notificationQueue: Queue,
|
||||||
@@ -162,6 +165,13 @@ export class PersistenceExtension implements Extension {
|
|||||||
await this.collabHistory.addContributors(pageId, editingUserIds);
|
await this.collabHistory.addContributors(pageId, editingUserIds);
|
||||||
|
|
||||||
const mentions = extractMentions(tiptapJson);
|
const mentions = extractMentions(tiptapJson);
|
||||||
|
const pageMentions = extractPageMentions(mentions);
|
||||||
|
|
||||||
|
await this.generalQueue.add(QueueJob.PAGE_BACKLINKS, {
|
||||||
|
pageId: pageId,
|
||||||
|
workspaceId: page.workspaceId,
|
||||||
|
mentions: pageMentions,
|
||||||
|
} as IPageBacklinkJob);
|
||||||
|
|
||||||
const userMentions = extractUserMentions(mentions);
|
const userMentions = extractUserMentions(mentions);
|
||||||
const oldMentions = page.content ? extractMentions(page.content) : [];
|
const oldMentions = page.content ? extractMentions(page.content) : [];
|
||||||
|
|||||||
@@ -1,17 +1,8 @@
|
|||||||
import { Logger, OnModuleDestroy } from '@nestjs/common';
|
import { Logger, OnModuleDestroy } from '@nestjs/common';
|
||||||
import { OnWorkerEvent, Processor, WorkerHost } from '@nestjs/bullmq';
|
import { OnWorkerEvent, Processor, WorkerHost } from '@nestjs/bullmq';
|
||||||
import { InjectQueue } from '@nestjs/bullmq';
|
import { Job } from 'bullmq';
|
||||||
import { Job, Queue } from 'bullmq';
|
|
||||||
import { QueueJob, QueueName } from '../../integrations/queue/constants';
|
import { QueueJob, QueueName } from '../../integrations/queue/constants';
|
||||||
import {
|
import { IPageHistoryJob } from '../../integrations/queue/constants/queue.interface';
|
||||||
IPageBacklinkJob,
|
|
||||||
IPageHistoryJob,
|
|
||||||
IPageUpdateNotificationJob,
|
|
||||||
} from '../../integrations/queue/constants/queue.interface';
|
|
||||||
import {
|
|
||||||
extractMentions,
|
|
||||||
extractPageMentions,
|
|
||||||
} from '../../common/helpers/prosemirror/utils';
|
|
||||||
import { PageHistoryRepo } from '@docmost/db/repos/page/page-history.repo';
|
import { PageHistoryRepo } from '@docmost/db/repos/page/page-history.repo';
|
||||||
import { PageRepo } from '@docmost/db/repos/page/page.repo';
|
import { PageRepo } from '@docmost/db/repos/page/page.repo';
|
||||||
import { isDeepStrictEqual } from 'node:util';
|
import { isDeepStrictEqual } from 'node:util';
|
||||||
@@ -27,8 +18,6 @@ export class HistoryProcessor extends WorkerHost implements OnModuleDestroy {
|
|||||||
private readonly pageRepo: PageRepo,
|
private readonly pageRepo: PageRepo,
|
||||||
private readonly collabHistory: CollabHistoryService,
|
private readonly collabHistory: CollabHistoryService,
|
||||||
private readonly watcherService: WatcherService,
|
private readonly watcherService: WatcherService,
|
||||||
@InjectQueue(QueueName.NOTIFICATION_QUEUE) private notificationQueue: Queue,
|
|
||||||
@InjectQueue(QueueName.GENERAL_QUEUE) private generalQueue: Queue,
|
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@@ -58,7 +47,8 @@ export class HistoryProcessor extends WorkerHost implements OnModuleDestroy {
|
|||||||
!lastHistory ||
|
!lastHistory ||
|
||||||
!isDeepStrictEqual(lastHistory.content, page.content)
|
!isDeepStrictEqual(lastHistory.content, page.content)
|
||||||
) {
|
) {
|
||||||
const contributorIds = await this.collabHistory.popContributors(pageId);
|
const contributorIds =
|
||||||
|
await this.collabHistory.popContributors(pageId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.watcherService.addPageWatchers(
|
await this.watcherService.addPageWatchers(
|
||||||
@@ -71,38 +61,11 @@ export class HistoryProcessor extends WorkerHost implements OnModuleDestroy {
|
|||||||
await this.pageHistoryRepo.saveHistory(page, { contributorIds });
|
await this.pageHistoryRepo.saveHistory(page, { contributorIds });
|
||||||
this.logger.debug(`History created for page: ${pageId}`);
|
this.logger.debug(`History created for page: ${pageId}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
await this.collabHistory.addContributors(pageId, contributorIds);
|
await this.collabHistory.addContributors(
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
const mentions = extractMentions(page.content);
|
|
||||||
const pageMentions = extractPageMentions(mentions);
|
|
||||||
|
|
||||||
await this.generalQueue
|
|
||||||
.add(QueueJob.PAGE_BACKLINKS, {
|
|
||||||
pageId,
|
pageId,
|
||||||
workspaceId: page.workspaceId,
|
contributorIds,
|
||||||
mentions: pageMentions,
|
);
|
||||||
} as IPageBacklinkJob)
|
throw err;
|
||||||
.catch((err) => {
|
|
||||||
this.logger.error(
|
|
||||||
`Failed to queue backlinks for ${pageId}: ${err.message}`,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (contributorIds.length > 0 && lastHistory?.content) {
|
|
||||||
await this.notificationQueue
|
|
||||||
.add(QueueJob.PAGE_UPDATED, {
|
|
||||||
pageId,
|
|
||||||
spaceId: page.spaceId,
|
|
||||||
workspaceId: page.workspaceId,
|
|
||||||
actorIds: contributorIds,
|
|
||||||
} as IPageUpdateNotificationJob)
|
|
||||||
.catch((err) => {
|
|
||||||
this.logger.error(
|
|
||||||
`Failed to queue page update notification for ${pageId}: ${err.message}`,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -50,12 +50,20 @@ export function createPinoConfig(): Params {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
serializers: {
|
serializers: {
|
||||||
req: (req) => ({
|
req: (req) => {
|
||||||
method: req.method,
|
const forwardedFor = req.headers?.['x-forwarded-for'];
|
||||||
url: req.url,
|
const ip =
|
||||||
ip: req.ip || req.remoteAddress,
|
req.headers?.['cf-connecting-ip'] ||
|
||||||
userAgent: req.headers?.['user-agent'],
|
(typeof forwardedFor === 'string' ? forwardedFor.split(',')[0]?.trim() : undefined) ||
|
||||||
}),
|
req.remoteAddress;
|
||||||
|
|
||||||
|
return {
|
||||||
|
method: req.method,
|
||||||
|
url: req.url,
|
||||||
|
ip,
|
||||||
|
userAgent: req.headers?.['user-agent'],
|
||||||
|
};
|
||||||
|
},
|
||||||
res: (res) => ({
|
res: (res) => ({
|
||||||
statusCode: res.statusCode,
|
statusCode: res.statusCode,
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ export class AuditContextMiddleware implements NestMiddleware {
|
|||||||
|
|
||||||
use(req: FastifyRequest['raw'], res: FastifyReply['raw'], next: () => void) {
|
use(req: FastifyRequest['raw'], res: FastifyReply['raw'], next: () => void) {
|
||||||
const workspaceId = (req as any).workspaceId ?? null;
|
const workspaceId = (req as any).workspaceId ?? null;
|
||||||
|
const ipAddress = this.extractIpAddress(req);
|
||||||
const ipAddress = (req as any).ip ?? (req as any).socket?.remoteAddress ?? null;
|
|
||||||
|
|
||||||
const userAgent =
|
const userAgent =
|
||||||
(req.headers['user-agent'] as string) ?? null;
|
(req.headers['user-agent'] as string) ?? null;
|
||||||
@@ -36,4 +35,21 @@ export class AuditContextMiddleware implements NestMiddleware {
|
|||||||
|
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private extractIpAddress(req: FastifyRequest['raw']): string | null {
|
||||||
|
const xForwardedFor = req.headers['x-forwarded-for'];
|
||||||
|
if (xForwardedFor) {
|
||||||
|
const ips = Array.isArray(xForwardedFor)
|
||||||
|
? xForwardedFor[0]
|
||||||
|
: xForwardedFor.split(',')[0];
|
||||||
|
return ips?.trim() ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const xRealIp = req.headers['x-real-ip'];
|
||||||
|
if (xRealIp) {
|
||||||
|
return Array.isArray(xRealIp) ? xRealIp[0] : xRealIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (req as any).socket?.remoteAddress ?? null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
UseGuards,
|
UseGuards,
|
||||||
Logger,
|
Logger,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { SkipThrottle, ThrottlerGuard } from '@nestjs/throttler';
|
|
||||||
import { LoginDto } from './dto/login.dto';
|
import { LoginDto } from './dto/login.dto';
|
||||||
import { AuthService } from './services/auth.service';
|
import { AuthService } from './services/auth.service';
|
||||||
import { SessionService } from '../session/session.service';
|
import { SessionService } from '../session/session.service';
|
||||||
@@ -34,7 +33,6 @@ import {
|
|||||||
IAuditService,
|
IAuditService,
|
||||||
} from '../../integrations/audit/audit.service';
|
} from '../../integrations/audit/audit.service';
|
||||||
|
|
||||||
@UseGuards(ThrottlerGuard)
|
|
||||||
@Controller('auth')
|
@Controller('auth')
|
||||||
export class AuthController {
|
export class AuthController {
|
||||||
private readonly logger = new Logger(AuthController.name);
|
private readonly logger = new Logger(AuthController.name);
|
||||||
@@ -113,7 +111,6 @@ export class AuthController {
|
|||||||
return workspace;
|
return workspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SkipThrottle()
|
|
||||||
@UseGuards(JwtAuthGuard)
|
@UseGuards(JwtAuthGuard)
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
@Post('change-password')
|
@Post('change-password')
|
||||||
@@ -176,7 +173,6 @@ export class AuthController {
|
|||||||
return this.authService.verifyUserToken(verifyUserTokenDto, workspace.id);
|
return this.authService.verifyUserToken(verifyUserTokenDto, workspace.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SkipThrottle()
|
|
||||||
@UseGuards(JwtAuthGuard)
|
@UseGuards(JwtAuthGuard)
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
@Post('collab-token')
|
@Post('collab-token')
|
||||||
@@ -187,7 +183,6 @@ export class AuthController {
|
|||||||
return this.authService.getCollabToken(user, workspace.id);
|
return this.authService.getCollabToken(user, workspace.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SkipThrottle()
|
|
||||||
@UseGuards(JwtAuthGuard)
|
@UseGuards(JwtAuthGuard)
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
@Post('logout')
|
@Post('logout')
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { IsArray, IsIn, IsOptional, IsString, IsUUID } from 'class-validator';
|
import { IsArray, IsOptional, IsUUID } from 'class-validator';
|
||||||
import { PaginationOptions } from '@docmost/db/pagination/pagination-options';
|
|
||||||
|
|
||||||
export class NotificationIdDto {
|
export class NotificationIdDto {
|
||||||
@IsUUID()
|
@IsUUID()
|
||||||
@@ -12,10 +11,3 @@ export class MarkNotificationsReadDto {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
notificationIds?: string[];
|
notificationIds?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ListNotificationsDto extends PaginationOptions {
|
|
||||||
@IsOptional()
|
|
||||||
@IsString()
|
|
||||||
@IsIn(['direct', 'updates', 'all'])
|
|
||||||
type?: 'direct' | 'updates' | 'all' = 'all';
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,45 +4,7 @@ export const NotificationType = {
|
|||||||
COMMENT_RESOLVED: 'comment.resolved',
|
COMMENT_RESOLVED: 'comment.resolved',
|
||||||
PAGE_USER_MENTION: 'page.user_mention',
|
PAGE_USER_MENTION: 'page.user_mention',
|
||||||
PAGE_PERMISSION_GRANTED: 'page.permission_granted',
|
PAGE_PERMISSION_GRANTED: 'page.permission_granted',
|
||||||
PAGE_UPDATED: 'page.updated',
|
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export type NotificationType =
|
export type NotificationType =
|
||||||
(typeof NotificationType)[keyof typeof NotificationType];
|
(typeof NotificationType)[keyof typeof NotificationType];
|
||||||
|
|
||||||
export type NotificationSettingKey =
|
|
||||||
| 'page.updated'
|
|
||||||
| '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',
|
|
||||||
};
|
|
||||||
|
|
||||||
export type NotificationTab = 'direct' | 'updates' | 'all';
|
|
||||||
|
|
||||||
export const DIRECT_NOTIFICATION_TYPES: NotificationType[] = [
|
|
||||||
NotificationType.COMMENT_USER_MENTION,
|
|
||||||
NotificationType.COMMENT_CREATED,
|
|
||||||
NotificationType.COMMENT_RESOLVED,
|
|
||||||
NotificationType.PAGE_USER_MENTION,
|
|
||||||
NotificationType.PAGE_PERMISSION_GRANTED,
|
|
||||||
];
|
|
||||||
|
|
||||||
export const UPDATES_NOTIFICATION_TYPES: NotificationType[] = [
|
|
||||||
NotificationType.PAGE_UPDATED,
|
|
||||||
];
|
|
||||||
|
|
||||||
export function getTypesForTab(tab: NotificationTab): NotificationType[] | undefined {
|
|
||||||
if (tab === 'direct') return DIRECT_NOTIFICATION_TYPES;
|
|
||||||
if (tab === 'updates') return UPDATES_NOTIFICATION_TYPES;
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -9,8 +9,9 @@ import {
|
|||||||
import { NotificationService } from './notification.service';
|
import { NotificationService } from './notification.service';
|
||||||
import { AuthUser } from '../../common/decorators/auth-user.decorator';
|
import { AuthUser } from '../../common/decorators/auth-user.decorator';
|
||||||
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
|
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
|
||||||
|
import { PaginationOptions } from '@docmost/db/pagination/pagination-options';
|
||||||
import { User } from '@docmost/db/types/entity.types';
|
import { User } from '@docmost/db/types/entity.types';
|
||||||
import { ListNotificationsDto, MarkNotificationsReadDto } from './dto/notification.dto';
|
import { MarkNotificationsReadDto } from './dto/notification.dto';
|
||||||
|
|
||||||
@UseGuards(JwtAuthGuard)
|
@UseGuards(JwtAuthGuard)
|
||||||
@Controller('notifications')
|
@Controller('notifications')
|
||||||
@@ -20,10 +21,10 @@ export class NotificationController {
|
|||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
@Post('/')
|
@Post('/')
|
||||||
async getNotifications(
|
async getNotifications(
|
||||||
@Body() dto: ListNotificationsDto,
|
@Body() pagination: PaginationOptions,
|
||||||
@AuthUser() user: User,
|
@AuthUser() user: User,
|
||||||
) {
|
) {
|
||||||
return this.notificationService.findByUserId(user.id, dto, dto.type);
|
return this.notificationService.findByUserId(user.id, pagination);
|
||||||
}
|
}
|
||||||
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { NotificationController } from './notification.controller';
|
|||||||
import { NotificationProcessor } from './notification.processor';
|
import { NotificationProcessor } from './notification.processor';
|
||||||
import { CommentNotificationService } from './services/comment.notification';
|
import { CommentNotificationService } from './services/comment.notification';
|
||||||
import { PageNotificationService } from './services/page.notification';
|
import { PageNotificationService } from './services/page.notification';
|
||||||
import { PageUpdateEmailRateLimiter } from './services/page-update-email-rate-limiter';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [],
|
imports: [],
|
||||||
@@ -14,7 +13,6 @@ import { PageUpdateEmailRateLimiter } from './services/page-update-email-rate-li
|
|||||||
NotificationProcessor,
|
NotificationProcessor,
|
||||||
CommentNotificationService,
|
CommentNotificationService,
|
||||||
PageNotificationService,
|
PageNotificationService,
|
||||||
PageUpdateEmailRateLimiter,
|
|
||||||
],
|
],
|
||||||
exports: [NotificationService],
|
exports: [NotificationService],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import {
|
|||||||
ICommentNotificationJob,
|
ICommentNotificationJob,
|
||||||
ICommentResolvedNotificationJob,
|
ICommentResolvedNotificationJob,
|
||||||
IPageMentionNotificationJob,
|
IPageMentionNotificationJob,
|
||||||
IPageUpdateNotificationJob,
|
|
||||||
IPermissionGrantedNotificationJob,
|
IPermissionGrantedNotificationJob,
|
||||||
} from '../../integrations/queue/constants/queue.interface';
|
} from '../../integrations/queue/constants/queue.interface';
|
||||||
import { CommentNotificationService } from './services/comment.notification';
|
import { CommentNotificationService } from './services/comment.notification';
|
||||||
@@ -36,7 +35,6 @@ export class NotificationProcessor
|
|||||||
| ICommentNotificationJob
|
| ICommentNotificationJob
|
||||||
| ICommentResolvedNotificationJob
|
| ICommentResolvedNotificationJob
|
||||||
| IPageMentionNotificationJob
|
| IPageMentionNotificationJob
|
||||||
| IPageUpdateNotificationJob
|
|
||||||
| IPermissionGrantedNotificationJob,
|
| IPermissionGrantedNotificationJob,
|
||||||
void
|
void
|
||||||
>,
|
>,
|
||||||
@@ -78,20 +76,6 @@ export class NotificationProcessor
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case QueueJob.PAGE_UPDATED: {
|
|
||||||
await this.pageNotificationService.processPageUpdate(
|
|
||||||
job.data as IPageUpdateNotificationJob,
|
|
||||||
appUrl,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case QueueJob.PAGE_UPDATE_DIGEST: {
|
|
||||||
const { userId } = job.data as unknown as { userId: string };
|
|
||||||
await this.pageNotificationService.processDigest(userId, appUrl);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
this.logger.warn(`Unknown notification job: ${job.name}`);
|
this.logger.warn(`Unknown notification job: ${job.name}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import { InsertableNotification } from '@docmost/db/types/entity.types';
|
|||||||
import { PaginationOptions } from '@docmost/db/pagination/pagination-options';
|
import { PaginationOptions } from '@docmost/db/pagination/pagination-options';
|
||||||
import { WsGateway } from '../../ws/ws.gateway';
|
import { WsGateway } from '../../ws/ws.gateway';
|
||||||
import { MailService } from '../../integrations/mail/mail.service';
|
import { MailService } from '../../integrations/mail/mail.service';
|
||||||
import { NotificationTab, NotificationType, NotificationTypeToSettingKey } from './notification.constants';
|
|
||||||
import { PagePermissionRepo } from '@docmost/db/repos/page/page-permission.repo';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class NotificationService {
|
export class NotificationService {
|
||||||
@@ -15,23 +13,12 @@ export class NotificationService {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly notificationRepo: NotificationRepo,
|
private readonly notificationRepo: NotificationRepo,
|
||||||
private readonly pagePermissionRepo: PagePermissionRepo,
|
|
||||||
private readonly wsGateway: WsGateway,
|
private readonly wsGateway: WsGateway,
|
||||||
private readonly mailService: MailService,
|
private readonly mailService: MailService,
|
||||||
@InjectKysely() private readonly db: KyselyDB,
|
@InjectKysely() private readonly db: KyselyDB,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async create(data: InsertableNotification) {
|
async create(data: InsertableNotification) {
|
||||||
const user = await this.db
|
|
||||||
.selectFrom('users')
|
|
||||||
.select(['id'])
|
|
||||||
.where('id', '=', data.userId)
|
|
||||||
.where('deletedAt', 'is', null)
|
|
||||||
.where('deactivatedAt', 'is', null)
|
|
||||||
.executeTakeFirst();
|
|
||||||
|
|
||||||
if (!user) return null;
|
|
||||||
|
|
||||||
const notification = await this.notificationRepo.insert(data);
|
const notification = await this.notificationRepo.insert(data);
|
||||||
|
|
||||||
this.wsGateway.server
|
this.wsGateway.server
|
||||||
@@ -41,35 +28,8 @@ export class NotificationService {
|
|||||||
return notification;
|
return notification;
|
||||||
}
|
}
|
||||||
|
|
||||||
async findByUserId(
|
async findByUserId(userId: string, pagination: PaginationOptions) {
|
||||||
userId: string,
|
return this.notificationRepo.findByUserId(userId, pagination);
|
||||||
pagination: PaginationOptions,
|
|
||||||
type: NotificationTab = 'all',
|
|
||||||
) {
|
|
||||||
const result = await this.notificationRepo.findByUserId(
|
|
||||||
userId,
|
|
||||||
pagination,
|
|
||||||
type,
|
|
||||||
);
|
|
||||||
|
|
||||||
const pageIds = result.items
|
|
||||||
.map((n: any) => n.pageId)
|
|
||||||
.filter(Boolean);
|
|
||||||
|
|
||||||
if (pageIds.length > 0) {
|
|
||||||
const accessiblePageIds =
|
|
||||||
await this.pagePermissionRepo.filterAccessiblePageIds({
|
|
||||||
pageIds,
|
|
||||||
userId,
|
|
||||||
});
|
|
||||||
const accessibleSet = new Set(accessiblePageIds);
|
|
||||||
|
|
||||||
result.items = result.items.filter(
|
|
||||||
(n: any) => !n.pageId || accessibleSet.has(n.pageId),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUnreadCount(userId: string) {
|
async getUnreadCount(userId: string) {
|
||||||
@@ -93,27 +53,17 @@ export class NotificationService {
|
|||||||
notificationId: string,
|
notificationId: string,
|
||||||
subject: string,
|
subject: string,
|
||||||
template: any,
|
template: any,
|
||||||
type?: NotificationType,
|
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const user = await this.db
|
const user = await this.db
|
||||||
.selectFrom('users')
|
.selectFrom('users')
|
||||||
.select(['email', 'settings'])
|
.select(['email'])
|
||||||
.where('id', '=', userId)
|
.where('id', '=', userId)
|
||||||
.where('deletedAt', 'is', null)
|
.where('deletedAt', 'is', null)
|
||||||
.where('deactivatedAt', 'is', null)
|
|
||||||
.executeTakeFirst();
|
.executeTakeFirst();
|
||||||
|
|
||||||
if (!user?.email) return;
|
if (!user?.email) return;
|
||||||
|
|
||||||
if (type) {
|
|
||||||
const settingKey = NotificationTypeToSettingKey[type];
|
|
||||||
if (settingKey) {
|
|
||||||
const settings = user.settings as any;
|
|
||||||
if (settings?.notifications?.[settingKey] === false) return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.mailService.sendToQueue({
|
await this.mailService.sendToQueue({
|
||||||
to: user.email,
|
to: user.email,
|
||||||
subject,
|
subject,
|
||||||
|
|||||||
@@ -86,14 +86,12 @@ export class CommentNotificationService {
|
|||||||
spaceId,
|
spaceId,
|
||||||
commentId,
|
commentId,
|
||||||
});
|
});
|
||||||
if (!notification) continue;
|
|
||||||
|
|
||||||
await this.notificationService.queueEmail(
|
await this.notificationService.queueEmail(
|
||||||
userId,
|
userId,
|
||||||
notification.id,
|
notification.id,
|
||||||
`${actor.name} mentioned you in a comment`,
|
`${actor.name} mentioned you in a comment`,
|
||||||
CommentMentionEmail({ actorName: actor.name, pageTitle, pageUrl }),
|
CommentMentionEmail({ actorName: actor.name, pageTitle, pageUrl }),
|
||||||
NotificationType.COMMENT_USER_MENTION,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
notifiedUserIds.add(userId);
|
notifiedUserIds.add(userId);
|
||||||
@@ -112,14 +110,12 @@ export class CommentNotificationService {
|
|||||||
spaceId,
|
spaceId,
|
||||||
commentId,
|
commentId,
|
||||||
});
|
});
|
||||||
if (!notification) continue;
|
|
||||||
|
|
||||||
await this.notificationService.queueEmail(
|
await this.notificationService.queueEmail(
|
||||||
recipientId,
|
recipientId,
|
||||||
notification.id,
|
notification.id,
|
||||||
`${actor.name} commented on ${pageTitle}`,
|
`${actor.name} commented on ${pageTitle}`,
|
||||||
CommentCreateEmail({ actorName: actor.name, pageTitle, pageUrl }),
|
CommentCreateEmail({ actorName: actor.name, pageTitle, pageUrl }),
|
||||||
NotificationType.COMMENT_CREATED,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,7 +171,6 @@ export class CommentNotificationService {
|
|||||||
spaceId,
|
spaceId,
|
||||||
commentId,
|
commentId,
|
||||||
});
|
});
|
||||||
if (!notification) return;
|
|
||||||
|
|
||||||
const subject = `${actor.name} resolved a comment on ${pageTitle}`;
|
const subject = `${actor.name} resolved a comment on ${pageTitle}`;
|
||||||
|
|
||||||
@@ -184,7 +179,6 @@ export class CommentNotificationService {
|
|||||||
notification.id,
|
notification.id,
|
||||||
subject,
|
subject,
|
||||||
CommentResolvedEmail({ actorName: actor.name, pageTitle, pageUrl }),
|
CommentResolvedEmail({ actorName: actor.name, pageTitle, pageUrl }),
|
||||||
NotificationType.COMMENT_RESOLVED,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { RedisService } from '@nestjs-labs/nestjs-ioredis';
|
|
||||||
import type { Redis } from 'ioredis';
|
|
||||||
|
|
||||||
const KEY_PREFIX = 'page-update:emails:';
|
|
||||||
const DIGEST_PREFIX = 'page-update:digest:';
|
|
||||||
const TTL_SECONDS = 86400; // 24 hours
|
|
||||||
const MAX_IMMEDIATE_EMAILS = 4;
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class PageUpdateEmailRateLimiter {
|
|
||||||
private readonly redis: Redis;
|
|
||||||
|
|
||||||
constructor(private readonly redisService: RedisService) {
|
|
||||||
this.redis = this.redisService.getOrThrow();
|
|
||||||
}
|
|
||||||
|
|
||||||
async canSendEmail(userId: string): Promise<boolean> {
|
|
||||||
const key = KEY_PREFIX + userId;
|
|
||||||
const count = await this.redis.incr(key);
|
|
||||||
await this.redis.expire(key, TTL_SECONDS, 'NX');
|
|
||||||
return count <= MAX_IMMEDIATE_EMAILS;
|
|
||||||
}
|
|
||||||
|
|
||||||
async addToDigest(userId: string, notificationId: string): Promise<boolean> {
|
|
||||||
const key = DIGEST_PREFIX + userId;
|
|
||||||
const len = await this.redis.rpush(key, notificationId);
|
|
||||||
await this.redis.expire(key, TTL_SECONDS);
|
|
||||||
return len === 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
async popDigest(userId: string): Promise<string[]> {
|
|
||||||
const key = DIGEST_PREFIX + userId;
|
|
||||||
const [ids] = await this.redis
|
|
||||||
.multi()
|
|
||||||
.lrange(key, 0, -1)
|
|
||||||
.del(key)
|
|
||||||
.exec();
|
|
||||||
|
|
||||||
return (ids?.[1] as string[]) ?? [];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,43 +1,25 @@
|
|||||||
import { Injectable, Logger } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { InjectKysely } from 'nestjs-kysely';
|
import { InjectKysely } from 'nestjs-kysely';
|
||||||
import { InjectQueue } from '@nestjs/bullmq';
|
|
||||||
import { Queue } from 'bullmq';
|
|
||||||
import { KyselyDB } from '@docmost/db/types/kysely.types';
|
import { KyselyDB } from '@docmost/db/types/kysely.types';
|
||||||
import {
|
import {
|
||||||
IPageMentionNotificationJob,
|
IPageMentionNotificationJob,
|
||||||
IPageUpdateNotificationJob,
|
|
||||||
IPermissionGrantedNotificationJob,
|
IPermissionGrantedNotificationJob,
|
||||||
} from '../../../integrations/queue/constants/queue.interface';
|
} from '../../../integrations/queue/constants/queue.interface';
|
||||||
import { NotificationService } from '../notification.service';
|
import { NotificationService } from '../notification.service';
|
||||||
import { NotificationType } from '../notification.constants';
|
import { NotificationType } from '../notification.constants';
|
||||||
import { NotificationRepo } from '@docmost/db/repos/notification/notification.repo';
|
|
||||||
import { SpaceMemberRepo } from '@docmost/db/repos/space/space-member.repo';
|
import { SpaceMemberRepo } from '@docmost/db/repos/space/space-member.repo';
|
||||||
import { PagePermissionRepo } from '@docmost/db/repos/page/page-permission.repo';
|
import { PagePermissionRepo } from '@docmost/db/repos/page/page-permission.repo';
|
||||||
import { WatcherRepo } from '@docmost/db/repos/watcher/watcher.repo';
|
|
||||||
import { PageUpdateEmailRateLimiter } from './page-update-email-rate-limiter';
|
|
||||||
import { PageMentionEmail } from '@docmost/transactional/emails/page-mention-email';
|
import { PageMentionEmail } from '@docmost/transactional/emails/page-mention-email';
|
||||||
import { PageUpdateEmail } from '@docmost/transactional/emails/page-update-email';
|
|
||||||
import { PageUpdateDigestEmail } from '@docmost/transactional/emails/page-update-digest-email';
|
|
||||||
import { PermissionGrantedEmail } from '@docmost/transactional/emails/permission-granted-email';
|
import { PermissionGrantedEmail } from '@docmost/transactional/emails/permission-granted-email';
|
||||||
import { getPageTitle } from '../../../common/helpers';
|
import { getPageTitle } from '../../../common/helpers';
|
||||||
import { QueueJob, QueueName } from '../../../integrations/queue/constants';
|
|
||||||
|
|
||||||
const PAGE_UPDATE_COOLDOWN_HOURS = 7;
|
|
||||||
const DIGEST_DELAY_MS = 12 * 60 * 60 * 1000; // 12 hours
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PageNotificationService {
|
export class PageNotificationService {
|
||||||
private readonly logger = new Logger(PageNotificationService.name);
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@InjectKysely() private readonly db: KyselyDB,
|
@InjectKysely() private readonly db: KyselyDB,
|
||||||
private readonly notificationService: NotificationService,
|
private readonly notificationService: NotificationService,
|
||||||
private readonly notificationRepo: NotificationRepo,
|
|
||||||
private readonly spaceMemberRepo: SpaceMemberRepo,
|
private readonly spaceMemberRepo: SpaceMemberRepo,
|
||||||
private readonly pagePermissionRepo: PagePermissionRepo,
|
private readonly pagePermissionRepo: PagePermissionRepo,
|
||||||
private readonly watcherRepo: WatcherRepo,
|
|
||||||
private readonly rateLimiter: PageUpdateEmailRateLimiter,
|
|
||||||
@InjectQueue(QueueName.NOTIFICATION_QUEUE) private notificationQueue: Queue,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async processPageMention(data: IPageMentionNotificationJob, appUrl: string) {
|
async processPageMention(data: IPageMentionNotificationJob, appUrl: string) {
|
||||||
@@ -59,9 +41,10 @@ export class PageNotificationService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const usersWithPageAccess =
|
const usersWithPageAccess =
|
||||||
await this.pagePermissionRepo.getUserIdsWithPageAccess(pageId, [
|
await this.pagePermissionRepo.getUserIdsWithPageAccess(
|
||||||
...usersWithSpaceAccess,
|
pageId,
|
||||||
]);
|
[...usersWithSpaceAccess],
|
||||||
|
);
|
||||||
const usersWithAccess = new Set(usersWithPageAccess);
|
const usersWithAccess = new Set(usersWithPageAccess);
|
||||||
|
|
||||||
const accessibleMentions = newMentions.filter((m) =>
|
const accessibleMentions = newMentions.filter((m) =>
|
||||||
@@ -114,7 +97,6 @@ export class PageNotificationService {
|
|||||||
spaceId,
|
spaceId,
|
||||||
data: { mentionId },
|
data: { mentionId },
|
||||||
});
|
});
|
||||||
if (!notification) continue;
|
|
||||||
|
|
||||||
const pageUrl = `${basePageUrl}`;
|
const pageUrl = `${basePageUrl}`;
|
||||||
const subject = `${actor.name} mentioned you in ${pageTitle}`;
|
const subject = `${actor.name} mentioned you in ${pageTitle}`;
|
||||||
@@ -124,7 +106,6 @@ export class PageNotificationService {
|
|||||||
notification.id,
|
notification.id,
|
||||||
subject,
|
subject,
|
||||||
PageMentionEmail({ actorName: actor.name, pageTitle, pageUrl }),
|
PageMentionEmail({ actorName: actor.name, pageTitle, pageUrl }),
|
||||||
NotificationType.PAGE_USER_MENTION,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,7 +139,6 @@ export class PageNotificationService {
|
|||||||
spaceId,
|
spaceId,
|
||||||
data: { role },
|
data: { role },
|
||||||
});
|
});
|
||||||
if (!notification) continue;
|
|
||||||
|
|
||||||
const subject = `${actor.name} gave you ${accessLabel} access to ${pageTitle}`;
|
const subject = `${actor.name} gave you ${accessLabel} access to ${pageTitle}`;
|
||||||
|
|
||||||
@@ -176,232 +156,6 @@ export class PageNotificationService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async processPageUpdate(data: IPageUpdateNotificationJob, appUrl: string) {
|
|
||||||
const { pageId, spaceId, workspaceId, actorIds } = data;
|
|
||||||
|
|
||||||
const watcherIds = await this.watcherRepo.getPageWatcherIds(pageId);
|
|
||||||
if (watcherIds.length === 0) return;
|
|
||||||
|
|
||||||
const actorSet = new Set(actorIds);
|
|
||||||
const candidateIds = watcherIds.filter((id) => !actorSet.has(id));
|
|
||||||
if (candidateIds.length === 0) return;
|
|
||||||
|
|
||||||
const eligibleUsers = await this.getEligiblePageUpdateUsers(candidateIds);
|
|
||||||
if (eligibleUsers.size === 0) return;
|
|
||||||
|
|
||||||
const afterPrefs = [...eligibleUsers.keys()];
|
|
||||||
|
|
||||||
const recentlyNotified =
|
|
||||||
await this.notificationRepo.getRecentlyNotifiedUserIds(
|
|
||||||
afterPrefs,
|
|
||||||
pageId,
|
|
||||||
NotificationType.PAGE_UPDATED,
|
|
||||||
PAGE_UPDATE_COOLDOWN_HOURS,
|
|
||||||
);
|
|
||||||
const afterCooldown = afterPrefs.filter((id) => !recentlyNotified.has(id));
|
|
||||||
if (afterCooldown.length === 0) return;
|
|
||||||
|
|
||||||
const usersWithSpaceAccess =
|
|
||||||
await this.spaceMemberRepo.getUserIdsWithSpaceAccess(
|
|
||||||
afterCooldown,
|
|
||||||
spaceId,
|
|
||||||
);
|
|
||||||
|
|
||||||
const usersWithPageAccess =
|
|
||||||
await this.pagePermissionRepo.getUserIdsWithPageAccess(pageId, [
|
|
||||||
...usersWithSpaceAccess,
|
|
||||||
]);
|
|
||||||
if (usersWithPageAccess.length === 0) return;
|
|
||||||
|
|
||||||
const recipientIds = new Set(usersWithPageAccess);
|
|
||||||
const actorId = actorIds[0];
|
|
||||||
|
|
||||||
const context = await this.getPageContext(actorId, pageId, spaceId, appUrl);
|
|
||||||
if (!context) return;
|
|
||||||
|
|
||||||
const { actor, pageTitle, basePageUrl } = context;
|
|
||||||
|
|
||||||
for (const userId of recipientIds) {
|
|
||||||
const notification = await this.notificationService.create({
|
|
||||||
userId,
|
|
||||||
workspaceId,
|
|
||||||
type: NotificationType.PAGE_UPDATED,
|
|
||||||
actorId,
|
|
||||||
pageId,
|
|
||||||
spaceId,
|
|
||||||
});
|
|
||||||
if (!notification) continue;
|
|
||||||
|
|
||||||
const canSend = await this.rateLimiter.canSendEmail(userId);
|
|
||||||
if (canSend) {
|
|
||||||
await this.notificationService.queueEmail(
|
|
||||||
userId,
|
|
||||||
notification.id,
|
|
||||||
`${actor.name} updated ${pageTitle}`,
|
|
||||||
PageUpdateEmail({
|
|
||||||
userName: eligibleUsers.get(userId) ?? '',
|
|
||||||
actorName: actor.name,
|
|
||||||
pageTitle,
|
|
||||||
pageUrl: basePageUrl,
|
|
||||||
}),
|
|
||||||
NotificationType.PAGE_UPDATED,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
const isFirst = await this.rateLimiter.addToDigest(
|
|
||||||
userId,
|
|
||||||
notification.id,
|
|
||||||
);
|
|
||||||
if (isFirst) {
|
|
||||||
await this.scheduleDigest(userId, workspaceId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async getEligiblePageUpdateUsers(
|
|
||||||
userIds: string[],
|
|
||||||
): Promise<Map<string, string>> {
|
|
||||||
if (userIds.length === 0) return new Map();
|
|
||||||
|
|
||||||
const users = await this.db
|
|
||||||
.selectFrom('users')
|
|
||||||
.select(['id', 'name', 'settings'])
|
|
||||||
.where('id', 'in', userIds)
|
|
||||||
.where('deletedAt', 'is', null)
|
|
||||||
.where('deactivatedAt', 'is', null)
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
const eligible = new Map<string, string>();
|
|
||||||
for (const u of users) {
|
|
||||||
const settings = u.settings as any;
|
|
||||||
if (settings?.notifications?.['page.updated'] !== false) {
|
|
||||||
eligible.set(u.id, u.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return eligible;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async scheduleDigest(
|
|
||||||
userId: string,
|
|
||||||
workspaceId: string,
|
|
||||||
): Promise<void> {
|
|
||||||
await this.notificationQueue
|
|
||||||
.add(
|
|
||||||
QueueJob.PAGE_UPDATE_DIGEST,
|
|
||||||
{ userId, workspaceId },
|
|
||||||
{ delay: DIGEST_DELAY_MS, removeOnComplete: true },
|
|
||||||
)
|
|
||||||
.catch((err) => {
|
|
||||||
this.logger.error(
|
|
||||||
`Failed to schedule digest for ${userId}: ${err.message}`,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async processDigest(userId: string, appUrl: string): Promise<void> {
|
|
||||||
const notificationIds = await this.rateLimiter.popDigest(userId);
|
|
||||||
if (notificationIds.length === 0) return;
|
|
||||||
|
|
||||||
const [user, notifications] = await Promise.all([
|
|
||||||
this.db
|
|
||||||
.selectFrom('users')
|
|
||||||
.select(['id', 'name'])
|
|
||||||
.where('id', '=', userId)
|
|
||||||
.executeTakeFirst(),
|
|
||||||
this.db
|
|
||||||
.selectFrom('notifications')
|
|
||||||
.select(['id', 'pageId', 'actorId'])
|
|
||||||
.where('id', 'in', notificationIds)
|
|
||||||
.execute(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (!user || notifications.length === 0) return;
|
|
||||||
|
|
||||||
const pageIds = [
|
|
||||||
...new Set(notifications.map((n) => n.pageId).filter(Boolean)),
|
|
||||||
];
|
|
||||||
const actorIds = [
|
|
||||||
...new Set(notifications.map((n) => n.actorId).filter(Boolean)),
|
|
||||||
];
|
|
||||||
|
|
||||||
const allPages = await this.db
|
|
||||||
.selectFrom('pages')
|
|
||||||
.innerJoin('spaces', 'spaces.id', 'pages.spaceId')
|
|
||||||
.select([
|
|
||||||
'pages.id',
|
|
||||||
'pages.title',
|
|
||||||
'pages.slugId',
|
|
||||||
'pages.spaceId',
|
|
||||||
'spaces.slug as spaceSlug',
|
|
||||||
])
|
|
||||||
.where('pages.id', 'in', pageIds)
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
if (allPages.length === 0) return;
|
|
||||||
|
|
||||||
const spaceIds = [...new Set(allPages.map((p) => p.spaceId))];
|
|
||||||
|
|
||||||
const accessibleSpaceIds = new Set<string>();
|
|
||||||
for (const spaceId of spaceIds) {
|
|
||||||
const usersWithAccess =
|
|
||||||
await this.spaceMemberRepo.getUserIdsWithSpaceAccess([userId], spaceId);
|
|
||||||
if (usersWithAccess.has(userId)) accessibleSpaceIds.add(spaceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
const spaceFilteredPages = allPages.filter((p) =>
|
|
||||||
accessibleSpaceIds.has(p.spaceId),
|
|
||||||
);
|
|
||||||
if (spaceFilteredPages.length === 0) return;
|
|
||||||
|
|
||||||
const accessiblePageIds = new Set<string>();
|
|
||||||
for (const p of spaceFilteredPages) {
|
|
||||||
const hasAccess = await this.pagePermissionRepo.getUserIdsWithPageAccess(
|
|
||||||
p.id,
|
|
||||||
[userId],
|
|
||||||
);
|
|
||||||
if (hasAccess.includes(userId)) accessiblePageIds.add(p.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
const pages = spaceFilteredPages.filter((p) => accessiblePageIds.has(p.id));
|
|
||||||
if (pages.length === 0) return;
|
|
||||||
|
|
||||||
const actors = actorIds.length > 0
|
|
||||||
? await this.db
|
|
||||||
.selectFrom('users')
|
|
||||||
.select(['id', 'name'])
|
|
||||||
.where('id', 'in', actorIds)
|
|
||||||
.execute()
|
|
||||||
: [];
|
|
||||||
|
|
||||||
const actorMap = new Map(actors.map((a) => [a.id, a.name]));
|
|
||||||
const pageActors = new Map<string, Set<string>>();
|
|
||||||
for (const n of notifications) {
|
|
||||||
if (!n.pageId || !n.actorId) continue;
|
|
||||||
const names = pageActors.get(n.pageId) ?? new Set();
|
|
||||||
const name = actorMap.get(n.actorId);
|
|
||||||
if (name) names.add(name);
|
|
||||||
pageActors.set(n.pageId, names);
|
|
||||||
}
|
|
||||||
|
|
||||||
const pageUpdates = pages.map((p) => ({
|
|
||||||
title: getPageTitle(p.title),
|
|
||||||
url: `${appUrl}/s/${p.spaceSlug}/p/${p.slugId}`,
|
|
||||||
updatedBy: [...(pageActors.get(p.id) ?? [])],
|
|
||||||
}));
|
|
||||||
|
|
||||||
await this.notificationService.queueEmail(
|
|
||||||
userId,
|
|
||||||
notificationIds[0],
|
|
||||||
`Your digest: ${pageUpdates.length} page ${pageUpdates.length === 1 ? 'update' : 'updates'}`,
|
|
||||||
PageUpdateDigestEmail({
|
|
||||||
userName: user.name,
|
|
||||||
pageUpdates,
|
|
||||||
totalUpdates: pageUpdates.length,
|
|
||||||
}),
|
|
||||||
NotificationType.PAGE_UPDATED,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async getPageContext(
|
private async getPageContext(
|
||||||
actorId: string,
|
actorId: string,
|
||||||
pageId: string,
|
pageId: string,
|
||||||
|
|||||||
@@ -35,24 +35,4 @@ export class UpdateUserDto extends PartialType(
|
|||||||
@MaxLength(70)
|
@MaxLength(70)
|
||||||
@IsString()
|
@IsString()
|
||||||
confirmPassword: string;
|
confirmPassword: string;
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsBoolean()
|
|
||||||
notificationPageUpdates: boolean;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsBoolean()
|
|
||||||
notificationPageUserMention: boolean;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsBoolean()
|
|
||||||
notificationCommentUserMention: boolean;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsBoolean()
|
|
||||||
notificationCommentCreated: boolean;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsBoolean()
|
|
||||||
notificationCommentResolved: boolean;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import {
|
|||||||
UnauthorizedException,
|
UnauthorizedException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { UpdateUserDto } from './dto/update-user.dto';
|
import { UpdateUserDto } from './dto/update-user.dto';
|
||||||
import { NotificationSettingKey } from '../notification/notification.constants';
|
|
||||||
import { comparePasswordHash, diffAuditTrackedFields } from 'src/common/helpers/utils';
|
import { comparePasswordHash, diffAuditTrackedFields } from 'src/common/helpers/utils';
|
||||||
import { Workspace } from '@docmost/db/types/entity.types';
|
import { Workspace } from '@docmost/db/types/entity.types';
|
||||||
import { validateSsoEnforcement } from '../auth/auth.util';
|
import { validateSsoEnforcement } from '../auth/auth.util';
|
||||||
@@ -61,24 +60,6 @@ export class UserService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const notificationSettings: Record<string, NotificationSettingKey> = {
|
|
||||||
notificationPageUpdates: 'page.updated',
|
|
||||||
notificationPageUserMention: 'page.userMention',
|
|
||||||
notificationCommentUserMention: 'comment.userMention',
|
|
||||||
notificationCommentCreated: 'comment.created',
|
|
||||||
notificationCommentResolved: 'comment.resolved',
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const [dtoField, settingKey] of Object.entries(notificationSettings)) {
|
|
||||||
if (typeof updateUserDto[dtoField] !== 'undefined') {
|
|
||||||
return this.userRepo.updateNotificationSetting(
|
|
||||||
userId,
|
|
||||||
settingKey,
|
|
||||||
updateUserDto[dtoField],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const userBefore = { name: user.name, email: user.email, locale: user.locale };
|
const userBefore = { name: user.name, email: user.email, locale: user.locale };
|
||||||
|
|
||||||
if (updateUserDto.name) {
|
if (updateUserDto.name) {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import {
|
/***
|
||||||
|
import {
|
||||||
Body,
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
|
ForbiddenException,
|
||||||
HttpCode,
|
HttpCode,
|
||||||
HttpStatus,
|
HttpStatus,
|
||||||
NotFoundException,
|
NotFoundException,
|
||||||
@@ -14,7 +16,12 @@ import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
|
|||||||
import { User, Workspace } from '@docmost/db/types/entity.types';
|
import { User, Workspace } from '@docmost/db/types/entity.types';
|
||||||
import { WatcherPageDto } from './dto/watcher.dto';
|
import { WatcherPageDto } from './dto/watcher.dto';
|
||||||
import { PageRepo } from '@docmost/db/repos/page/page.repo';
|
import { PageRepo } from '@docmost/db/repos/page/page.repo';
|
||||||
import { PageAccessService } from '../page/page-access/page-access.service';
|
import SpaceAbilityFactory from '../casl/abilities/space-ability.factory';
|
||||||
|
import {
|
||||||
|
SpaceCaslAction,
|
||||||
|
SpaceCaslSubject,
|
||||||
|
} from '../casl/interfaces/space-ability.type';
|
||||||
|
|
||||||
|
|
||||||
@UseGuards(JwtAuthGuard)
|
@UseGuards(JwtAuthGuard)
|
||||||
@Controller('pages')
|
@Controller('pages')
|
||||||
@@ -22,7 +29,7 @@ export class WatcherController {
|
|||||||
constructor(
|
constructor(
|
||||||
private readonly watcherService: WatcherService,
|
private readonly watcherService: WatcherService,
|
||||||
private readonly pageRepo: PageRepo,
|
private readonly pageRepo: PageRepo,
|
||||||
private readonly pageAccessService: PageAccessService,
|
private readonly spaceAbility: SpaceAbilityFactory,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
@@ -37,7 +44,10 @@ export class WatcherController {
|
|||||||
throw new NotFoundException('Page not found');
|
throw new NotFoundException('Page not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.pageAccessService.validateCanView(page, user);
|
const ability = await this.spaceAbility.createForUser(user, page.spaceId);
|
||||||
|
if (ability.cannot(SpaceCaslAction.Read, SpaceCaslSubject.Page)) {
|
||||||
|
throw new ForbiddenException();
|
||||||
|
}
|
||||||
|
|
||||||
await this.watcherService.watchPage(
|
await this.watcherService.watchPage(
|
||||||
user.id,
|
user.id,
|
||||||
@@ -57,7 +67,10 @@ export class WatcherController {
|
|||||||
throw new NotFoundException('Page not found');
|
throw new NotFoundException('Page not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.pageAccessService.validateCanView(page, user);
|
const ability = await this.spaceAbility.createForUser(user, page.spaceId);
|
||||||
|
if (ability.cannot(SpaceCaslAction.Read, SpaceCaslSubject.Page)) {
|
||||||
|
throw new ForbiddenException();
|
||||||
|
}
|
||||||
|
|
||||||
await this.watcherService.unwatchPage(user.id, page.id);
|
await this.watcherService.unwatchPage(user.id, page.id);
|
||||||
|
|
||||||
@@ -72,10 +85,15 @@ export class WatcherController {
|
|||||||
throw new NotFoundException('Page not found');
|
throw new NotFoundException('Page not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.pageAccessService.validateCanView(page, user);
|
const ability = await this.spaceAbility.createForUser(user, page.spaceId);
|
||||||
|
if (ability.cannot(SpaceCaslAction.Read, SpaceCaslSubject.Page)) {
|
||||||
|
throw new ForbiddenException();
|
||||||
|
}
|
||||||
|
|
||||||
const watching = await this.watcherService.isWatchingPage(user.id, page.id);
|
const watching = await this.watcherService.isWatchingPage(user.id, page.id);
|
||||||
|
|
||||||
return { watching };
|
return { watching };
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
***/
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { WatcherService } from './watcher.service';
|
import { WatcherService } from './watcher.service';
|
||||||
import { WatcherController } from './watcher.controller';
|
import { CaslModule } from '../casl/casl.module';
|
||||||
import { PageAccessModule } from '../page/page-access/page-access.module';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [PageAccessModule],
|
imports: [CaslModule],
|
||||||
controllers: [WatcherController],
|
controllers: [],
|
||||||
providers: [WatcherService],
|
providers: [WatcherService],
|
||||||
exports: [WatcherService],
|
exports: [WatcherService],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,333 +0,0 @@
|
|||||||
import { type Kysely, sql } from 'kysely';
|
|
||||||
|
|
||||||
export async function up(db: Kysely<any>): Promise<void> {
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_group_users_user_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('group_users')
|
|
||||||
.column('user_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_space_members_user_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('space_members')
|
|
||||||
.column('user_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_space_members_group_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('space_members')
|
|
||||||
.column('group_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
// Page tree
|
|
||||||
await sql`
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_pages_space_parent_position
|
|
||||||
ON pages (space_id, parent_page_id, position COLLATE "C")
|
|
||||||
WHERE deleted_at IS NULL
|
|
||||||
`.execute(db);
|
|
||||||
|
|
||||||
await sql`
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_pages_parent_page_id
|
|
||||||
ON pages (parent_page_id)
|
|
||||||
WHERE deleted_at IS NULL
|
|
||||||
`.execute(db);
|
|
||||||
|
|
||||||
// Recent pages query
|
|
||||||
await sql`
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_pages_space_updated
|
|
||||||
ON pages (space_id, updated_at DESC)
|
|
||||||
WHERE deleted_at IS NULL
|
|
||||||
`.execute(db);
|
|
||||||
|
|
||||||
// Trash view
|
|
||||||
await sql`
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_pages_space_deleted
|
|
||||||
ON pages (space_id, deleted_at DESC)
|
|
||||||
WHERE deleted_at IS NOT NULL
|
|
||||||
`.execute(db);
|
|
||||||
|
|
||||||
await sql`
|
|
||||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_workspaces_hostname_lower
|
|
||||||
ON workspaces (LOWER(hostname))
|
|
||||||
`.execute(db);
|
|
||||||
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_workspaces_created_at')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('workspaces')
|
|
||||||
.column('created_at')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_users_workspace_deleted')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('users')
|
|
||||||
.columns(['workspace_id', 'deleted_at'])
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
await sql`
|
|
||||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_spaces_slug_lower_workspace
|
|
||||||
ON spaces (LOWER(slug), workspace_id)
|
|
||||||
`.execute(db);
|
|
||||||
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_spaces_workspace_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('spaces')
|
|
||||||
.column('workspace_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
await sql`
|
|
||||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_groups_name_lower_workspace
|
|
||||||
ON groups (LOWER(name), workspace_id)
|
|
||||||
`.execute(db);
|
|
||||||
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_groups_workspace_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('groups')
|
|
||||||
.column('workspace_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_shares_page_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('shares')
|
|
||||||
.column('page_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_attachments_page_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('attachments')
|
|
||||||
.column('page_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_attachments_space_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('attachments')
|
|
||||||
.column('space_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_comments_page_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('comments')
|
|
||||||
.column('page_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_comments_parent_comment_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('comments')
|
|
||||||
.column('parent_comment_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
await sql`
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_page_history_page_created
|
|
||||||
ON page_history (page_id, created_at DESC)
|
|
||||||
`.execute(db);
|
|
||||||
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_attachments_workspace_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('attachments')
|
|
||||||
.column('workspace_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_backlinks_target_page_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('backlinks')
|
|
||||||
.column('target_page_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_pages_workspace_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('pages')
|
|
||||||
.column('workspace_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_pages_creator_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('pages')
|
|
||||||
.column('creator_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
// Notifications: FK cascade from pages, spaces, comments
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_notifications_page_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('notifications')
|
|
||||||
.column('page_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_notifications_space_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('notifications')
|
|
||||||
.column('space_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_notifications_comment_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('notifications')
|
|
||||||
.column('comment_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
// Watchers: cleanup queries and FK cascade
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_watchers_user_workspace')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('watchers')
|
|
||||||
.columns(['user_id', 'workspace_id'])
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_watchers_space_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('watchers')
|
|
||||||
.column('space_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
// Auth providers: all queries filter by workspaceId
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_auth_providers_workspace_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('auth_providers')
|
|
||||||
.column('workspace_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
// Auth accounts: SSO login lookup by provider user
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_auth_accounts_provider_user_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('auth_accounts')
|
|
||||||
.columns(['provider_user_id', 'auth_provider_id'])
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
// Workspace invitations: listing and SSO lookup
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_workspace_invitations_workspace_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('workspace_invitations')
|
|
||||||
.column('workspace_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
// API keys: query and FK cascade
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_api_keys_workspace_id')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('api_keys')
|
|
||||||
.column('workspace_id')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
// User sessions: delete queries and FK cascade on all session states
|
|
||||||
await db.schema
|
|
||||||
.createIndex('idx_user_sessions_user_workspace')
|
|
||||||
.ifNotExists()
|
|
||||||
.on('user_sessions')
|
|
||||||
.columns(['user_id', 'workspace_id'])
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function down(db: Kysely<any>): Promise<void> {
|
|
||||||
await db.schema.dropIndex('idx_group_users_user_id').ifExists().execute();
|
|
||||||
await db.schema.dropIndex('idx_space_members_user_id').ifExists().execute();
|
|
||||||
await db.schema.dropIndex('idx_space_members_group_id').ifExists().execute();
|
|
||||||
await db.schema
|
|
||||||
.dropIndex('idx_pages_space_parent_position')
|
|
||||||
.ifExists()
|
|
||||||
.execute();
|
|
||||||
await db.schema.dropIndex('idx_pages_parent_page_id').ifExists().execute();
|
|
||||||
await db.schema.dropIndex('idx_pages_space_updated').ifExists().execute();
|
|
||||||
await db.schema.dropIndex('idx_pages_space_deleted').ifExists().execute();
|
|
||||||
await db.schema
|
|
||||||
.dropIndex('idx_workspaces_hostname_lower')
|
|
||||||
.ifExists()
|
|
||||||
.execute();
|
|
||||||
await db.schema.dropIndex('idx_workspaces_created_at').ifExists().execute();
|
|
||||||
await db.schema
|
|
||||||
.dropIndex('idx_users_workspace_deleted')
|
|
||||||
.ifExists()
|
|
||||||
.execute();
|
|
||||||
await db.schema
|
|
||||||
.dropIndex('idx_spaces_slug_lower_workspace')
|
|
||||||
.ifExists()
|
|
||||||
.execute();
|
|
||||||
await db.schema
|
|
||||||
.dropIndex('idx_spaces_workspace_id')
|
|
||||||
.ifExists()
|
|
||||||
.execute();
|
|
||||||
await db.schema
|
|
||||||
.dropIndex('idx_groups_name_lower_workspace')
|
|
||||||
.ifExists()
|
|
||||||
.execute();
|
|
||||||
await db.schema.dropIndex('idx_groups_workspace_id').ifExists().execute();
|
|
||||||
await db.schema.dropIndex('idx_shares_page_id').ifExists().execute();
|
|
||||||
await db.schema.dropIndex('idx_attachments_page_id').ifExists().execute();
|
|
||||||
await db.schema.dropIndex('idx_attachments_space_id').ifExists().execute();
|
|
||||||
await db.schema.dropIndex('idx_comments_page_id').ifExists().execute();
|
|
||||||
await db.schema
|
|
||||||
.dropIndex('idx_comments_parent_comment_id')
|
|
||||||
.ifExists()
|
|
||||||
.execute();
|
|
||||||
await db.schema
|
|
||||||
.dropIndex('idx_page_history_page_created')
|
|
||||||
.ifExists()
|
|
||||||
.execute();
|
|
||||||
await db.schema
|
|
||||||
.dropIndex('idx_attachments_workspace_id')
|
|
||||||
.ifExists()
|
|
||||||
.execute();
|
|
||||||
await db.schema
|
|
||||||
.dropIndex('idx_backlinks_target_page_id')
|
|
||||||
.ifExists()
|
|
||||||
.execute();
|
|
||||||
await db.schema.dropIndex('idx_pages_workspace_id').ifExists().execute();
|
|
||||||
await db.schema.dropIndex('idx_pages_creator_id').ifExists().execute();
|
|
||||||
await db.schema
|
|
||||||
.dropIndex('idx_notifications_page_id')
|
|
||||||
.ifExists()
|
|
||||||
.execute();
|
|
||||||
await db.schema
|
|
||||||
.dropIndex('idx_notifications_space_id')
|
|
||||||
.ifExists()
|
|
||||||
.execute();
|
|
||||||
await db.schema
|
|
||||||
.dropIndex('idx_notifications_comment_id')
|
|
||||||
.ifExists()
|
|
||||||
.execute();
|
|
||||||
await db.schema
|
|
||||||
.dropIndex('idx_watchers_user_workspace')
|
|
||||||
.ifExists()
|
|
||||||
.execute();
|
|
||||||
await db.schema.dropIndex('idx_watchers_space_id').ifExists().execute();
|
|
||||||
await db.schema
|
|
||||||
.dropIndex('idx_auth_providers_workspace_id')
|
|
||||||
.ifExists()
|
|
||||||
.execute();
|
|
||||||
await db.schema
|
|
||||||
.dropIndex('idx_auth_accounts_provider_user_id')
|
|
||||||
.ifExists()
|
|
||||||
.execute();
|
|
||||||
await db.schema
|
|
||||||
.dropIndex('idx_workspace_invitations_workspace_id')
|
|
||||||
.ifExists()
|
|
||||||
.execute();
|
|
||||||
await db.schema
|
|
||||||
.dropIndex('idx_api_keys_workspace_id')
|
|
||||||
.ifExists()
|
|
||||||
.execute();
|
|
||||||
await db.schema
|
|
||||||
.dropIndex('idx_user_sessions_user_workspace')
|
|
||||||
.ifExists()
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
@@ -11,7 +11,6 @@ import { ExpressionBuilder } from 'kysely';
|
|||||||
import { DB } from '@docmost/db/types/db';
|
import { DB } from '@docmost/db/types/db';
|
||||||
import { jsonObjectFrom } from 'kysely/helpers/postgres';
|
import { jsonObjectFrom } from 'kysely/helpers/postgres';
|
||||||
import { SpaceMemberRepo } from '@docmost/db/repos/space/space-member.repo';
|
import { SpaceMemberRepo } from '@docmost/db/repos/space/space-member.repo';
|
||||||
import { NotificationTab, NotificationType } from '../../../core/notification/notification.constants';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class NotificationRepo {
|
export class NotificationRepo {
|
||||||
@@ -28,12 +27,8 @@ export class NotificationRepo {
|
|||||||
.executeTakeFirst();
|
.executeTakeFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
async findByUserId(
|
async findByUserId(userId: string, pagination: PaginationOptions) {
|
||||||
userId: string,
|
const query = this.db
|
||||||
pagination: PaginationOptions,
|
|
||||||
type: NotificationTab = 'all',
|
|
||||||
) {
|
|
||||||
let query = this.db
|
|
||||||
.selectFrom('notifications')
|
.selectFrom('notifications')
|
||||||
.selectAll('notifications')
|
.selectAll('notifications')
|
||||||
.select((eb) => this.withActor(eb))
|
.select((eb) => this.withActor(eb))
|
||||||
@@ -47,12 +42,6 @@ export class NotificationRepo {
|
|||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (type === 'direct') {
|
|
||||||
query = query.where('type', '!=', NotificationType.PAGE_UPDATED);
|
|
||||||
} else if (type === 'updates') {
|
|
||||||
query = query.where('type', '=', NotificationType.PAGE_UPDATED);
|
|
||||||
}
|
|
||||||
|
|
||||||
return executeWithCursorPagination(query, {
|
return executeWithCursorPagination(query, {
|
||||||
perPage: pagination.limit,
|
perPage: pagination.limit,
|
||||||
cursor: pagination.cursor,
|
cursor: pagination.cursor,
|
||||||
@@ -149,29 +138,6 @@ export class NotificationRepo {
|
|||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getRecentlyNotifiedUserIds(
|
|
||||||
userIds: string[],
|
|
||||||
pageId: string,
|
|
||||||
type: string,
|
|
||||||
withinHours: number,
|
|
||||||
): Promise<Set<string>> {
|
|
||||||
if (userIds.length === 0) return new Set();
|
|
||||||
|
|
||||||
const cutoff = new Date(Date.now() - withinHours * 60 * 60 * 1000);
|
|
||||||
|
|
||||||
const rows = await this.db
|
|
||||||
.selectFrom('notifications')
|
|
||||||
.select('userId')
|
|
||||||
.where('userId', 'in', userIds)
|
|
||||||
.where('pageId', '=', pageId)
|
|
||||||
.where('type', '=', type)
|
|
||||||
.where('createdAt', '>', cutoff)
|
|
||||||
.groupBy('userId')
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
return new Set(rows.map((r) => r.userId));
|
|
||||||
}
|
|
||||||
|
|
||||||
withActor(eb: ExpressionBuilder<DB, 'notifications'>) {
|
withActor(eb: ExpressionBuilder<DB, 'notifications'>) {
|
||||||
return jsonObjectFrom(
|
return jsonObjectFrom(
|
||||||
eb
|
eb
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import { PaginationOptions } from '../../pagination/pagination-options';
|
|||||||
import { executeWithCursorPagination } from '@docmost/db/pagination/cursor-pagination';
|
import { executeWithCursorPagination } from '@docmost/db/pagination/cursor-pagination';
|
||||||
import { ExpressionBuilder, sql } from 'kysely';
|
import { ExpressionBuilder, sql } from 'kysely';
|
||||||
import { jsonObjectFrom } from 'kysely/helpers/postgres';
|
import { jsonObjectFrom } from 'kysely/helpers/postgres';
|
||||||
import { NotificationSettingKey } from '../../../core/notification/notification.constants';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserRepo {
|
export class UserRepo {
|
||||||
@@ -192,24 +191,6 @@ export class UserRepo {
|
|||||||
.executeTakeFirst();
|
.executeTakeFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateNotificationSetting(
|
|
||||||
userId: string,
|
|
||||||
settingKey: NotificationSettingKey,
|
|
||||||
settingValue: boolean,
|
|
||||||
) {
|
|
||||||
return await this.db
|
|
||||||
.updateTable('users')
|
|
||||||
.set({
|
|
||||||
settings: sql`COALESCE(settings, '{}'::jsonb)
|
|
||||||
|| jsonb_build_object('notifications', COALESCE(settings->'notifications', '{}'::jsonb)
|
|
||||||
|| jsonb_build_object(${sql.lit(settingKey)}, ${sql.lit(settingValue)}))`,
|
|
||||||
updatedAt: new Date(),
|
|
||||||
})
|
|
||||||
.where('id', '=', userId)
|
|
||||||
.returning(this.baseFields)
|
|
||||||
.executeTakeFirst();
|
|
||||||
}
|
|
||||||
|
|
||||||
withUserMfa(eb: ExpressionBuilder<DB, 'users'>) {
|
withUserMfa(eb: ExpressionBuilder<DB, 'users'>) {
|
||||||
return jsonObjectFrom(
|
return jsonObjectFrom(
|
||||||
eb
|
eb
|
||||||
|
|||||||
+1
-1
Submodule apps/server/src/ee updated: 670b9458f3...f486726088
@@ -259,12 +259,6 @@ export class EnvironmentService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAiEmbeddingSupportsMrl(): boolean | undefined {
|
|
||||||
const val = this.configService.get<string>('AI_EMBEDDING_SUPPORTS_MRL');
|
|
||||||
if (val === undefined || val === null || val === '') return undefined;
|
|
||||||
return val === 'true';
|
|
||||||
}
|
|
||||||
|
|
||||||
getOpenAiApiKey(): string {
|
getOpenAiApiKey(): string {
|
||||||
return this.configService.get<string>('OPENAI_API_KEY');
|
return this.configService.get<string>('OPENAI_API_KEY');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,12 +117,6 @@ export class EnvironmentVariables {
|
|||||||
@IsString()
|
@IsString()
|
||||||
AI_EMBEDDING_DIMENSION: string;
|
AI_EMBEDDING_DIMENSION: string;
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@ValidateIf((obj) => obj.AI_EMBEDDING_SUPPORTS_MRL)
|
|
||||||
@IsIn(['true', 'false'])
|
|
||||||
@IsString()
|
|
||||||
AI_EMBEDDING_SUPPORTS_MRL: string;
|
|
||||||
|
|
||||||
@ValidateIf((obj) => obj.AI_DRIVER)
|
@ValidateIf((obj) => obj.AI_DRIVER)
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
|
|||||||
@@ -193,8 +193,6 @@ export class ImportAttachmentService {
|
|||||||
// Build a map from resolved archive path → real filename from Confluence
|
// Build a map from resolved archive path → real filename from Confluence
|
||||||
// metadata. Confluence Server archives often store files under numeric IDs
|
// metadata. Confluence Server archives often store files under numeric IDs
|
||||||
// (e.g. "attachments/65601/65602") instead of the original filename.
|
// (e.g. "attachments/65601/65602") instead of the original filename.
|
||||||
// Also register aliases so HTML references using the original filename
|
|
||||||
// (e.g. "attachments/pageId/original.mp3") resolve to the numeric path.
|
|
||||||
const pageDir = path.dirname(pageRelativePath);
|
const pageDir = path.dirname(pageRelativePath);
|
||||||
const attachmentNameByRelPath = new Map<string, string>();
|
const attachmentNameByRelPath = new Map<string, string>();
|
||||||
for (const attachment of pageAttachments) {
|
for (const attachment of pageAttachments) {
|
||||||
@@ -205,13 +203,6 @@ export class ImportAttachmentService {
|
|||||||
);
|
);
|
||||||
if (relPath && attachment.fileName) {
|
if (relPath && attachment.fileName) {
|
||||||
attachmentNameByRelPath.set(relPath, attachment.fileName);
|
attachmentNameByRelPath.set(relPath, attachment.fileName);
|
||||||
|
|
||||||
const dir = path.posix.dirname(relPath);
|
|
||||||
const aliasKey = `${dir}/${attachment.fileName}`;
|
|
||||||
if (!attachmentCandidates.has(aliasKey)) {
|
|
||||||
attachmentCandidates.set(aliasKey, attachmentCandidates.get(relPath)!);
|
|
||||||
attachmentNameByRelPath.set(aliasKey, attachment.fileName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -571,31 +562,18 @@ export class ImportAttachmentService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve the metadata href to the actual archive path
|
// Check if already processed (was referenced in HTML)
|
||||||
const resolvedHref = resolveRelativeAttachmentPath(
|
if (processed.has(href)) {
|
||||||
href,
|
continue;
|
||||||
pageDir,
|
}
|
||||||
attachmentCandidates,
|
|
||||||
);
|
|
||||||
if (!resolvedHref) continue;
|
|
||||||
|
|
||||||
// Check if already processed (was referenced in HTML).
|
// Skip if the file doesn't exist
|
||||||
// Inline elements may have been processed under an alias key (original
|
if (!attachmentCandidates.has(href)) {
|
||||||
// filename) rather than the numeric archive path, so also check whether
|
|
||||||
// the underlying absolute file path has already been uploaded.
|
|
||||||
const absPath = attachmentCandidates.get(resolvedHref);
|
|
||||||
const alreadyProcessed =
|
|
||||||
processed.has(resolvedHref) ||
|
|
||||||
(absPath &&
|
|
||||||
Array.from(processed.values()).some(
|
|
||||||
(entry) => entry.abs === absPath,
|
|
||||||
));
|
|
||||||
if (alreadyProcessed) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This attachment was in the list but not referenced in HTML - add it
|
// This attachment was in the list but not referenced in HTML - add it
|
||||||
const { attachmentId, apiFilePath, abs } = processFile(resolvedHref);
|
const { attachmentId, apiFilePath, abs } = processFile(href);
|
||||||
const mime = mimeType || getMimeType(abs);
|
const mime = mimeType || getMimeType(abs);
|
||||||
|
|
||||||
// Add as attachment node at the end
|
// Add as attachment node at the end
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ export enum QueueJob {
|
|||||||
COMMENT_RESOLVED_NOTIFICATION = 'comment-resolved-notification',
|
COMMENT_RESOLVED_NOTIFICATION = 'comment-resolved-notification',
|
||||||
PAGE_MENTION_NOTIFICATION = 'page-mention-notification',
|
PAGE_MENTION_NOTIFICATION = 'page-mention-notification',
|
||||||
PAGE_PERMISSION_GRANTED = 'page-permission-granted',
|
PAGE_PERMISSION_GRANTED = 'page-permission-granted',
|
||||||
PAGE_UPDATE_DIGEST = 'page-update-digest',
|
|
||||||
|
|
||||||
AUDIT_LOG = 'audit-log',
|
AUDIT_LOG = 'audit-log',
|
||||||
AUDIT_CLEANUP = 'audit-cleanup',
|
AUDIT_CLEANUP = 'audit-cleanup',
|
||||||
|
|||||||
@@ -60,13 +60,6 @@ export interface IPageMentionNotificationJob {
|
|||||||
workspaceId: string;
|
workspaceId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPageUpdateNotificationJob {
|
|
||||||
pageId: string;
|
|
||||||
spaceId: string;
|
|
||||||
workspaceId: string;
|
|
||||||
actorIds: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IPermissionGrantedNotificationJob {
|
export interface IPermissionGrantedNotificationJob {
|
||||||
userIds: string[];
|
userIds: string[];
|
||||||
pageId: string;
|
pageId: string;
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
import { Module } from '@nestjs/common';
|
|
||||||
import { ThrottlerModule } from '@nestjs/throttler';
|
|
||||||
import { ThrottlerStorageRedisService } from '@nest-lab/throttler-storage-redis';
|
|
||||||
import { EnvironmentService } from '../environment/environment.service';
|
|
||||||
import { EnvironmentModule } from '../environment/environment.module';
|
|
||||||
import { parseRedisUrl } from '../../common/helpers';
|
|
||||||
import Redis from 'ioredis';
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
imports: [
|
|
||||||
ThrottlerModule.forRootAsync({
|
|
||||||
imports: [EnvironmentModule],
|
|
||||||
useFactory: (environmentService: EnvironmentService) => {
|
|
||||||
const redisConfig = parseRedisUrl(environmentService.getRedisUrl());
|
|
||||||
|
|
||||||
return {
|
|
||||||
throttlers: [{ name: 'auth', ttl: 60_000, limit: 10 }],
|
|
||||||
errorMessage: 'Too many requests',
|
|
||||||
storage: new ThrottlerStorageRedisService(
|
|
||||||
new Redis({
|
|
||||||
host: redisConfig.host,
|
|
||||||
port: redisConfig.port,
|
|
||||||
password: redisConfig.password,
|
|
||||||
db: redisConfig.db,
|
|
||||||
family: redisConfig.family,
|
|
||||||
keyPrefix: 'throttle:',
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
inject: [EnvironmentService],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
})
|
|
||||||
export class ThrottleModule {}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
import { Link, Section, Text } from '@react-email/components';
|
|
||||||
import * as React from 'react';
|
|
||||||
import { content, link, paragraph } from '../css/styles';
|
|
||||||
import { getGreetingName, MailBody } from '../partials/partials';
|
|
||||||
|
|
||||||
interface PageUpdate {
|
|
||||||
title: string;
|
|
||||||
url: string;
|
|
||||||
updatedBy: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
userName: string;
|
|
||||||
pageUpdates: PageUpdate[];
|
|
||||||
totalUpdates: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const PageUpdateDigestEmail = ({
|
|
||||||
userName,
|
|
||||||
pageUpdates,
|
|
||||||
totalUpdates,
|
|
||||||
}: Props) => {
|
|
||||||
return (
|
|
||||||
<MailBody>
|
|
||||||
<Section style={content}>
|
|
||||||
<Text style={paragraph}>
|
|
||||||
Hi {getGreetingName(userName)},
|
|
||||||
</Text>
|
|
||||||
<Text style={paragraph}>
|
|
||||||
There {totalUpdates === 1 ? 'has' : 'have'} been{' '}
|
|
||||||
<strong>
|
|
||||||
{totalUpdates} update{totalUpdates === 1 ? '' : 's'}
|
|
||||||
</strong>{' '}
|
|
||||||
since your last update.
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
{pageUpdates.map((page, i) => (
|
|
||||||
<Section key={i} style={pageCard}>
|
|
||||||
<Text style={pageTitle}>
|
|
||||||
<Link href={page.url} style={link}>
|
|
||||||
{page.title}
|
|
||||||
</Link>
|
|
||||||
</Text>
|
|
||||||
{page.updatedBy.length > 0 && (
|
|
||||||
<Text style={updatedByText}>
|
|
||||||
Edited by {page.updatedBy.join(', ')}
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
</Section>
|
|
||||||
))}
|
|
||||||
</Section>
|
|
||||||
</MailBody>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const pageCard = {
|
|
||||||
borderLeft: '3px solid #e8e5ef',
|
|
||||||
paddingLeft: '12px',
|
|
||||||
marginBottom: '12px',
|
|
||||||
};
|
|
||||||
|
|
||||||
const pageTitle = {
|
|
||||||
...paragraph,
|
|
||||||
margin: '0 0 2px 0',
|
|
||||||
fontSize: 14,
|
|
||||||
fontWeight: 'bold' as const,
|
|
||||||
};
|
|
||||||
|
|
||||||
const updatedByText = {
|
|
||||||
...paragraph,
|
|
||||||
margin: '0',
|
|
||||||
fontSize: 13,
|
|
||||||
color: '#666',
|
|
||||||
};
|
|
||||||
|
|
||||||
export default PageUpdateDigestEmail;
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
import { Link, Section, Text } from '@react-email/components';
|
|
||||||
import * as React from 'react';
|
|
||||||
import { content, link, paragraph } from '../css/styles';
|
|
||||||
import { EmailButton, getGreetingName, MailBody } from '../partials/partials';
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
userName: string;
|
|
||||||
actorName: string;
|
|
||||||
pageTitle: string;
|
|
||||||
pageUrl: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const PageUpdateEmail = ({
|
|
||||||
userName,
|
|
||||||
actorName,
|
|
||||||
pageTitle,
|
|
||||||
pageUrl,
|
|
||||||
}: Props) => {
|
|
||||||
return (
|
|
||||||
<MailBody>
|
|
||||||
<Section style={content}>
|
|
||||||
<Text style={paragraph}>Hi {getGreetingName(userName)},</Text>
|
|
||||||
<Text style={paragraph}>
|
|
||||||
<strong>{actorName}</strong> updated{' '}
|
|
||||||
<Link href={pageUrl} style={link}>
|
|
||||||
<strong>{pageTitle}</strong>
|
|
||||||
</Link>
|
|
||||||
.
|
|
||||||
</Text>
|
|
||||||
</Section>
|
|
||||||
<EmailButton href={pageUrl}>View page</EmailButton>
|
|
||||||
</MailBody>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default PageUpdateEmail;
|
|
||||||
@@ -87,7 +87,3 @@ export function MailFooter() {
|
|||||||
</Section>
|
</Section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getGreetingName(name?: string): string {
|
|
||||||
return name?.split(' ')[0] || 'there';
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import { TransformHttpResponseInterceptor } from './common/interceptors/http-res
|
|||||||
import { WsRedisIoAdapter } from './ws/adapter/ws-redis.adapter';
|
import { WsRedisIoAdapter } from './ws/adapter/ws-redis.adapter';
|
||||||
import fastifyMultipart from '@fastify/multipart';
|
import fastifyMultipart from '@fastify/multipart';
|
||||||
import fastifyCookie from '@fastify/cookie';
|
import fastifyCookie from '@fastify/cookie';
|
||||||
import fastifyIp from 'fastify-ip';
|
|
||||||
import { InternalLogFilter } from './common/logger/internal-log-filter';
|
import { InternalLogFilter } from './common/logger/internal-log-filter';
|
||||||
|
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
@@ -46,7 +45,6 @@ async function bootstrap() {
|
|||||||
|
|
||||||
app.useWebSocketAdapter(redisIoAdapter);
|
app.useWebSocketAdapter(redisIoAdapter);
|
||||||
|
|
||||||
await app.register(fastifyIp);
|
|
||||||
await app.register(fastifyMultipart);
|
await app.register(fastifyMultipart);
|
||||||
await app.register(fastifyCookie);
|
await app.register(fastifyCookie);
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,5 @@
|
|||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"module": "./src/index.ts",
|
"module": "./src/index.ts",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"dependencies": {
|
"dependencies": {}
|
||||||
"marked": "17.0.5"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+2
-54
@@ -286,7 +286,7 @@ importers:
|
|||||||
specifier: ^1.1.0
|
specifier: ^1.1.0
|
||||||
version: 1.1.0
|
version: 1.1.0
|
||||||
axios:
|
axios:
|
||||||
specifier: 1.13.6
|
specifier: ^1.13.6
|
||||||
version: 1.13.6
|
version: 1.13.6
|
||||||
blueimp-load-image:
|
blueimp-load-image:
|
||||||
specifier: ^5.16.0
|
specifier: ^5.16.0
|
||||||
@@ -493,9 +493,6 @@ importers:
|
|||||||
'@modelcontextprotocol/sdk':
|
'@modelcontextprotocol/sdk':
|
||||||
specifier: ^1.27.1
|
specifier: ^1.27.1
|
||||||
version: 1.27.1(@cfworker/json-schema@4.1.1)(zod@4.3.6)
|
version: 1.27.1(@cfworker/json-schema@4.1.1)(zod@4.3.6)
|
||||||
'@nest-lab/throttler-storage-redis':
|
|
||||||
specifier: ^1.2.0
|
|
||||||
version: 1.2.0(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.1.17)(@nestjs/throttler@6.5.0(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.1.17)(reflect-metadata@0.2.2))(ioredis@5.10.1)(reflect-metadata@0.2.2)
|
|
||||||
'@nestjs-labs/nestjs-ioredis':
|
'@nestjs-labs/nestjs-ioredis':
|
||||||
specifier: ^11.0.4
|
specifier: ^11.0.4
|
||||||
version: 11.0.4(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.1.17)(ioredis@5.10.1)
|
version: 11.0.4(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.1.17)(ioredis@5.10.1)
|
||||||
@@ -538,9 +535,6 @@ importers:
|
|||||||
'@nestjs/terminus':
|
'@nestjs/terminus':
|
||||||
specifier: ^11.1.1
|
specifier: ^11.1.1
|
||||||
version: 11.1.1(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.1.17)(reflect-metadata@0.2.2)(rxjs@7.8.2)
|
version: 11.1.1(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.1.17)(reflect-metadata@0.2.2)(rxjs@7.8.2)
|
||||||
'@nestjs/throttler':
|
|
||||||
specifier: ^6.5.0
|
|
||||||
version: 6.5.0(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.1.17)(reflect-metadata@0.2.2)
|
|
||||||
'@nestjs/websockets':
|
'@nestjs/websockets':
|
||||||
specifier: ^11.1.17
|
specifier: ^11.1.17
|
||||||
version: 11.1.17(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.1.17)(@nestjs/platform-socket.io@11.1.17)(reflect-metadata@0.2.2)(rxjs@7.8.2)
|
version: 11.1.17(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.1.17)(@nestjs/platform-socket.io@11.1.17)(reflect-metadata@0.2.2)(rxjs@7.8.2)
|
||||||
@@ -586,9 +580,6 @@ importers:
|
|||||||
cookie:
|
cookie:
|
||||||
specifier: ^1.1.1
|
specifier: ^1.1.1
|
||||||
version: 1.1.1
|
version: 1.1.1
|
||||||
fastify-ip:
|
|
||||||
specifier: ^2.0.0
|
|
||||||
version: 2.0.0
|
|
||||||
fs-extra:
|
fs-extra:
|
||||||
specifier: ^11.3.4
|
specifier: ^11.3.4
|
||||||
version: 11.3.4
|
version: 11.3.4
|
||||||
@@ -810,11 +801,7 @@ importers:
|
|||||||
specifier: ^8.57.1
|
specifier: ^8.57.1
|
||||||
version: 8.57.1(eslint@9.39.4(jiti@2.4.2))(typescript@5.9.3)
|
version: 8.57.1(eslint@9.39.4(jiti@2.4.2))(typescript@5.9.3)
|
||||||
|
|
||||||
packages/editor-ext:
|
packages/editor-ext: {}
|
||||||
dependencies:
|
|
||||||
marked:
|
|
||||||
specifier: 17.0.5
|
|
||||||
version: 17.0.5
|
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
@@ -2934,15 +2921,6 @@ packages:
|
|||||||
'@napi-rs/wasm-runtime@1.1.1':
|
'@napi-rs/wasm-runtime@1.1.1':
|
||||||
resolution: {integrity: sha512-p64ah1M1ld8xjWv3qbvFwHiFVWrq1yFvV4f7w+mzaqiR4IlSgkqhcRdHwsGgomwzBH51sRY4NEowLxnaBjcW/A==}
|
resolution: {integrity: sha512-p64ah1M1ld8xjWv3qbvFwHiFVWrq1yFvV4f7w+mzaqiR4IlSgkqhcRdHwsGgomwzBH51sRY4NEowLxnaBjcW/A==}
|
||||||
|
|
||||||
'@nest-lab/throttler-storage-redis@1.2.0':
|
|
||||||
resolution: {integrity: sha512-tMkUyo68NCKTR+zILk+EC35SMYBtDPZY2mCj7ZaCietWGVTnuP4zwq9ERYfvU6kJv6h8teNZrC6MJCmY6/dljw==}
|
|
||||||
peerDependencies:
|
|
||||||
'@nestjs/common': ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0
|
|
||||||
'@nestjs/core': ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0
|
|
||||||
'@nestjs/throttler': '>=6.0.0'
|
|
||||||
ioredis: '>=5.0.0'
|
|
||||||
reflect-metadata: ^0.2.1
|
|
||||||
|
|
||||||
'@nestjs-labs/nestjs-ioredis@11.0.4':
|
'@nestjs-labs/nestjs-ioredis@11.0.4':
|
||||||
resolution: {integrity: sha512-4jPNOrxDiwNMIN5OLmsMWhA782kxv/ZBxkySX9l8n6sr55acHX/BciaFsOXVa/ILsm+Y7893y98/6WNhmEoiNQ==}
|
resolution: {integrity: sha512-4jPNOrxDiwNMIN5OLmsMWhA782kxv/ZBxkySX9l8n6sr55acHX/BciaFsOXVa/ILsm+Y7893y98/6WNhmEoiNQ==}
|
||||||
engines: {node: '>=16'}
|
engines: {node: '>=16'}
|
||||||
@@ -3145,13 +3123,6 @@ packages:
|
|||||||
'@nestjs/platform-express':
|
'@nestjs/platform-express':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@nestjs/throttler@6.5.0':
|
|
||||||
resolution: {integrity: sha512-9j0ZRfH0QE1qyrj9JjIRDz5gQLPqq9yVC2nHsrosDVAfI5HHw08/aUAWx9DZLSdQf4HDkmhTTEGLrRFHENvchQ==}
|
|
||||||
peerDependencies:
|
|
||||||
'@nestjs/common': ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0
|
|
||||||
'@nestjs/core': ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0
|
|
||||||
reflect-metadata: ^0.1.13 || ^0.2.0
|
|
||||||
|
|
||||||
'@nestjs/websockets@11.1.17':
|
'@nestjs/websockets@11.1.17':
|
||||||
resolution: {integrity: sha512-YbwQ0QfVj0lxkKQhdIIgk14ZSVWDqGk1J8nNSN6SLjf36sVv58Ma5ro+dtQua8wj3l2Ub7JJCVFixEhKtYc/rQ==}
|
resolution: {integrity: sha512-YbwQ0QfVj0lxkKQhdIIgk14ZSVWDqGk1J8nNSN6SLjf36sVv58Ma5ro+dtQua8wj3l2Ub7JJCVFixEhKtYc/rQ==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -7041,10 +7012,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-Z7Fh2nVQSb2d+poDViM063ix2ZGt9jmY1nWhPfHBOK2Hgnb/OW3P4Et3P/81SEej0J7QbWtJqxO05h8QYfK7LQ==}
|
resolution: {integrity: sha512-Z7Fh2nVQSb2d+poDViM063ix2ZGt9jmY1nWhPfHBOK2Hgnb/OW3P4Et3P/81SEej0J7QbWtJqxO05h8QYfK7LQ==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
fastify-ip@2.0.0:
|
|
||||||
resolution: {integrity: sha512-7mQyAc7sapawpiriEFoJyQIs41nNIO42UCzgMKrjNGsIegnevj2VhOlXLLTa+q7cxXfJ5fDGmOAdQpaIgA9ObA==}
|
|
||||||
engines: {node: '>=20.x'}
|
|
||||||
|
|
||||||
fastify-plugin@5.0.1:
|
fastify-plugin@5.0.1:
|
||||||
resolution: {integrity: sha512-HCxs+YnRaWzCl+cWRYFnHmeRFyR5GVnJTAaCJQiYzQSDwK9MgJdyAsuL3nh0EWRCYMgQ5MeziymvmAhUHYHDUQ==}
|
resolution: {integrity: sha512-HCxs+YnRaWzCl+cWRYFnHmeRFyR5GVnJTAaCJQiYzQSDwK9MgJdyAsuL3nh0EWRCYMgQ5MeziymvmAhUHYHDUQ==}
|
||||||
|
|
||||||
@@ -13492,15 +13459,6 @@ snapshots:
|
|||||||
'@tybys/wasm-util': 0.10.1
|
'@tybys/wasm-util': 0.10.1
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@nest-lab/throttler-storage-redis@1.2.0(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.1.17)(@nestjs/throttler@6.5.0(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.1.17)(reflect-metadata@0.2.2))(ioredis@5.10.1)(reflect-metadata@0.2.2)':
|
|
||||||
dependencies:
|
|
||||||
'@nestjs/common': 11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2)
|
|
||||||
'@nestjs/core': 11.1.17(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/websockets@11.1.17)(reflect-metadata@0.2.2)(rxjs@7.8.2)
|
|
||||||
'@nestjs/throttler': 6.5.0(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.1.17)(reflect-metadata@0.2.2)
|
|
||||||
ioredis: 5.10.1
|
|
||||||
reflect-metadata: 0.2.2
|
|
||||||
tslib: 2.8.1
|
|
||||||
|
|
||||||
'@nestjs-labs/nestjs-ioredis@11.0.4(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.1.17)(ioredis@5.10.1)':
|
'@nestjs-labs/nestjs-ioredis@11.0.4(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.1.17)(ioredis@5.10.1)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@nestjs/common': 11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2)
|
'@nestjs/common': 11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2)
|
||||||
@@ -13681,12 +13639,6 @@ snapshots:
|
|||||||
'@nestjs/core': 11.1.17(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/websockets@11.1.17)(reflect-metadata@0.2.2)(rxjs@7.8.2)
|
'@nestjs/core': 11.1.17(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/websockets@11.1.17)(reflect-metadata@0.2.2)(rxjs@7.8.2)
|
||||||
tslib: 2.8.1
|
tslib: 2.8.1
|
||||||
|
|
||||||
'@nestjs/throttler@6.5.0(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.1.17)(reflect-metadata@0.2.2)':
|
|
||||||
dependencies:
|
|
||||||
'@nestjs/common': 11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2)
|
|
||||||
'@nestjs/core': 11.1.17(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/websockets@11.1.17)(reflect-metadata@0.2.2)(rxjs@7.8.2)
|
|
||||||
reflect-metadata: 0.2.2
|
|
||||||
|
|
||||||
'@nestjs/websockets@11.1.17(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.1.17)(@nestjs/platform-socket.io@11.1.17)(reflect-metadata@0.2.2)(rxjs@7.8.2)':
|
'@nestjs/websockets@11.1.17(@nestjs/common@11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.1.17)(@nestjs/platform-socket.io@11.1.17)(reflect-metadata@0.2.2)(rxjs@7.8.2)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@nestjs/common': 11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2)
|
'@nestjs/common': 11.1.17(class-transformer@0.5.1)(class-validator@0.15.1)(reflect-metadata@0.2.2)(rxjs@7.8.2)
|
||||||
@@ -18116,10 +18068,6 @@ snapshots:
|
|||||||
path-expression-matcher: 1.2.0
|
path-expression-matcher: 1.2.0
|
||||||
strnum: 2.2.1
|
strnum: 2.2.1
|
||||||
|
|
||||||
fastify-ip@2.0.0:
|
|
||||||
dependencies:
|
|
||||||
fastify-plugin: 5.1.0
|
|
||||||
|
|
||||||
fastify-plugin@5.0.1: {}
|
fastify-plugin@5.0.1: {}
|
||||||
|
|
||||||
fastify-plugin@5.1.0: {}
|
fastify-plugin@5.1.0: {}
|
||||||
|
|||||||
Reference in New Issue
Block a user