fixed reply processing
This commit is contained in:
parent
049a9bec94
commit
7356c4bb93
6
main.js
6
main.js
@ -120,14 +120,14 @@ function isReplyToMyself(item) {
|
|||||||
if (uri === null) {
|
if (uri === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return uri.includes("${mastodonInstance}/users/${mastodonUser}");
|
return uri.includes(`${mastodonInstance}/users/${mastodonUser}`);
|
||||||
}
|
}
|
||||||
// Function to periodically fetch new Mastodon posts
|
// Function to periodically fetch new Mastodon posts
|
||||||
async function fetchNewPosts() {
|
async function fetchNewPosts() {
|
||||||
const response = await axios.get(`${mastodonInstance}/users/${mastodonUser}/outbox?page=true`);
|
const response = await axios.get(`${mastodonInstance}/users/${mastodonUser}/outbox?page=true`);
|
||||||
|
|
||||||
const reversed = response.data.orderedItems.filter(item => item.object.type === 'Note')
|
const reversed = response.data.orderedItems.filter(item => item.object.type === 'Note')
|
||||||
.filter(item => item.object.inReplyTo === null || isReplyToMyself(item))
|
.filter(item => isReplyToMyself(item) || item.object.inReplyTo === null)
|
||||||
.reverse();
|
.reverse();
|
||||||
|
|
||||||
let newTimestampId = 0;
|
let newTimestampId = 0;
|
||||||
@ -141,7 +141,7 @@ async function fetchNewPosts() {
|
|||||||
if (currentTimestampId > lastProcessedPostId && lastProcessedPostId != 0) {
|
if (currentTimestampId > lastProcessedPostId && lastProcessedPostId != 0) {
|
||||||
const text = removeHtmlTags(convertQuote(item.object.content));
|
const text = removeHtmlTags(convertQuote(item.object.content));
|
||||||
const images = await getImages(item);
|
const images = await getImages(item);
|
||||||
let {uri} = await postToBluesky(text, images);
|
let { uri } = await postToBluesky(text, images);
|
||||||
console.log(`posted ${item.object.id} to ${uri} . ${newTimestampId}`);
|
console.log(`posted ${item.object.id} to ${uri} . ${newTimestampId}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user