Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat: redirectmeto

Nevo David94157b10aeb8
diff --git a/libraries/nestjs-libraries/src/integrations/social/threads.provider.ts b/libraries/nestjs-libraries/src/integrations/social/threads.provider.ts
index 2aa64e95f..5355dc5de 100644
--- a/libraries/nestjs-libraries/src/integrations/social/threads.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/threads.provider.ts
@@ -41,11 +41,11 @@ export class ThreadsProvider extends SocialAbstract implements SocialProvider {
'https://threads.net/oauth/authorize' +
`?client_id=${process.env.THREADS_APP_ID}` +
`&redirect_uri=${encodeURIComponent(
- process.env.NODE_ENV === 'development' || !process.env.NODE_ENV
- ? `https://redirectmeto.com/${process.env.FRONTEND_URL}/integrations/social/threads`
- : `${process.env.FRONTEND_URL}/integrations/social/threads${
- refresh ? `?refresh=${refresh}` : ''
- }`
+ `${
+ process?.env.FRONTEND_URL?.indexOf('https') == -1
+ ? `https://redirectmeto.com/${process?.env.FRONTEND_URL}`
+ : `${process?.env.FRONTEND_URL}`
+ }/integrations/social/threads`
)}` +
`&state=${state}` +
`&scope=${encodeURIComponent(this.scopes.join(','))}`,
@@ -104,8 +104,15 @@ export class ThreadsProvider extends SocialAbstract implements SocialProvider {
};
}
- private async checkLoaded(mediaContainerId: string, accessToken: string): Promise<boolean> {
- const {status, id, error_message} = await (await this.fetch(`https://graph.threads.net/v1.0/${mediaContainerId}?fields=status,error_message&access_token=${accessToken}`)).json();
+ private async checkLoaded(
+ mediaContainerId: string,
+ accessToken: string
+ ): Promise<boolean> {
+ const { status, id, error_message } = await (
+ await this.fetch(
+ `https://graph.threads.net/v1.0/${mediaContainerId}?fields=status,error_message&access_token=${accessToken}`
+ )
+ ).json();
console.log(status, error_message);
if (status === 'ERROR') {
throw new Error(id);
@@ -205,12 +212,8 @@ export class ThreadsProvider extends SocialAbstract implements SocialProvider {
mediaLoad.path.indexOf('.mp4') > -1 ? 'video_url' : 'image_url';
const media = new URLSearchParams({
- ...(type === 'video_url'
- ? { video_url: mediaLoad.path }
- : {}),
- ...(type === 'image_url'
- ? { image_url: mediaLoad.path }
- : {}),
+ ...(type === 'video_url' ? { video_url: mediaLoad.path } : {}),
+ ...(type === 'image_url' ? { image_url: mediaLoad.path } : {}),
is_carousel_item: 'true',
media_type:
type === 'video_url'
@@ -234,7 +237,9 @@ export class ThreadsProvider extends SocialAbstract implements SocialProvider {
medias.push(mediaId);
}
- await Promise.all(medias.map((p: string) => this.checkLoaded(p, accessToken)));
+ await Promise.all(
+ medias.map((p: string) => this.checkLoaded(p, accessToken))
+ );
const { id: containerId } = await (
await this.fetch(