From 85058be1c2d78951a5d7d981bb19c6c54f6499c2 Mon Sep 17 00:00:00 2001 From: "Tomoya Matsuura(MacBookPro)" Date: Mon, 4 Mar 2024 13:14:49 +0900 Subject: [PATCH] fixed bugs --- README.md | 3 ++- main.js | 15 +++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 02a8b6b..a0bfdaa 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,5 @@ https://maurice-renck.de/hub/tooling/crosspost-from-mastodon-to-bluesky - not shown as reply-tree in bluesky, to keep the code simple. (I don't want to keep the pairs of mastodon posts and bsky posts) - embed image as raw URL text on the mastodon - uploading image with `uploadBlob` fails if the image size is under 1MB, the official limit on the docs (maybe because I'm using self-hosted PDS.) -- fixed quote is not unescaped \ No newline at end of file +- fixed the problem that quote is not unescaped correctly +- added Docker image and compose file \ No newline at end of file diff --git a/main.js b/main.js index a334775..c25e7ed 100644 --- a/main.js +++ b/main.js @@ -97,13 +97,13 @@ async function postToBluesky(text, images) { // }; // })); let completetext = text; - if (!images.empty()) { + if (images.length > 0) { completetext = text + " " + images.map(img => img.url).join(" ") } - const richText = new RichText({ completetext }); + const richText = new RichText({ text: completetext }); await richText.detectFacets(agent); - await agent.post({ + return agent.post({ text: richText.text, facets: richText.facets, }); @@ -131,8 +131,7 @@ async function fetchNewPosts() { .reverse(); let newTimestampId = 0; - - await Promise.all(reversed.map(async item => { + for (item in reversed) { const currentTimestampId = Date.parse(item.published); if (currentTimestampId > newTimestampId) { @@ -142,10 +141,10 @@ async function fetchNewPosts() { if (currentTimestampId > lastProcessedPostId && lastProcessedPostId != 0) { const text = removeHtmlTags(convertQuote(item.object.content)); const images = await getImages(item); - postToBluesky(text, images); - console.log(`posted ${item.object.id}. ${newTimestampId}`); + let {uri} = await postToBluesky(text, images); + console.log(`posted ${item.object.id} to ${uri} . ${newTimestampId}`); } - })) + } if (newTimestampId > 0) { lastProcessedPostId = newTimestampId;