Skip to content

Commit

Permalink
Update for LentilleDataResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
wxh06 authored and immccn123 committed Nov 18, 2024
1 parent 7e9b385 commit 677d8b7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
6 changes: 2 additions & 4 deletions packages/archive/src/lib/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ interface PostData {
}

interface PostListResponse {
code: 200;
currentTemplate: "DiscussList";
currentData: {
data: {
forum: ForumData | null;
publicForums: ForumData[];
posts: {
Expand All @@ -45,7 +43,7 @@ export default async function getPostList(
false,
);
const {
currentData: {
data: {
posts: { result },
},
} = (await response.json()) as PostListResponse;
Expand Down
1 change: 1 addition & 0 deletions packages/archive/src/lib/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export async function getResponse(
const response = await fetch(url, {
headers: {
"x-luogu-type": "content-only",
"x-lentille-request": "content-only",
...(cookie ? { cookie: process.env.COOKIE! } : {}),
},
cache: "no-cache",
Expand Down
6 changes: 3 additions & 3 deletions packages/archive/src/lib/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface ReplyData {
}

interface ResponseBody {
currentData: {
data: {
forum: ForumData;
post: PostData;
replies: ReplyData;
Expand Down Expand Up @@ -125,7 +125,7 @@ export async function savePost(
});
};

const { post, replies, forum } = (await fetchPage(1)).currentData;
const { post, replies, forum } = (await fetchPage(1)).data;
const postTime = new Date(post.time * 1000);

await upsertUserSnapshot(prisma, post.author);
Expand Down Expand Up @@ -184,7 +184,7 @@ export async function savePost(
)[0];
for (let i = Math.min(pages, maxPages); i > 0; i -= 1) {
// eslint-disable-next-line no-await-in-loop
const { replies: newReplies } = (await fetchPage(i)).currentData;
const { replies: newReplies } = (await fetchPage(i)).data;
// eslint-disable-next-line no-await-in-loop
await saveReplies(newReplies.result);
if (newReplies.result[newReplies.result.length - 1].id <= lastReply)
Expand Down

0 comments on commit 677d8b7

Please sign in to comment.