mirror of
https://github.com/docmost/docmost.git
synced 2026-05-21 17:22:54 +08:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 72f64e7b10 | |||
| 3cfb17bb62 | |||
| fe5066c7b5 | |||
| e13be904cd | |||
| fda5c7d60f | |||
| 7fc1a782a7 | |||
| 54d27af76a | |||
| 0065f29634 | |||
| 7d034e8a8b | |||
| 81b6c7ef69 | |||
| 89f6b0a8c2 | |||
| ad1571b902 | |||
| 4b9ab4f63c |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "client",
|
"name": "client",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.8.3",
|
"version": "0.8.4",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc && vite build",
|
"build": "tsc && vite build",
|
||||||
|
|||||||
@@ -148,6 +148,7 @@
|
|||||||
"Select role to assign to all invited members": "Select role to assign to all invited members",
|
"Select role to assign to all invited members": "Select role to assign to all invited members",
|
||||||
"Select theme": "Select theme",
|
"Select theme": "Select theme",
|
||||||
"Send invitation": "Send invitation",
|
"Send invitation": "Send invitation",
|
||||||
|
"Invitation sent": "Invitation sent",
|
||||||
"Settings": "Settings",
|
"Settings": "Settings",
|
||||||
"Setup workspace": "Setup workspace",
|
"Setup workspace": "Setup workspace",
|
||||||
"Sign In": "Sign In",
|
"Sign In": "Sign In",
|
||||||
|
|||||||
+36
-3
@@ -1,12 +1,16 @@
|
|||||||
import { Menu, ActionIcon, Text } from "@mantine/core";
|
import { Menu, ActionIcon, Text } from "@mantine/core";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { IconDots, IconTrash } from "@tabler/icons-react";
|
import { IconCopy, IconDots, IconSend, IconTrash } from "@tabler/icons-react";
|
||||||
import { modals } from "@mantine/modals";
|
import { modals } from "@mantine/modals";
|
||||||
import {
|
import {
|
||||||
useResendInvitationMutation,
|
useResendInvitationMutation,
|
||||||
useRevokeInvitationMutation,
|
useRevokeInvitationMutation,
|
||||||
} from "@/features/workspace/queries/workspace-query.ts";
|
} from "@/features/workspace/queries/workspace-query.ts";
|
||||||
import { useTranslation } from "react-i18next";
|
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 {
|
interface Props {
|
||||||
invitationId: string;
|
invitationId: string;
|
||||||
@@ -15,6 +19,21 @@ export default function InviteActionMenu({ invitationId }: Props) {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const resendInvitationMutation = useResendInvitationMutation();
|
const resendInvitationMutation = useResendInvitationMutation();
|
||||||
const revokeInvitationMutation = useRevokeInvitationMutation();
|
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 () => {
|
const onResend = async () => {
|
||||||
await resendInvitationMutation.mutateAsync({ invitationId });
|
await resendInvitationMutation.mutateAsync({ invitationId });
|
||||||
@@ -57,12 +76,26 @@ export default function InviteActionMenu({ invitationId }: Props) {
|
|||||||
</Menu.Target>
|
</Menu.Target>
|
||||||
|
|
||||||
<Menu.Dropdown>
|
<Menu.Dropdown>
|
||||||
<Menu.Item onClick={onResend}>{t("Resend invitation")}</Menu.Item>
|
<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.Divider />
|
<Menu.Divider />
|
||||||
<Menu.Item
|
<Menu.Item
|
||||||
c="red"
|
c="red"
|
||||||
onClick={openRevokeModal}
|
onClick={openRevokeModal}
|
||||||
leftSection={<IconTrash size={16} stroke={2} />}
|
leftSection={<IconTrash size={16} />}
|
||||||
|
disabled={!isAdmin}
|
||||||
>
|
>
|
||||||
{t("Revoke invitation")}
|
{t("Revoke invitation")}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import {
|
|||||||
IWorkspace,
|
IWorkspace,
|
||||||
} from "@/features/workspace/types/workspace.types.ts";
|
} from "@/features/workspace/types/workspace.types.ts";
|
||||||
import { IUser } from "@/features/user/types/user.types.ts";
|
import { IUser } from "@/features/user/types/user.types.ts";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
export function useWorkspaceQuery(): UseQueryResult<IWorkspace, Error> {
|
export function useWorkspaceQuery(): UseQueryResult<IWorkspace, Error> {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
@@ -81,12 +82,13 @@ export function useWorkspaceInvitationsQuery(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function useCreateInvitationMutation() {
|
export function useCreateInvitationMutation() {
|
||||||
|
const { t } = useTranslation();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
return useMutation<void, Error, ICreateInvite>({
|
return useMutation<void, Error, ICreateInvite>({
|
||||||
mutationFn: (data) => createInvitation(data),
|
mutationFn: (data) => createInvitation(data),
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: (data, variables) => {
|
||||||
notifications.show({ message: "Invitation sent" });
|
notifications.show({ message: t("Invitation sent") });
|
||||||
queryClient.refetchQueries({
|
queryClient.refetchQueries({
|
||||||
queryKey: ["invitations"],
|
queryKey: ["invitations"],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
IInvitation,
|
IInvitation,
|
||||||
IWorkspace,
|
IWorkspace,
|
||||||
IAcceptInvite,
|
IAcceptInvite,
|
||||||
|
IInvitationLink,
|
||||||
} from "../types/workspace.types";
|
} from "../types/workspace.types";
|
||||||
import { IPagination, QueryParams } from "@/lib/types.ts";
|
import { IPagination, QueryParams } from "@/lib/types.ts";
|
||||||
|
|
||||||
@@ -53,6 +54,13 @@ export async function acceptInvitation(data: IAcceptInvite): Promise<void> {
|
|||||||
await api.post<void>("/workspace/invites/accept", data);
|
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: {
|
export async function resendInvitation(data: {
|
||||||
invitationId: string;
|
invitationId: string;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ export interface IInvitation {
|
|||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IInvitationLink {
|
||||||
|
inviteLink: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface IAcceptInvite {
|
export interface IAcceptInvite {
|
||||||
invitationId: string;
|
invitationId: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
|||||||
@@ -19,15 +19,13 @@ export function getBackendUrl(): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getCollaborationUrl(): string {
|
export function getCollaborationUrl(): string {
|
||||||
const COLLAB_PATH = "/collab";
|
const baseUrl =
|
||||||
|
getConfigValue("COLLAB_URL") ||
|
||||||
|
(import.meta.env.DEV ? process.env.APP_URL : getAppUrl());
|
||||||
|
|
||||||
let url = getAppUrl();
|
const collabUrl = new URL("/collab", baseUrl);
|
||||||
if (import.meta.env.DEV) {
|
collabUrl.protocol = collabUrl.protocol === "https:" ? "wss:" : "ws:";
|
||||||
url = process.env.APP_URL;
|
return collabUrl.toString();
|
||||||
}
|
|
||||||
|
|
||||||
const wsProtocol = url.startsWith("https") ? "wss" : "ws";
|
|
||||||
return `${wsProtocol}://${url.split("://")[1]}${COLLAB_PATH}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAvatarUrl(avatarUrl: string) {
|
export function getAvatarUrl(avatarUrl: string) {
|
||||||
|
|||||||
@@ -5,16 +5,21 @@ import * as path from "path";
|
|||||||
export const envPath = path.resolve(process.cwd(), "..", "..");
|
export const envPath = path.resolve(process.cwd(), "..", "..");
|
||||||
|
|
||||||
export default defineConfig(({ mode }) => {
|
export default defineConfig(({ mode }) => {
|
||||||
const { APP_URL, FILE_UPLOAD_SIZE_LIMIT, DRAWIO_URL } = loadEnv(mode, envPath, "");
|
const { APP_URL, FILE_UPLOAD_SIZE_LIMIT, DRAWIO_URL, COLLAB_URL } = loadEnv(
|
||||||
|
mode,
|
||||||
|
envPath,
|
||||||
|
"",
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
define: {
|
define: {
|
||||||
"process.env": {
|
"process.env": {
|
||||||
APP_URL,
|
APP_URL,
|
||||||
FILE_UPLOAD_SIZE_LIMIT,
|
FILE_UPLOAD_SIZE_LIMIT,
|
||||||
DRAWIO_URL
|
DRAWIO_URL,
|
||||||
|
COLLAB_URL,
|
||||||
},
|
},
|
||||||
'APP_VERSION': JSON.stringify(process.env.npm_package_version),
|
APP_VERSION: JSON.stringify(process.env.npm_package_version),
|
||||||
},
|
},
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
resolve: {
|
resolve: {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "server",
|
"name": "server",
|
||||||
"version": "0.8.3",
|
"version": "0.8.4",
|
||||||
"description": "",
|
"description": "",
|
||||||
"author": "",
|
"author": "",
|
||||||
"private": true,
|
"private": true,
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
"start:dev": "cross-env NODE_ENV=development nest start --watch",
|
"start:dev": "cross-env NODE_ENV=development nest start --watch",
|
||||||
"start:debug": "cross-env NODE_ENV=development nest start --debug --watch",
|
"start:debug": "cross-env NODE_ENV=development nest start --debug --watch",
|
||||||
"start:prod": "cross-env NODE_ENV=production node dist/main",
|
"start:prod": "cross-env NODE_ENV=production node dist/main",
|
||||||
|
"collab:prod": "cross-env NODE_ENV=production node dist/collaboration/server/collab-main",
|
||||||
"email:dev": "email dev -p 5019 -d ./src/integrations/transactional/emails",
|
"email:dev": "email dev -p 5019 -d ./src/integrations/transactional/emails",
|
||||||
"migration:create": "tsx src/database/migrate.ts create",
|
"migration:create": "tsx src/database/migrate.ts create",
|
||||||
"migration:up": "tsx src/database/migrate.ts up",
|
"migration:up": "tsx src/database/migrate.ts up",
|
||||||
|
|||||||
@@ -25,21 +25,25 @@ export class CollaborationGateway {
|
|||||||
this.redisConfig = parseRedisUrl(this.environmentService.getRedisUrl());
|
this.redisConfig = parseRedisUrl(this.environmentService.getRedisUrl());
|
||||||
|
|
||||||
this.hocuspocus = HocuspocusServer.configure({
|
this.hocuspocus = HocuspocusServer.configure({
|
||||||
debounce: 5000,
|
debounce: 10000,
|
||||||
maxDebounce: 10000,
|
maxDebounce: 20000,
|
||||||
unloadImmediately: false,
|
unloadImmediately: false,
|
||||||
extensions: [
|
extensions: [
|
||||||
this.authenticationExtension,
|
this.authenticationExtension,
|
||||||
this.persistenceExtension,
|
this.persistenceExtension,
|
||||||
new Redis({
|
...(this.environmentService.isCollabDisableRedis()
|
||||||
host: this.redisConfig.host,
|
? []
|
||||||
port: this.redisConfig.port,
|
: [
|
||||||
options: {
|
new Redis({
|
||||||
password: this.redisConfig.password,
|
host: this.redisConfig.host,
|
||||||
db: this.redisConfig.db,
|
port: this.redisConfig.port,
|
||||||
retryStrategy: createRetryStrategy(),
|
options: {
|
||||||
},
|
password: this.redisConfig.password,
|
||||||
}),
|
db: this.redisConfig.db,
|
||||||
|
retryStrategy: createRetryStrategy(),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
]),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -48,6 +52,14 @@ export class CollaborationGateway {
|
|||||||
this.hocuspocus.handleConnection(client, request);
|
this.hocuspocus.handleConnection(client, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getConnectionCount() {
|
||||||
|
return this.hocuspocus.getConnectionsCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
getDocumentCount() {
|
||||||
|
return this.hocuspocus.getDocumentsCount();
|
||||||
|
}
|
||||||
|
|
||||||
async destroy(): Promise<void> {
|
async destroy(): Promise<void> {
|
||||||
await this.hocuspocus.destroy();
|
await this.hocuspocus.destroy();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { HistoryListener } from './listeners/history.listener';
|
|||||||
PersistenceExtension,
|
PersistenceExtension,
|
||||||
HistoryListener,
|
HistoryListener,
|
||||||
],
|
],
|
||||||
|
exports: [CollaborationGateway],
|
||||||
imports: [TokenModule],
|
imports: [TokenModule],
|
||||||
})
|
})
|
||||||
export class CollaborationModule implements OnModuleInit, OnModuleDestroy {
|
export class CollaborationModule implements OnModuleInit, OnModuleDestroy {
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { AppController } from '../../app.controller';
|
||||||
|
import { AppService } from '../../app.service';
|
||||||
|
import { EnvironmentModule } from '../../integrations/environment/environment.module';
|
||||||
|
import { CollaborationModule } from '../collaboration.module';
|
||||||
|
import { DatabaseModule } from '@docmost/db/database.module';
|
||||||
|
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';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [
|
||||||
|
DatabaseModule,
|
||||||
|
EnvironmentModule,
|
||||||
|
CollaborationModule,
|
||||||
|
QueueModule,
|
||||||
|
HealthModule,
|
||||||
|
EventEmitterModule.forRoot(),
|
||||||
|
],
|
||||||
|
controllers: [
|
||||||
|
AppController,
|
||||||
|
...(process.env.COLLAB_SHOW_STATS.toLowerCase() === 'true'
|
||||||
|
? [CollaborationController]
|
||||||
|
: []),
|
||||||
|
],
|
||||||
|
providers: [AppService],
|
||||||
|
})
|
||||||
|
export class CollabAppModule {}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import { NestFactory } from '@nestjs/core';
|
||||||
|
import { CollabAppModule } from './collab-app.module';
|
||||||
|
import {
|
||||||
|
FastifyAdapter,
|
||||||
|
NestFastifyApplication,
|
||||||
|
} from '@nestjs/platform-fastify';
|
||||||
|
import { TransformHttpResponseInterceptor } from '../../common/interceptors/http-response.interceptor';
|
||||||
|
import { InternalLogFilter } from '../../common/logger/internal-log-filter';
|
||||||
|
import { Logger } from '@nestjs/common';
|
||||||
|
|
||||||
|
async function bootstrap() {
|
||||||
|
const app = await NestFactory.create<NestFastifyApplication>(
|
||||||
|
CollabAppModule,
|
||||||
|
new FastifyAdapter({
|
||||||
|
ignoreTrailingSlash: true,
|
||||||
|
ignoreDuplicateSlashes: true,
|
||||||
|
maxParamLength: 500,
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
logger: new InternalLogFilter(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
app.setGlobalPrefix('api', { exclude: ['/'] });
|
||||||
|
|
||||||
|
app.enableCors();
|
||||||
|
|
||||||
|
app.useGlobalInterceptors(new TransformHttpResponseInterceptor());
|
||||||
|
app.enableShutdownHooks();
|
||||||
|
|
||||||
|
const logger = new Logger('CollabServer');
|
||||||
|
|
||||||
|
const port = process.env.COLLAB_PORT || 3001;
|
||||||
|
await app.listen(port, '0.0.0.0', () => {
|
||||||
|
logger.log(`Listening on http://127.0.0.1:${port}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bootstrap();
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { Controller, Get } from '@nestjs/common';
|
||||||
|
import { CollaborationGateway } from '../collaboration.gateway';
|
||||||
|
|
||||||
|
@Controller('collab')
|
||||||
|
export class CollaborationController {
|
||||||
|
constructor(private readonly collaborationGateway: CollaborationGateway) {}
|
||||||
|
|
||||||
|
@Get('stats')
|
||||||
|
async getStats() {
|
||||||
|
return {
|
||||||
|
connections: this.collaborationGateway.getConnectionCount(),
|
||||||
|
documents: this.collaborationGateway.getDocumentCount(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -237,4 +237,30 @@ export class WorkspaceController {
|
|||||||
secure: this.environmentService.isHttps(),
|
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,6 +71,21 @@ export class WorkspaceInvitationService {
|
|||||||
return invitation;
|
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(
|
async createInvitation(
|
||||||
inviteUserDto: InviteUserDto,
|
inviteUserDto: InviteUserDto,
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
@@ -256,7 +271,6 @@ export class WorkspaceInvitationService {
|
|||||||
invitationId: string,
|
invitationId: string,
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
//
|
|
||||||
const invitation = await this.db
|
const invitation = await this.db
|
||||||
.selectFrom('workspaceInvitations')
|
.selectFrom('workspaceInvitations')
|
||||||
.selectAll()
|
.selectAll()
|
||||||
@@ -292,13 +306,28 @@ export class WorkspaceInvitationService {
|
|||||||
.execute();
|
.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(
|
async sendInvitationMail(
|
||||||
invitationId: string,
|
invitationId: string,
|
||||||
inviteeEmail: string,
|
inviteeEmail: string,
|
||||||
inviteToken: string,
|
inviteToken: string,
|
||||||
invitedByName: string,
|
invitedByName: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const inviteLink = `${this.environmentService.getAppUrl()}/invites/${invitationId}?token=${inviteToken}`;
|
const inviteLink = await this.buildInviteLink(invitationId, inviteToken);
|
||||||
|
|
||||||
const emailTemplate = InvitationEmail({
|
const emailTemplate = InvitationEmail({
|
||||||
inviteLink,
|
inviteLink,
|
||||||
|
|||||||
@@ -145,4 +145,15 @@ export class EnvironmentService {
|
|||||||
isSelfHosted(): boolean {
|
isSelfHosted(): boolean {
|
||||||
return !this.isCloud();
|
return !this.isCloud();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCollabUrl(): string {
|
||||||
|
return this.configService.get<string>('COLLAB_URL');
|
||||||
|
}
|
||||||
|
|
||||||
|
isCollabDisableRedis(): boolean {
|
||||||
|
const isStandalone = this.configService
|
||||||
|
.get<string>('COLLAB_DISABLE_REDIS', 'false')
|
||||||
|
.toLowerCase();
|
||||||
|
return isStandalone === 'true';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
IsOptional,
|
IsOptional,
|
||||||
IsUrl,
|
IsUrl,
|
||||||
MinLength,
|
MinLength,
|
||||||
|
ValidateIf,
|
||||||
validateSync,
|
validateSync,
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
import { plainToInstance } from 'class-transformer';
|
import { plainToInstance } from 'class-transformer';
|
||||||
@@ -48,6 +49,11 @@ export class EnvironmentVariables {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsIn(['local', 's3'])
|
@IsIn(['local', 's3'])
|
||||||
STORAGE_DRIVER: string;
|
STORAGE_DRIVER: string;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@ValidateIf((obj) => obj.COLLAB_URL != '' && obj.COLLAB_URL != null)
|
||||||
|
@IsUrl({ protocols: ['http', 'https'], require_tld: false })
|
||||||
|
COLLAB_URL: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function validate(config: Record<string, any>) {
|
export function validate(config: Record<string, any>) {
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export class StaticModule implements OnModuleInit {
|
|||||||
FILE_UPLOAD_SIZE_LIMIT:
|
FILE_UPLOAD_SIZE_LIMIT:
|
||||||
this.environmentService.getFileUploadSizeLimit(),
|
this.environmentService.getFileUploadSizeLimit(),
|
||||||
DRAWIO_URL: this.environmentService.getDrawioUrl(),
|
DRAWIO_URL: this.environmentService.getDrawioUrl(),
|
||||||
|
COLLAB_URL: this.environmentService.getCollabUrl(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const windowScriptContent = `<script>window.CONFIG=${JSON.stringify(configString)};</script>`;
|
const windowScriptContent = `<script>window.CONFIG=${JSON.stringify(configString)};</script>`;
|
||||||
|
|||||||
+10
-2
@@ -4,7 +4,7 @@ import {
|
|||||||
FastifyAdapter,
|
FastifyAdapter,
|
||||||
NestFastifyApplication,
|
NestFastifyApplication,
|
||||||
} from '@nestjs/platform-fastify';
|
} from '@nestjs/platform-fastify';
|
||||||
import { NotFoundException, ValidationPipe } from '@nestjs/common';
|
import { Logger, NotFoundException, ValidationPipe } from '@nestjs/common';
|
||||||
import { TransformHttpResponseInterceptor } from './common/interceptors/http-response.interceptor';
|
import { TransformHttpResponseInterceptor } from './common/interceptors/http-response.interceptor';
|
||||||
import fastifyMultipart from '@fastify/multipart';
|
import fastifyMultipart from '@fastify/multipart';
|
||||||
import { WsRedisIoAdapter } from './ws/adapter/ws-redis.adapter';
|
import { WsRedisIoAdapter } from './ws/adapter/ws-redis.adapter';
|
||||||
@@ -18,6 +18,7 @@ async function bootstrap() {
|
|||||||
ignoreTrailingSlash: true,
|
ignoreTrailingSlash: true,
|
||||||
ignoreDuplicateSlashes: true,
|
ignoreDuplicateSlashes: true,
|
||||||
maxParamLength: 500,
|
maxParamLength: 500,
|
||||||
|
trustProxy: true,
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
logger: new InternalLogFilter(),
|
logger: new InternalLogFilter(),
|
||||||
@@ -65,7 +66,14 @@ async function bootstrap() {
|
|||||||
app.useGlobalInterceptors(new TransformHttpResponseInterceptor());
|
app.useGlobalInterceptors(new TransformHttpResponseInterceptor());
|
||||||
app.enableShutdownHooks();
|
app.enableShutdownHooks();
|
||||||
|
|
||||||
await app.listen(process.env.PORT || 3000, '0.0.0.0');
|
const logger = new Logger('NestApplication');
|
||||||
|
|
||||||
|
const port = process.env.PORT || 3000;
|
||||||
|
await app.listen(port, '0.0.0.0', () => {
|
||||||
|
logger.log(
|
||||||
|
`Listening on http://127.0.0.1:${port} / ${process.env.APP_URL}`,
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|||||||
+2
-1
@@ -1,11 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "docmost",
|
"name": "docmost",
|
||||||
"homepage": "https://docmost.com",
|
"homepage": "https://docmost.com",
|
||||||
"version": "0.8.3",
|
"version": "0.8.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "nx run-many -t build",
|
"build": "nx run-many -t build",
|
||||||
"start": "pnpm --filter ./apps/server run start:prod",
|
"start": "pnpm --filter ./apps/server run start:prod",
|
||||||
|
"collab": "pnpm --filter ./apps/server run collab:prod",
|
||||||
"server:build": "nx run server:build",
|
"server:build": "nx run server:build",
|
||||||
"client:build": "nx run client:build",
|
"client:build": "nx run client:build",
|
||||||
"editor-ext:build": "nx run @docmost/editor-ext:build",
|
"editor-ext:build": "nx run @docmost/editor-ext:build",
|
||||||
|
|||||||
Generated
+12
-4
@@ -588,7 +588,7 @@ importers:
|
|||||||
version: 3.5.1
|
version: 3.5.1
|
||||||
react-email:
|
react-email:
|
||||||
specifier: 3.0.2
|
specifier: 3.0.2
|
||||||
version: 3.0.2(babel-plugin-macros@3.1.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
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)
|
||||||
source-map-support:
|
source-map-support:
|
||||||
specifier: ^0.5.21
|
specifier: ^0.5.21
|
||||||
version: 0.5.21
|
version: 0.5.21
|
||||||
@@ -2830,6 +2830,10 @@ packages:
|
|||||||
'@one-ini/wasm@0.1.1':
|
'@one-ini/wasm@0.1.1':
|
||||||
resolution: {integrity: sha512-XuySG1E38YScSJoMlqovLru4KTUNSjgVTIjyh7qMX6aNN5HY5Ct5LhRJdxO79JtTzKfzV/bnWpz+zquYrISsvw==}
|
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':
|
'@pkgjs/parseargs@0.11.0':
|
||||||
resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==}
|
resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==}
|
||||||
engines: {node: '>=14'}
|
engines: {node: '>=14'}
|
||||||
@@ -11094,6 +11098,9 @@ snapshots:
|
|||||||
|
|
||||||
'@one-ini/wasm@0.1.1': {}
|
'@one-ini/wasm@0.1.1': {}
|
||||||
|
|
||||||
|
'@opentelemetry/api@1.9.0':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@pkgjs/parseargs@0.11.0':
|
'@pkgjs/parseargs@0.11.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
@@ -15465,7 +15472,7 @@ snapshots:
|
|||||||
kysely: 0.27.5
|
kysely: 0.27.5
|
||||||
reflect-metadata: 0.2.2
|
reflect-metadata: 0.2.2
|
||||||
|
|
||||||
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):
|
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):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@next/env': 14.2.10
|
'@next/env': 14.2.10
|
||||||
'@swc/helpers': 0.5.5
|
'@swc/helpers': 0.5.5
|
||||||
@@ -15486,6 +15493,7 @@ snapshots:
|
|||||||
'@next/swc-win32-arm64-msvc': 14.2.10
|
'@next/swc-win32-arm64-msvc': 14.2.10
|
||||||
'@next/swc-win32-ia32-msvc': 14.2.10
|
'@next/swc-win32-ia32-msvc': 14.2.10
|
||||||
'@next/swc-win32-x64-msvc': 14.2.10
|
'@next/swc-win32-x64-msvc': 14.2.10
|
||||||
|
'@opentelemetry/api': 1.9.0
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- '@babel/core'
|
- '@babel/core'
|
||||||
- babel-plugin-macros
|
- babel-plugin-macros
|
||||||
@@ -16159,7 +16167,7 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
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):
|
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):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/core': 7.24.5
|
'@babel/core': 7.24.5
|
||||||
'@babel/parser': 7.24.5
|
'@babel/parser': 7.24.5
|
||||||
@@ -16171,7 +16179,7 @@ snapshots:
|
|||||||
glob: 10.3.4
|
glob: 10.3.4
|
||||||
log-symbols: 4.1.0
|
log-symbols: 4.1.0
|
||||||
mime-types: 2.1.35
|
mime-types: 2.1.35
|
||||||
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)
|
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)
|
||||||
normalize-path: 3.0.0
|
normalize-path: 3.0.0
|
||||||
ora: 5.4.1
|
ora: 5.4.1
|
||||||
socket.io: 4.8.0
|
socket.io: 4.8.0
|
||||||
|
|||||||
Reference in New Issue
Block a user