From e9ce164514f401328d84a8c6e8ee5a43c7239bf6 Mon Sep 17 00:00:00 2001 From: plutoyzhang Date: Thu, 10 Jul 2025 19:58:55 +0800 Subject: [PATCH 1/3] fix verify notion account and add new page api --- src/common/backend/services/notion/service.ts | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/common/backend/services/notion/service.ts b/src/common/backend/services/notion/service.ts index d45e0de0..e6871a5d 100644 --- a/src/common/backend/services/notion/service.ts +++ b/src/common/backend/services/notion/service.ts @@ -81,8 +81,8 @@ export default class NotionDocumentService implements DocumentService { const result: Array = await Promise.all( Object.keys(spaces).map(async (p) => { const space = spaces[p]; - const recentPages = await this.getRecentPageVisits(space.value.id, userId); - return this.loadSpace(p, space.value.name, recentPages); + const recentPages = await this.getRecentPageVisits(space.spaceId, userId); + return this.loadSpace(space.spaceId, space.table, recentPages); }) ); @@ -94,11 +94,24 @@ export default class NotionDocumentService implements DocumentService { const response = await this.requestWithCookie.post<{ users: { [id: string]: { + user_root: { + [id: string]: { + value: { + space_view_pointers: [ + { + id: string; + table: string; + spaceId: string; + } + ] + } + }; + } space: any; }; }; }>('/api/v3/getSpacesInitial'); - return response.data.users[userId].space; + return response.data.users[userId].user_root[userId].value.space_view_pointers; }; createDocument = async ({ @@ -152,7 +165,7 @@ export default class NotionDocumentService implements DocumentService { const userId = Object.keys(this.userContent.recordMap.notion_user)[0] as string; const spaces = (await this.getSpaces(userId)) as any; - return Object.keys(spaces)[0]; + return spaces[0].spaceId; }; createEmptyFile = async (repository: NotionRepository, title: string) => { @@ -161,6 +174,8 @@ export default class NotionDocumentService implements DocumentService { } const spaceId = await this.getSpaceId(); const documentId = generateUuid(); + const requestId = generateUuid(); + const inner_requestId = generateUuid(); const parentId = repository.id; const userId = Object.values(this.userContent.recordMap.notion_user)[0].value.id; const time = new Date().getDate(); @@ -271,8 +286,15 @@ export default class NotionDocumentService implements DocumentService { ]; } - await this.requestWithCookie.post('api/v3/submitTransaction', { - operations, + await this.requestWithCookie.post('api/v3/saveTransactionsFanout', { + requestId: requestId, + transactions: [ + { + id: inner_requestId, + operations: operations, + spaceId: spaceId, + } + ] }); return documentId; }; From 1cb8f7300cedf90f225d74e400298576d6716701 Mon Sep 17 00:00:00 2001 From: Pluto-Y Date: Mon, 14 Jul 2025 21:40:54 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86spaceName?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=88=E9=83=BD=E9=94=99=E8=AF=AF=E7=9A=84=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=B8=BAspace=5Fview=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/services/notion/service.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/common/backend/services/notion/service.ts b/src/common/backend/services/notion/service.ts index e6871a5d..c92e531a 100644 --- a/src/common/backend/services/notion/service.ts +++ b/src/common/backend/services/notion/service.ts @@ -82,7 +82,8 @@ export default class NotionDocumentService implements DocumentService { Object.keys(spaces).map(async (p) => { const space = spaces[p]; const recentPages = await this.getRecentPageVisits(space.spaceId, userId); - return this.loadSpace(space.spaceId, space.table, recentPages); + const spaceName = await this.getSpaceName(space.spaceId); + return this.loadSpace(space.spaceId, spaceName, recentPages); }) ); @@ -114,6 +115,20 @@ export default class NotionDocumentService implements DocumentService { return response.data.users[userId].user_root[userId].value.space_view_pointers; }; + getSpaceName = async (spaceId: string) => { + const response = await this.requestWithCookie.post<{ + results: [ + { + name: string; + } + ] + }>('api/v3/getPublicSpaceData', { + spaceIds: [spaceId], + type: 'space-ids' + }); + return response.data.results[0].name; + } + createDocument = async ({ repositoryId, title, From 98dc5edaf1186755b5b8a46a75efe1031f484826 Mon Sep 17 00:00:00 2001 From: Pluto-Y Date: Thu, 9 Oct 2025 21:56:22 +0800 Subject: [PATCH 3/3] fix the notion format --- src/common/backend/services/notion/service.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/backend/services/notion/service.ts b/src/common/backend/services/notion/service.ts index c92e531a..44c7b5de 100644 --- a/src/common/backend/services/notion/service.ts +++ b/src/common/backend/services/notion/service.ts @@ -164,6 +164,7 @@ export default class NotionDocumentService implements DocumentService { spaceId: spaceId, }, spaceId: spaceId, + signedToken: fileUrl.signedToken, }, }, }); @@ -318,6 +319,7 @@ export default class NotionDocumentService implements DocumentService { const result = await this.requestWithCookie.post<{ url: string; signedPutUrl: string; + signedToken: string; }>('api/v3/getUploadFileUrl', { bucket: 'temporary', name: fileName,