feat: workspace level share settings (#14201)

fix #13698
This commit is contained in:
DarkSky
2026-01-03 01:13:27 +08:00
committed by GitHub
parent 60de882a30
commit 9a7f8e7d4d
36 changed files with 560 additions and 34 deletions
@@ -59,6 +59,7 @@ test('should update workspace', async t => {
const data = {
public: true,
enableAi: true,
enableSharing: false,
enableUrlPreview: true,
enableDocEmbedding: false,
};
@@ -85,6 +85,26 @@ export async function updateWorkspace(
return res.updateWorkspace.public;
}
export async function setWorkspaceSharing(
app: TestingApp,
workspaceId: string,
enableSharing: boolean
) {
const res = await app.gql(
`
mutation {
updateWorkspace(
input: { id: "${workspaceId}", enableSharing: ${enableSharing} }
) {
enableSharing
}
}
`
);
return res.updateWorkspace.enableSharing as boolean;
}
export async function deleteWorkspace(
app: TestingApp,
workspaceId: string
@@ -10,6 +10,7 @@ import {
inviteUser,
publishDoc,
revokePublicDoc,
setWorkspaceSharing,
TestingApp,
updateWorkspace,
} from './utils';
@@ -180,4 +181,17 @@ test('should be able to get public workspace doc', async t => {
.type('application/octet-stream');
t.deepEqual(res.body, Buffer.from([0, 0]), 'failed to get public doc');
const disabled = await setWorkspaceSharing(app, workspace.id, false);
t.false(disabled, 'failed to disable workspace sharing');
// owner should still be able to access
await app
.GET(`/api/workspaces/${workspace.id}/docs/${workspace.id}`)
.expect(200);
await app.logout();
await app
.GET(`/api/workspaces/${workspace.id}/docs/${workspace.id}`)
.expect(403);
});