fix: bluesky threading, prep for linkedin

We are stuck waiting for scopes approval at the moment.
This commit is contained in:
2025-12-23 15:47:54 -08:00
parent 0cef2f3429
commit 5925f3aec0
4 changed files with 539 additions and 9 deletions
+24 -7
View File
@@ -11,6 +11,7 @@ import { AtpAgent } from "@atproto/api";
* @param content - The main body of the announcement.
* @returns A message indicating the success or failure of the operation.
*/
// eslint-disable-next-line max-lines-per-function, max-statements -- This is a big function.
export const announceOnBluesky = async(
content: Array<string>,
): Promise<string> => {
@@ -39,19 +40,35 @@ export const announceOnBluesky = async(
if (typeof blueskyRequest === "string") {
return `Failed to send initial post to Bluesky. ${blueskyRequest}`;
}
let { uri } = blueskyRequest;
const rootUri = blueskyRequest.uri;
const rootCid = blueskyRequest.cid;
let parentUri = rootUri;
let parentCid = rootCid;
for (const post of restOfPosts) {
// eslint-disable-next-line no-await-in-loop -- We need to do this sequentially.
const blueskyResponse = await agent.post({
replyTo: uri,
text: post,
reply: {
parent: {
cid: parentCid,
uri: parentUri,
},
root: {
cid: rootCid,
uri: rootUri,
},
},
text: post,
}).catch((error: unknown) => {
return error instanceof Error
? error.message
: String(error);
});
if (typeof blueskyResponse !== "string") {
const { uri: replyUri } = blueskyResponse;
uri = replyUri;
if (typeof blueskyResponse === "string") {
failedReplies.push(post);
continue;
}
failedReplies.push(post);
parentUri = blueskyResponse.uri;
parentCid = blueskyResponse.cid;
}
return `Successfully sent initial post to Bluesky. ${failedReplies.length > 0
? `Failed to send ${failedReplies.length.toString()} replies: ${failedReplies.join(", ")}`