Skip to content

Commit e9ce164

Browse files
author
plutoyzhang
committed
fix verify notion account and add new page api
1 parent dc978f0 commit e9ce164

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

src/common/backend/services/notion/service.ts

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ export default class NotionDocumentService implements DocumentService {
8181
const result: Array<NotionRepository[]> = await Promise.all(
8282
Object.keys(spaces).map(async (p) => {
8383
const space = spaces[p];
84-
const recentPages = await this.getRecentPageVisits(space.value.id, userId);
85-
return this.loadSpace(p, space.value.name, recentPages);
84+
const recentPages = await this.getRecentPageVisits(space.spaceId, userId);
85+
return this.loadSpace(space.spaceId, space.table, recentPages);
8686
})
8787
);
8888

@@ -94,11 +94,24 @@ export default class NotionDocumentService implements DocumentService {
9494
const response = await this.requestWithCookie.post<{
9595
users: {
9696
[id: string]: {
97+
user_root: {
98+
[id: string]: {
99+
value: {
100+
space_view_pointers: [
101+
{
102+
id: string;
103+
table: string;
104+
spaceId: string;
105+
}
106+
]
107+
}
108+
};
109+
}
97110
space: any;
98111
};
99112
};
100113
}>('/api/v3/getSpacesInitial');
101-
return response.data.users[userId].space;
114+
return response.data.users[userId].user_root[userId].value.space_view_pointers;
102115
};
103116

104117
createDocument = async ({
@@ -152,7 +165,7 @@ export default class NotionDocumentService implements DocumentService {
152165

153166
const userId = Object.keys(this.userContent.recordMap.notion_user)[0] as string;
154167
const spaces = (await this.getSpaces(userId)) as any;
155-
return Object.keys(spaces)[0];
168+
return spaces[0].spaceId;
156169
};
157170

158171
createEmptyFile = async (repository: NotionRepository, title: string) => {
@@ -161,6 +174,8 @@ export default class NotionDocumentService implements DocumentService {
161174
}
162175
const spaceId = await this.getSpaceId();
163176
const documentId = generateUuid();
177+
const requestId = generateUuid();
178+
const inner_requestId = generateUuid();
164179
const parentId = repository.id;
165180
const userId = Object.values(this.userContent.recordMap.notion_user)[0].value.id;
166181
const time = new Date().getDate();
@@ -271,8 +286,15 @@ export default class NotionDocumentService implements DocumentService {
271286
];
272287
}
273288

274-
await this.requestWithCookie.post('api/v3/submitTransaction', {
275-
operations,
289+
await this.requestWithCookie.post('api/v3/saveTransactionsFanout', {
290+
requestId: requestId,
291+
transactions: [
292+
{
293+
id: inner_requestId,
294+
operations: operations,
295+
spaceId: spaceId,
296+
}
297+
]
276298
});
277299
return documentId;
278300
};

0 commit comments

Comments
 (0)