Skip to content

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

fix(instagram): strip leading @ from collaborator handles

Gilad Resisi1de153704194
diff --git a/libraries/nestjs-libraries/src/integrations/social/instagram.provider.ts b/libraries/nestjs-libraries/src/integrations/social/instagram.provider.ts
index 134dc43c4..f8c9aa08c 100644
--- a/libraries/nestjs-libraries/src/integrations/social/instagram.provider.ts
+++ b/libraries/nestjs-libraries/src/integrations/social/instagram.provider.ts
@@ -605,6 +605,12 @@ export class InstagramProvider
};
}
+ // Instagram rejects collaborator handles that carry a leading @ with
+ // error_subcode 2207018, and the tag input stores whatever the user typed.
+ private stripHandle(handle: string) {
+ return handle.replace(/^@+/, '');
+ }
+
// Single, read-only status check of a media container - the polling loops
// that used to live inside post() are now driven by the post workflow.
private async igContainerStatus(
@@ -668,7 +674,9 @@ export class InstagramProvider
firstPost?.settings?.collaborators?.length && !isStory
? `&collaborators=${encodeURIComponent(
JSON.stringify(
- firstPost?.settings?.collaborators.map((p) => p.label)
+ firstPost?.settings?.collaborators.map((p) =>
+ this.stripHandle(p.label)
+ )
)
)}`
: ``;
@@ -770,8 +778,8 @@ export class InstagramProvider
message: firstPost?.message || '',
...(collaborators
? {
- collaborators: firstPost.settings.collaborators!.map(
- (p) => p.label
+ collaborators: firstPost.settings.collaborators!.map((p) =>
+ this.stripHandle(p.label)
),
}
: {}),