Replaced Snoowrap with public API calls in response to Reddit revoking API keys. This was largely done using Claude Code, extensive manual review and major version bump needed if merged into main.
This commit is contained in:
@@ -4,11 +4,11 @@ function curateComments(comments) {
|
||||
return comments.map((comment) => ({
|
||||
id: comment.id,
|
||||
url: `https://reddit.com${comment.permalink}`,
|
||||
author: comment.author.name,
|
||||
author: comment.author,
|
||||
body: comment.body,
|
||||
html: comment.body_html,
|
||||
score: comment.score,
|
||||
datetime: new Date(comment.created * 1000),
|
||||
datetime: new Date(comment.created_utc * 1000),
|
||||
edited: comment.edited,
|
||||
controversiality: comment.controversiality,
|
||||
gilded: comment.gilded,
|
||||
@@ -22,18 +22,12 @@ function curateComments(comments) {
|
||||
}
|
||||
|
||||
async function getFullPost(postId, reddit) {
|
||||
return reddit
|
||||
.getSubmission(postId)
|
||||
.expandReplies({
|
||||
limit: Infinity,
|
||||
depth: Infinity,
|
||||
})
|
||||
.fetch();
|
||||
return reddit.getSubmissionWithComments(postId);
|
||||
}
|
||||
|
||||
async function self(host, originalPost, { reddit }) {
|
||||
const post = await getFullPost(originalPost.id, reddit) || originalPost;
|
||||
const curatedComments = curateComments(post.comments);
|
||||
const { post, comments } = await getFullPost(originalPost.id, reddit);
|
||||
const curatedComments = curateComments(comments);
|
||||
|
||||
return {
|
||||
album: null,
|
||||
@@ -41,9 +35,9 @@ async function self(host, originalPost, { reddit }) {
|
||||
id: post.id,
|
||||
url: post.url,
|
||||
title: post.title,
|
||||
text: post.text,
|
||||
author: post.author.name,
|
||||
datetime: post.datetime,
|
||||
text: post.selftext,
|
||||
author: post.author,
|
||||
datetime: new Date(post.created_utc * 1000),
|
||||
comments: curatedComments,
|
||||
type: 'text/plain',
|
||||
self: true,
|
||||
|
||||
Reference in New Issue
Block a user