Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(server): everyone can share page in workspace (#4357)

LongYinanf0de34a60bc6
diff --git a/apps/server/src/modules/workspaces/resolver.ts b/apps/server/src/modules/workspaces/resolver.ts
index e36ab8d85c..49f849bafa 100644
--- a/apps/server/src/modules/workspaces/resolver.ts
+++ b/apps/server/src/modules/workspaces/resolver.ts
@@ -30,7 +30,6 @@ import type { User, Workspace } from '@prisma/client';
import GraphQLUpload from 'graphql-upload/GraphQLUpload.mjs';
import { applyUpdate, Doc } from 'yjs';
-import { Config } from '../../config';
import { PrismaService } from '../../prisma';
import { StorageProvide } from '../../storage';
import { CloudThrottlerGuard, Throttle } from '../../throttler';
@@ -139,7 +138,6 @@ export class WorkspaceResolver {
constructor(
private readonly auth: AuthService,
- private readonly config: Config,
private readonly mailer: MailService,
private readonly prisma: PrismaService,
private readonly permissions: PermissionService,
@@ -644,9 +642,16 @@ export class WorkspaceResolver {
@Args('workspaceId') workspaceId: string,
@Args('pageId') pageId: string
) {
- await this.permissions.check(workspaceId, user.id, Permission.Admin);
-
- return this.permissions.grantPage(workspaceId, pageId);
+ const userWorkspace = await this.prisma.userWorkspacePermission.findFirst({
+ where: {
+ userId: user.id,
+ workspaceId,
+ },
+ });
+ return (
+ userWorkspace?.accepted &&
+ (await this.permissions.grantPage(workspaceId, pageId))
+ );
}
@Mutation(() => Boolean)