mirror of
https://github.com/docmost/docmost.git
synced 2026-05-10 16:24:05 +08:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d51342f7b0 |
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "client",
|
||||
"private": true,
|
||||
"version": "0.8.4",
|
||||
"version": "0.8.3",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc && vite build",
|
||||
|
||||
@@ -148,7 +148,6 @@
|
||||
"Select role to assign to all invited members": "Select role to assign to all invited members",
|
||||
"Select theme": "Select theme",
|
||||
"Send invitation": "Send invitation",
|
||||
"Invitation sent": "Invitation sent",
|
||||
"Settings": "Settings",
|
||||
"Setup workspace": "Setup workspace",
|
||||
"Sign In": "Sign In",
|
||||
|
||||
+3
-36
@@ -1,16 +1,12 @@
|
||||
import { Menu, ActionIcon, Text } from "@mantine/core";
|
||||
import React from "react";
|
||||
import { IconCopy, IconDots, IconSend, IconTrash } from "@tabler/icons-react";
|
||||
import { IconDots, IconTrash } from "@tabler/icons-react";
|
||||
import { modals } from "@mantine/modals";
|
||||
import {
|
||||
useResendInvitationMutation,
|
||||
useRevokeInvitationMutation,
|
||||
} from "@/features/workspace/queries/workspace-query.ts";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { notifications } from "@mantine/notifications";
|
||||
import { useClipboard } from "@mantine/hooks";
|
||||
import { getInviteLink } from "@/features/workspace/services/workspace-service.ts";
|
||||
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||
|
||||
interface Props {
|
||||
invitationId: string;
|
||||
@@ -19,21 +15,6 @@ export default function InviteActionMenu({ invitationId }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const resendInvitationMutation = useResendInvitationMutation();
|
||||
const revokeInvitationMutation = useRevokeInvitationMutation();
|
||||
const { isAdmin } = useUserRole();
|
||||
const clipboard = useClipboard();
|
||||
|
||||
const handleCopyLink = async (invitationId: string) => {
|
||||
try {
|
||||
const link = await getInviteLink({ invitationId });
|
||||
clipboard.copy(link.inviteLink);
|
||||
notifications.show({ message: t("Link copied") });
|
||||
} catch (err) {
|
||||
notifications.show({
|
||||
message: err["response"]?.data?.message,
|
||||
color: "red",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const onResend = async () => {
|
||||
await resendInvitationMutation.mutateAsync({ invitationId });
|
||||
@@ -76,26 +57,12 @@ export default function InviteActionMenu({ invitationId }: Props) {
|
||||
</Menu.Target>
|
||||
|
||||
<Menu.Dropdown>
|
||||
<Menu.Item
|
||||
onClick={() => handleCopyLink(invitationId)}
|
||||
leftSection={<IconCopy size={16} />}
|
||||
disabled={!isAdmin}
|
||||
>
|
||||
{t("Copy link")}
|
||||
</Menu.Item>
|
||||
<Menu.Item
|
||||
onClick={onResend}
|
||||
leftSection={<IconSend size={16} />}
|
||||
disabled={!isAdmin}
|
||||
>
|
||||
{t("Resend invitation")}
|
||||
</Menu.Item>
|
||||
<Menu.Item onClick={onResend}>{t("Resend invitation")}</Menu.Item>
|
||||
<Menu.Divider />
|
||||
<Menu.Item
|
||||
c="red"
|
||||
onClick={openRevokeModal}
|
||||
leftSection={<IconTrash size={16} />}
|
||||
disabled={!isAdmin}
|
||||
leftSection={<IconTrash size={16} stroke={2} />}
|
||||
>
|
||||
{t("Revoke invitation")}
|
||||
</Menu.Item>
|
||||
|
||||
@@ -24,7 +24,6 @@ import {
|
||||
IWorkspace,
|
||||
} from "@/features/workspace/types/workspace.types.ts";
|
||||
import { IUser } from "@/features/user/types/user.types.ts";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
export function useWorkspaceQuery(): UseQueryResult<IWorkspace, Error> {
|
||||
return useQuery({
|
||||
@@ -82,13 +81,12 @@ export function useWorkspaceInvitationsQuery(
|
||||
}
|
||||
|
||||
export function useCreateInvitationMutation() {
|
||||
const { t } = useTranslation();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<void, Error, ICreateInvite>({
|
||||
mutationFn: (data) => createInvitation(data),
|
||||
onSuccess: (data, variables) => {
|
||||
notifications.show({ message: t("Invitation sent") });
|
||||
notifications.show({ message: "Invitation sent" });
|
||||
queryClient.refetchQueries({
|
||||
queryKey: ["invitations"],
|
||||
});
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
IInvitation,
|
||||
IWorkspace,
|
||||
IAcceptInvite,
|
||||
IInvitationLink,
|
||||
} from "../types/workspace.types";
|
||||
import { IPagination, QueryParams } from "@/lib/types.ts";
|
||||
|
||||
@@ -54,13 +53,6 @@ export async function acceptInvitation(data: IAcceptInvite): Promise<void> {
|
||||
await api.post<void>("/workspace/invites/accept", data);
|
||||
}
|
||||
|
||||
export async function getInviteLink(data: {
|
||||
invitationId: string;
|
||||
}): Promise<IInvitationLink> {
|
||||
const req = await api.post("/workspace/invites/link", data);
|
||||
return req.data;
|
||||
}
|
||||
|
||||
export async function resendInvitation(data: {
|
||||
invitationId: string;
|
||||
}): Promise<void> {
|
||||
|
||||
@@ -28,10 +28,6 @@ export interface IInvitation {
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export interface IInvitationLink {
|
||||
inviteLink: string;
|
||||
}
|
||||
|
||||
export interface IAcceptInvite {
|
||||
invitationId: string;
|
||||
name: string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "server",
|
||||
"version": "0.8.4",
|
||||
"version": "0.8.3",
|
||||
"description": "",
|
||||
"author": "",
|
||||
"private": true,
|
||||
@@ -49,6 +49,8 @@
|
||||
"@nestjs/websockets": "^11.0.10",
|
||||
"@react-email/components": "0.0.28",
|
||||
"@react-email/render": "1.0.2",
|
||||
"@sentry/nestjs": "^9.2.0",
|
||||
"@sentry/profiling-node": "^9.2.0",
|
||||
"@socket.io/redis-adapter": "^8.3.0",
|
||||
"bcrypt": "^5.1.1",
|
||||
"bullmq": "^5.41.3",
|
||||
|
||||
@@ -14,9 +14,11 @@ import { EventEmitterModule } from '@nestjs/event-emitter';
|
||||
import { HealthModule } from './integrations/health/health.module';
|
||||
import { ExportModule } from './integrations/export/export.module';
|
||||
import { ImportModule } from './integrations/import/import.module';
|
||||
import { SentryModule } from "@sentry/nestjs/setup";
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
SentryModule.forRoot(),
|
||||
CoreModule,
|
||||
DatabaseModule,
|
||||
EnvironmentModule,
|
||||
|
||||
@@ -8,9 +8,11 @@ import { QueueModule } from '../../integrations/queue/queue.module';
|
||||
import { EventEmitterModule } from '@nestjs/event-emitter';
|
||||
import { HealthModule } from '../../integrations/health/health.module';
|
||||
import { CollaborationController } from './collaboration.controller';
|
||||
import { SentryModule } from "@sentry/nestjs/setup";
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
SentryModule.forRoot(),
|
||||
DatabaseModule,
|
||||
EnvironmentModule,
|
||||
CollaborationModule,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import "./common/sentry/instrument";
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { CollabAppModule } from './collab-app.module';
|
||||
import {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import * as Sentry from '@sentry/nestjs';
|
||||
import { nodeProfilingIntegration } from '@sentry/profiling-node';
|
||||
import { envPath } from '../helpers';
|
||||
import * as dotenv from 'dotenv';
|
||||
dotenv.config({ path: envPath });
|
||||
|
||||
if (process.env.SENTRY_DSN) {
|
||||
Sentry.init({
|
||||
dsn: process.env.SENTRY_DSN,
|
||||
integrations: [
|
||||
nodeProfilingIntegration(),
|
||||
],
|
||||
tracesSampleRate: 1.0,
|
||||
profilesSampleRate: 1.0,
|
||||
});
|
||||
}
|
||||
@@ -237,30 +237,4 @@ export class WorkspaceController {
|
||||
secure: this.environmentService.isHttps(),
|
||||
});
|
||||
}
|
||||
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Post('invites/link')
|
||||
async getInviteLink(
|
||||
@Body() inviteDto: InvitationIdDto,
|
||||
@AuthUser() user: User,
|
||||
@AuthWorkspace() workspace: Workspace,
|
||||
) {
|
||||
if (this.environmentService.isCloud()) {
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
|
||||
const ability = this.workspaceAbility.createForUser(user, workspace);
|
||||
if (
|
||||
ability.cannot(WorkspaceCaslAction.Manage, WorkspaceCaslSubject.Member)
|
||||
) {
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
const inviteLink =
|
||||
await this.workspaceInvitationService.getInvitationLinkById(
|
||||
inviteDto.invitationId,
|
||||
workspace.id,
|
||||
);
|
||||
|
||||
return { inviteLink };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,21 +71,6 @@ export class WorkspaceInvitationService {
|
||||
return invitation;
|
||||
}
|
||||
|
||||
async getInvitationTokenById(invitationId: string, workspaceId: string) {
|
||||
const invitation = await this.db
|
||||
.selectFrom('workspaceInvitations')
|
||||
.select(['token'])
|
||||
.where('id', '=', invitationId)
|
||||
.where('workspaceId', '=', workspaceId)
|
||||
.executeTakeFirst();
|
||||
|
||||
if (!invitation) {
|
||||
throw new NotFoundException('Invitation not found');
|
||||
}
|
||||
|
||||
return invitation;
|
||||
}
|
||||
|
||||
async createInvitation(
|
||||
inviteUserDto: InviteUserDto,
|
||||
workspaceId: string,
|
||||
@@ -271,6 +256,7 @@ export class WorkspaceInvitationService {
|
||||
invitationId: string,
|
||||
workspaceId: string,
|
||||
): Promise<void> {
|
||||
//
|
||||
const invitation = await this.db
|
||||
.selectFrom('workspaceInvitations')
|
||||
.selectAll()
|
||||
@@ -306,28 +292,13 @@ export class WorkspaceInvitationService {
|
||||
.execute();
|
||||
}
|
||||
|
||||
async getInvitationLinkById(
|
||||
invitationId: string,
|
||||
workspaceId: string,
|
||||
): Promise<string> {
|
||||
const token = await this.getInvitationTokenById(invitationId, workspaceId);
|
||||
return this.buildInviteLink(invitationId, token.token);
|
||||
}
|
||||
|
||||
async buildInviteLink(
|
||||
invitationId: string,
|
||||
inviteToken: string,
|
||||
): Promise<string> {
|
||||
return `${this.environmentService.getAppUrl()}/invites/${invitationId}?token=${inviteToken}`;
|
||||
}
|
||||
|
||||
async sendInvitationMail(
|
||||
invitationId: string,
|
||||
inviteeEmail: string,
|
||||
inviteToken: string,
|
||||
invitedByName: string,
|
||||
): Promise<void> {
|
||||
const inviteLink = await this.buildInviteLink(invitationId, inviteToken);
|
||||
const inviteLink = `${this.environmentService.getAppUrl()}/invites/${invitationId}?token=${inviteToken}`;
|
||||
|
||||
const emailTemplate = InvitationEmail({
|
||||
inviteLink,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import "./common/sentry/instrument";
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { AppModule } from './app.module';
|
||||
import {
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "docmost",
|
||||
"homepage": "https://docmost.com",
|
||||
"version": "0.8.4",
|
||||
"version": "0.8.3",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "nx run-many -t build",
|
||||
|
||||
Generated
+4
-12
@@ -588,7 +588,7 @@ importers:
|
||||
version: 3.5.1
|
||||
react-email:
|
||||
specifier: 3.0.2
|
||||
version: 3.0.2(@opentelemetry/api@1.9.0)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||
version: 3.0.2(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||
source-map-support:
|
||||
specifier: ^0.5.21
|
||||
version: 0.5.21
|
||||
@@ -2830,10 +2830,6 @@ packages:
|
||||
'@one-ini/wasm@0.1.1':
|
||||
resolution: {integrity: sha512-XuySG1E38YScSJoMlqovLru4KTUNSjgVTIjyh7qMX6aNN5HY5Ct5LhRJdxO79JtTzKfzV/bnWpz+zquYrISsvw==}
|
||||
|
||||
'@opentelemetry/api@1.9.0':
|
||||
resolution: {integrity: sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==}
|
||||
engines: {node: '>=8.0.0'}
|
||||
|
||||
'@pkgjs/parseargs@0.11.0':
|
||||
resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==}
|
||||
engines: {node: '>=14'}
|
||||
@@ -11098,9 +11094,6 @@ snapshots:
|
||||
|
||||
'@one-ini/wasm@0.1.1': {}
|
||||
|
||||
'@opentelemetry/api@1.9.0':
|
||||
optional: true
|
||||
|
||||
'@pkgjs/parseargs@0.11.0':
|
||||
optional: true
|
||||
|
||||
@@ -15472,7 +15465,7 @@ snapshots:
|
||||
kysely: 0.27.5
|
||||
reflect-metadata: 0.2.2
|
||||
|
||||
next@14.2.10(@babel/core@7.24.5)(@opentelemetry/api@1.9.0)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
|
||||
next@14.2.10(@babel/core@7.24.5)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
|
||||
dependencies:
|
||||
'@next/env': 14.2.10
|
||||
'@swc/helpers': 0.5.5
|
||||
@@ -15493,7 +15486,6 @@ snapshots:
|
||||
'@next/swc-win32-arm64-msvc': 14.2.10
|
||||
'@next/swc-win32-ia32-msvc': 14.2.10
|
||||
'@next/swc-win32-x64-msvc': 14.2.10
|
||||
'@opentelemetry/api': 1.9.0
|
||||
transitivePeerDependencies:
|
||||
- '@babel/core'
|
||||
- babel-plugin-macros
|
||||
@@ -16167,7 +16159,7 @@ snapshots:
|
||||
dependencies:
|
||||
react: 18.3.1
|
||||
|
||||
react-email@3.0.2(@opentelemetry/api@1.9.0)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
|
||||
react-email@3.0.2(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
|
||||
dependencies:
|
||||
'@babel/core': 7.24.5
|
||||
'@babel/parser': 7.24.5
|
||||
@@ -16179,7 +16171,7 @@ snapshots:
|
||||
glob: 10.3.4
|
||||
log-symbols: 4.1.0
|
||||
mime-types: 2.1.35
|
||||
next: 14.2.10(@babel/core@7.24.5)(@opentelemetry/api@1.9.0)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||
next: 14.2.10(@babel/core@7.24.5)(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||
normalize-path: 3.0.0
|
||||
ora: 5.4.1
|
||||
socket.io: 4.8.0
|
||||
|
||||
Reference in New Issue
Block a user