fixed bugs

This commit is contained in:
Tomoya Matsuura(MacBookPro) 2024-03-04 13:14:49 +09:00
parent 1981c47fcd
commit 85058be1c2
2 changed files with 9 additions and 9 deletions

View File

@ -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
- fixed the problem that quote is not unescaped correctly
- added Docker image and compose file

15
main.js
View File

@ -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;