mirror of
https://github.com/zhigang1992/notion-api-worker.git
synced 2026-01-12 17:32:42 +08:00
Fix edge cases that let worker crash
This commit is contained in:
@@ -92,16 +92,19 @@ export const fetchNotionUsers = async (
|
||||
},
|
||||
notionToken,
|
||||
});
|
||||
return users.results.map((u) => {
|
||||
const user = {
|
||||
id: u.value.id,
|
||||
firstName: u.value.given_name,
|
||||
lastLame: u.value.family_name,
|
||||
fullName: u.value.given_name + " " + u.value.family_name,
|
||||
profilePhoto: u.value.profile_photo,
|
||||
};
|
||||
return user;
|
||||
});
|
||||
if (users && users.results) {
|
||||
return users.results.map((u) => {
|
||||
const user = {
|
||||
id: u.value.id,
|
||||
firstName: u.value.given_name,
|
||||
lastLame: u.value.family_name,
|
||||
fullName: u.value.given_name + " " + u.value.family_name,
|
||||
profilePhoto: u.value.profile_photo,
|
||||
};
|
||||
return user;
|
||||
});
|
||||
}
|
||||
return [];
|
||||
};
|
||||
|
||||
export const fetchBlocks = async (
|
||||
|
||||
@@ -22,7 +22,9 @@ export async function pageRoute(req: HandlerRequest) {
|
||||
const block = allBlocks[blockId];
|
||||
const content = block.value.content;
|
||||
|
||||
return content ? content.filter((id: string) => !allBlocks[id]) : [];
|
||||
return content && block.value.type !== "page"
|
||||
? content.filter((id: string) => !allBlocks[id])
|
||||
: [];
|
||||
});
|
||||
|
||||
if (!pendingBlocks.length) {
|
||||
|
||||
@@ -44,7 +44,7 @@ export const getTableData = async (
|
||||
if (val) {
|
||||
const schema = collectionRows[key];
|
||||
row[schema.name] = raw ? val : getNotionValue(val, schema.type);
|
||||
if (schema.type === "person") {
|
||||
if (schema.type === "person" && row[schema.name]) {
|
||||
const users = await fetchNotionUsers(row[schema.name] as string[]);
|
||||
row[schema.name] = users as any;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user