feat: remove concurrency from authentication

This commit is contained in:
Nevo David 2025-08-04 12:30:28 +07:00
parent 8e06b081e8
commit 806dba19c3
5 changed files with 15 additions and 16 deletions

View File

@ -428,7 +428,7 @@ export class FacebookProvider extends SocialAbstract implements SocialProvider {
const since = dayjs().subtract(date, 'day').unix();
const { data } = await (
await this.fetch(
await fetch(
`https://graph.facebook.com/v20.0/${id}/insights?metric=page_impressions_unique,page_posts_impressions_unique,page_post_engagements,page_daily_follows,page_video_views&access_token=${accessToken}&period=day&since=${since}&until=${until}`
)
).json();

View File

@ -385,7 +385,7 @@ export class InstagramProvider
async pages(accessToken: string) {
const { data } = await (
await this.fetch(
await fetch(
`https://graph.facebook.com/v20.0/me/accounts?fields=id,instagram_business_account,username,name,picture.type(large)&access_token=${accessToken}&limit=500`
)
).json();
@ -397,7 +397,7 @@ export class InstagramProvider
return {
pageId: p.id,
...(await (
await this.fetch(
await fetch(
`https://graph.facebook.com/v20.0/${p.instagram_business_account.id}?fields=name,profile_picture_url&access_token=${accessToken}&limit=500`
)
).json()),
@ -430,7 +430,6 @@ export class InstagramProvider
)
).json();
console.log(id, name, profile_picture_url, username);
return {
id,
name,
@ -667,13 +666,13 @@ export class InstagramProvider
const since = dayjs().subtract(date, 'day').unix();
const { data, ...all } = await (
await this.fetch(
await fetch(
`https://${type}/v21.0/${id}/insights?metric=follower_count,reach&access_token=${accessToken}&period=day&since=${since}&until=${until}`
)
).json();
const { data: data2, ...all2 } = await (
await this.fetch(
await fetch(
`https://${type}/v21.0/${id}/insights?metric_type=total_value&metric=likes,views,comments,shares,saves,replies&access_token=${accessToken}&period=day&since=${since}&until=${until}`
)
).json();

View File

@ -35,13 +35,13 @@ export class InstagramStandaloneProvider
async refreshToken(refresh_token: string): Promise<AuthTokenDetails> {
const { access_token } = await (
await this.fetch(
await fetch(
`https://graph.instagram.com/refresh_access_token?grant_type=ig_refresh_token&access_token=${refresh_token}`
)
).json();
const { user_id, name, username, profile_picture_url } = await (
await this.fetch(
await fetch(
`https://graph.instagram.com/v21.0/me?fields=user_id,username,name,profile_picture_url&access_token=${access_token}`
)
).json();
@ -97,14 +97,14 @@ export class InstagramStandaloneProvider
formData.append('code', params.code);
const getAccessToken = await (
await this.fetch('https://api.instagram.com/oauth/access_token', {
await fetch('https://api.instagram.com/oauth/access_token', {
method: 'POST',
body: formData,
})
).json();
const { access_token, expires_in, ...all } = await (
await this.fetch(
await fetch(
'https://graph.instagram.com/access_token' +
'?grant_type=ig_exchange_token' +
`&client_id=${process.env.INSTAGRAM_APP_ID}` +
@ -116,7 +116,7 @@ export class InstagramStandaloneProvider
this.checkScopes(this.scopes, getAccessToken.permissions);
const { user_id, name, username, profile_picture_url } = await (
await this.fetch(
await fetch(
`https://graph.instagram.com/v21.0/me?fields=user_id,username,name,profile_picture_url&access_token=${access_token}`
)
).json();

View File

@ -30,7 +30,7 @@ export class LinkedinPageProvider
'r_organization_social',
];
editor = 'normal' as const;
override editor = 'normal' as const;
override async refreshToken(
refresh_token: string
@ -264,7 +264,7 @@ export class LinkedinPageProvider
const startDate = dayjs().subtract(date, 'days').unix() * 1000;
const { elements }: { elements: Root[]; paging: any } = await (
await this.fetch(
await fetch(
`https://api.linkedin.com/v2/organizationPageStatistics?q=organization&organization=${encodeURIComponent(
`urn:li:organization:${id}`
)}&timeIntervals=(timeRange:(start:${startDate},end:${endDate}),timeGranularityType:DAY)`,
@ -279,7 +279,7 @@ export class LinkedinPageProvider
).json();
const { elements: elements2 }: { elements: Root[]; paging: any } = await (
await this.fetch(
await fetch(
`https://api.linkedin.com/v2/organizationalEntityFollowerStatistics?q=organizationalEntity&organizationalEntity=${encodeURIComponent(
`urn:li:organization:${id}`
)}&timeIntervals=(timeRange:(start:${startDate},end:${endDate}),timeGranularityType:DAY)`,
@ -294,7 +294,7 @@ export class LinkedinPageProvider
).json();
const { elements: elements3 }: { elements: Root[]; paging: any } = await (
await this.fetch(
await fetch(
`https://api.linkedin.com/v2/organizationalEntityShareStatistics?q=organizationalEntity&organizationalEntity=${encodeURIComponent(
`urn:li:organization:${id}`
)}&timeIntervals=(timeRange:(start:${startDate},end:${endDate}),timeGranularityType:DAY)`,

View File

@ -289,7 +289,7 @@ export class PinterestProvider
const {
all: { daily_metrics },
} = await (
await this.fetch(
await fetch(
`https://api.pinterest.com/v5/user_account/analytics?start_date=${since}&end_date=${until}`,
{
method: 'GET',