fix(route): zhihu private answers (#12379)

* fix(route): zhihu answers

* fix: more robust caching
This commit is contained in:
Tony 2023-04-23 10:37:32 -07:00 committed by GitHub
parent b088a9875a
commit 75fc439daf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 9 deletions

View File

@ -19,16 +19,20 @@ module.exports = async (ctx) => {
let name = data[0].author.name;
if (name === '知乎用户') {
const info = await got({
method: 'get',
url: `https://www.zhihu.com/api/v4/members/${id}/activities?limit=1`,
headers: {
...utils.header,
Referer: `https://www.zhihu.com/people/${id}/activities`,
Authorization: 'oauth c3cef7c66a1843f8b3a9e6a1e3160e20', // hard-coded in js
},
const userProfile = await ctx.cache.tryGet(`zhihu:profile:${id}`, async () => {
const apiPath = `/api/v4/profile/${id}/infinity`;
const { data } = await got({
method: 'get',
url: `https://www.zhihu.com${apiPath}`,
headers: {
...utils.header,
Referer: `https://www.zhihu.com/people/${id}`,
},
});
return data.data;
});
name = info.data.data[0].actor.name;
name = userProfile.name;
}
const items = await Promise.all(