generated from nhcarrigan/template
fix: bluesky threading, prep for linkedin
We are stuck waiting for scopes approval at the moment.
This commit is contained in:
@@ -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(", ")}`
|
||||
|
||||
Reference in New Issue
Block a user