Skip to content

Commit

Permalink
refactor(route/twitter): keep twitter graphql endpoints consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudoyu committed Nov 29, 2024
1 parent 3f12f92 commit 3e102d5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/routes/twitter/api/web-api/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { baseUrl, gqlMap, gqlFeatures, gqlMapThirdParty } from './constants';
import { baseUrl, gqlMap, gqlFeatures } from './constants';
import { config } from '@/config';
import cache from '@/utils/cache';
import { twitterGot, paginationTweets, gatherLegacyFromData } from './utils';
Expand All @@ -24,7 +24,7 @@ const getUserData = (id) =>
};

if (config.twitter.thirdPartyApi) {
const endpoint = id.startsWith('+') ? gqlMapThirdParty.UserByRestId : gqlMapThirdParty.UserByScreenName;
const endpoint = id.startsWith('+') ? gqlMap.UserByRestId : gqlMap.UserByScreenName;

return ofetch(`${config.twitter.thirdPartyApi}${endpoint}`, {
method: 'GET',
Expand Down
6 changes: 1 addition & 5 deletions lib/routes/twitter/api/web-api/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ const graphQLEndpointsPlain = [

const gqlMap = Object.fromEntries(graphQLEndpointsPlain.map((endpoint) => [endpoint.split('/')[3].replace(/V2$|Query$|QueryV2$/, ''), endpoint]));

const graphQLEndpointsThirdParty = ['/graphql/xxxxxxx/UserByScreenName', '/graphql/xxxxxxx/UserByRestId'];

const gqlMapThirdParty = Object.fromEntries(graphQLEndpointsThirdParty.map((endpoint) => [endpoint.split('/')[3].replace(/V2$|Query$|QueryV2$/, ''), endpoint]));

const gqlFeatureUser = {
hidden_profile_subscriptions_enabled: true,
rweb_tipjar_consumption_enabled: true,
Expand Down Expand Up @@ -116,4 +112,4 @@ const timelineParams = {

const bearerToken = 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA';

export { baseUrl, gqlMap, gqlMapThirdParty, gqlFeatures, timelineParams, bearerToken };
export { baseUrl, gqlMap, gqlFeatures, timelineParams, bearerToken };

0 comments on commit 3e102d5

Please sign in to comment.