Skip to content

Commit

Permalink
Store reply summary instead
Browse files Browse the repository at this point in the history
The Bsky API in fact returns all replies, which is a non-starter for popular posts which may have hundreds or thousands – we don't want to store a separate note for each. Instead, we now store a note with the number of direct replies at the time of storage, as an ISO datetime.
  • Loading branch information
urschrei committed Dec 6, 2024
1 parent 521eb97 commit 3849c25
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Bluesky.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2024-12-06 01:13:45"
"lastUpdated": "2024-12-06 01:20:16"
}

/*
Expand Down Expand Up @@ -89,16 +89,14 @@ async function scrapeAPI(doc, url) {
// Handle embedded quote records (if any)
if (post.embed && post.embed.record && post.embed.record.value) {
let embeddedPost = post.embed.record.value;
item.notes.push(`Quoting this post by @${post.embed.record.author.handle}: "${embeddedPost.text}"`);
item.notes.push(`This post is quoting a post by @${post.embed.record.author.handle}: "${embeddedPost.text}"`);
}

// Handle replies (if any)
if (data.thread.replies && data.thread.replies.length > 0) {
for (let reply of data.thread.replies) {
if (reply.post && reply.post.record) {
item.notes.push(`Reply by @${reply.post.author.handle}: "${reply.post.record.text}"`);
}
}
const date = new Date()
const utcStr = date.toUTCString()
item.notes.push(`This post had ${data.thread.replies.length} direct replies as of ${utcStr}`);
}
item.attachments.push({ document: doc, title: "Snapshot" });
item.complete();
Expand Down

0 comments on commit 3849c25

Please sign in to comment.