feat(twitter): try catch allow empty content
This commit is contained in:
@@ -7,7 +7,7 @@ const graphQLEndpointsPlain = [
|
||||
'/graphql/DiTkXJgLqBBxCs7zaYsbtA/HomeLatestTimeline',
|
||||
'/graphql/bt4TKuFz4T7Ckk-VvQVSow/UserTweetsAndReplies',
|
||||
'/graphql/dexO_2tohK86JDudXXG3Yw/UserMedia',
|
||||
'/graphql/tD8zKvQzwY3kdx5yz6YmOw/UserByRestId',
|
||||
'/graphql/Qw77dDjp9xCpUY-AXwt-yQ/UserByRestId',
|
||||
'/graphql/UN1i3zUiCWa-6r-Uaho4fw/SearchTimeline',
|
||||
'/graphql/Pa45JvqZuKcW1plybfgBlQ/ListLatestTweetsTimeline',
|
||||
'/graphql/QuBlQ6SxNAQCt6-kBiCXCQ/TweetDetail',
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Route, ViewType } from '@/types';
|
||||
import api from './api';
|
||||
import utils from './utils';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/media/:id/:routeParams?',
|
||||
@@ -47,7 +48,12 @@ async function handler(ctx) {
|
||||
|
||||
await api.init();
|
||||
const userInfo = await api.getUser(id);
|
||||
const data = await api.getUserMedia(id, params);
|
||||
let data;
|
||||
try {
|
||||
data = await api.getUserMedia(id, params);
|
||||
} catch (error) {
|
||||
logger.debug(error);
|
||||
}
|
||||
const profileImageUrl = userInfo?.profile_image_url || userInfo?.profile_image_url_https;
|
||||
|
||||
return {
|
||||
@@ -55,8 +61,11 @@ async function handler(ctx) {
|
||||
link: `https://x.com/${userInfo?.screen_name}/media`,
|
||||
image: profileImageUrl.replace(/_normal.jpg$/, '.jpg'),
|
||||
description: userInfo?.description,
|
||||
item: utils.ProcessFeed(ctx, {
|
||||
data,
|
||||
}),
|
||||
item:
|
||||
data &&
|
||||
utils.ProcessFeed(ctx, {
|
||||
data,
|
||||
}),
|
||||
allowEmpty: true,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -58,9 +58,14 @@ async function handler(ctx) {
|
||||
|
||||
await api.init();
|
||||
const userInfo = await api.getUser(id);
|
||||
let data = await (exclude_replies ? api.getUserTweets(id, params) : api.getUserTweetsAndReplies(id, params));
|
||||
if (!include_rts) {
|
||||
data = utils.excludeRetweet(data);
|
||||
let data;
|
||||
try {
|
||||
data = await (exclude_replies ? api.getUserTweets(id, params) : api.getUserTweetsAndReplies(id, params));
|
||||
if (!include_rts) {
|
||||
data = utils.excludeRetweet(data);
|
||||
}
|
||||
} catch (error) {
|
||||
logger.debug(error);
|
||||
}
|
||||
|
||||
const profileImageUrl = userInfo?.profile_image_url || userInfo?.profile_image_url_https;
|
||||
@@ -70,8 +75,11 @@ async function handler(ctx) {
|
||||
link: `https://x.com/${userInfo?.screen_name}`,
|
||||
image: profileImageUrl.replace(/_normal.jpg$/, '.jpg'),
|
||||
description: userInfo?.description,
|
||||
item: utils.ProcessFeed(ctx, {
|
||||
data,
|
||||
}),
|
||||
item:
|
||||
data &&
|
||||
utils.ProcessFeed(ctx, {
|
||||
data,
|
||||
}),
|
||||
allowEmpty: true,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user