remove unfinished image support
This commit is contained in:
parent
0231851726
commit
4738b41b6f
1 changed files with 3 additions and 39 deletions
42
main.js
42
main.js
|
@ -56,39 +56,8 @@ async function main() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function postToBluesky(textParts, images) {
|
async function postToBluesky(textParts) {
|
||||||
const blueSkyImages = []
|
const rootMessageResponse = await agent.post(await createBlueskyMessage(textParts[0]));
|
||||||
/*const blueSkyImages = await images.reduce(async (list, {url, alt}) => {
|
|
||||||
const {data: imageData} = await axios.get(url, {
|
|
||||||
responseType: 'arraybuffer',
|
|
||||||
});
|
|
||||||
//const base64Data = Buffer.from(imageData, 'binary').toString('base64')
|
|
||||||
console.log('🐈', url)
|
|
||||||
|
|
||||||
// new Uint8Array(imageData), {encoding: 'utf8'}
|
|
||||||
const {data} = await agent.uploadBlob(url);
|
|
||||||
|
|
||||||
return [
|
|
||||||
...list,
|
|
||||||
{
|
|
||||||
alt,
|
|
||||||
image: data.blob,
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}, []);*/
|
|
||||||
|
|
||||||
const rootMessageResponse = await agent.post({
|
|
||||||
...(await createBlueskyMessage(textParts[0])),
|
|
||||||
...(blueSkyImages.length > 0
|
|
||||||
? {
|
|
||||||
embed: {
|
|
||||||
type: 'app.bsky.embed.images',
|
|
||||||
images: blueSkyImages,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
: {}
|
|
||||||
),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (textParts.length === 1) return;
|
if (textParts.length === 1) return;
|
||||||
|
|
||||||
|
@ -159,12 +128,7 @@ async function main() {
|
||||||
try {
|
try {
|
||||||
console.log('📧 posting to BlueSky', currentTimestampId)
|
console.log('📧 posting to BlueSky', currentTimestampId)
|
||||||
const textParts = splitText(removeHtmlTags(item.object.content), 300);
|
const textParts = splitText(removeHtmlTags(item.object.content), 300);
|
||||||
|
postToBluesky(textParts);
|
||||||
const images = item.object.attachment
|
|
||||||
.filter(attachment => attachment.type === 'Document' && attachment.mediaType.startsWith('image/'))
|
|
||||||
.map(({name: alt, url}) => ({ alt, url }));
|
|
||||||
|
|
||||||
postToBluesky(textParts, images);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('🔥 can\'t post to Bluesky', currentTimestampId, error)
|
console.error('🔥 can\'t post to Bluesky', currentTimestampId, error)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue