Skip to content

Commit

Permalink
fix(sync): make inReplyToStatusId more reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
louisgrasset committed Oct 22, 2024
1 parent 7a87d90 commit c143ced
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/helpers/post/make-bluesky-post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ export const makeBlueskyPost = async (

// Get in reply post references
let replyPost = undefined;
if (tweet.inReplyToStatus) {
if (tweet.inReplyToStatusId) {
const replyData = await getCachedPostChunk<BlueskyCacheChunk>(
Platform.BLUESKY,
"last",
tweet.inReplyToStatus.id,
tweet.inReplyToStatusId,
);
replyPost = replyData
? await client
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/post/make-mastodon-post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export const makeMastodonPost = async (

// Get in reply post references
let inReplyToId = undefined;
if (tweet.inReplyToStatus) {
if (tweet.inReplyToStatusId) {
// Retrieve the potentially already synced post references
const existingPost =
cachedPosts[tweet.inReplyToStatus.id!]?.[Platform.MASTODON];
cachedPosts[tweet.inReplyToStatusId]?.[Platform.MASTODON];
// Set inReplyToId to the last chunk reference of the existing post
inReplyToId = existingPost
? existingPost[existingPost.length - 1]
Expand Down
4 changes: 3 additions & 1 deletion src/helpers/tweet/get-eligible-tweet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export const getEligibleTweet = async (
const eligibleTweet = {
...tweet,
inReplyToStatus: isSelfReply ? tweet.inReplyToStatus : undefined,
inReplyToStatusId: isSelfReply ? tweet.inReplyToStatusId : undefined,
inReplyToStatusId: isSelfReply
? (tweet.inReplyToStatusId ?? tweet.inReplyToStatus?.id)
: undefined,
quotedStatus: isSelfQuote ? tweet.quotedStatus : undefined,
quotedStatusId: isSelfQuote ? tweet.quotedStatusId : undefined,
};
Expand Down

0 comments on commit c143ced

Please sign in to comment.