mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-23 04:34:15 -04:00
(calendar) fix bluesky bot uploading an empty stream
This commit is contained in:
parent
18ffa6dedd
commit
423cc9fb83
@ -31,6 +31,7 @@ const publishers = {
|
||||
|
||||
return tweetResponse.id_str;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Sentry.captureException(error);
|
||||
}
|
||||
},
|
||||
@ -50,6 +51,7 @@ const publishers = {
|
||||
console.log(mediaResponse);
|
||||
mediaIds.push(mediaResponse.data.id);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Sentry.captureException(error);
|
||||
}
|
||||
}
|
||||
@ -65,6 +67,7 @@ const publishers = {
|
||||
console.log(tweetResponse.data);
|
||||
return tweetResponse.data.id;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Sentry.captureException(error);
|
||||
}
|
||||
},
|
||||
@ -82,6 +85,7 @@ const publishers = {
|
||||
console.log(uploadResponse);
|
||||
media.push(uploadResponse.data.blob);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Sentry.captureException(error);
|
||||
}
|
||||
}
|
||||
@ -117,6 +121,7 @@ const publishers = {
|
||||
cid: postResponse.cid,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Sentry.captureException(error);
|
||||
}
|
||||
},
|
||||
@ -146,16 +151,18 @@ const lastPostId = {};
|
||||
}
|
||||
|
||||
fs.writeFileSync(imageTmpPath, Buffer.from(await (await fetch(image)).arrayBuffer()), { encoding: 'binary' });
|
||||
let imageStream = null;
|
||||
try {
|
||||
imageStream = fs.createReadStream(imageTmpPath);
|
||||
} catch {}
|
||||
|
||||
for (const publisher of process.argv[3].split(',')) {
|
||||
if (!publisher) {
|
||||
continue;
|
||||
}
|
||||
console.log(`Publishing: ${publisher}`);
|
||||
|
||||
let imageStream = null;
|
||||
try {
|
||||
imageStream = fs.createReadStream(imageTmpPath);
|
||||
} catch {}
|
||||
|
||||
const postId = await publishers[publisher](
|
||||
message,
|
||||
imageStream,
|
||||
@ -170,6 +177,7 @@ const lastPostId = {};
|
||||
lastPostId[publisher] = postId;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Sentry.captureException(error);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user