diff --git a/infra/api/src/index.ts b/infra/api/src/index.ts index 72cd98c..9b31fe3 100644 --- a/infra/api/src/index.ts +++ b/infra/api/src/index.ts @@ -673,7 +673,7 @@ async function fanInExistingPosts(readerDid: string, authorDid: string, publicat const postRkey = (post.SK as string).slice('p#'.length); const item: Record = { PK: `u#${readerDid}#timeline`, - SK: `${post.publishedAt as string}#${postRkey}`, + SK: `${new Date(Math.min(new Date(post.publishedAt as string).getTime(), Date.now())).toISOString()}#${postRkey}`, entityType: 'timeline-item', authorDid, rkey: postRkey, diff --git a/infra/backfill/src/index.ts b/infra/backfill/src/index.ts index adfdc9e..9124716 100644 --- a/infra/backfill/src/index.ts +++ b/infra/backfill/src/index.ts @@ -171,7 +171,7 @@ async function upsertDocument( PK: `u#${did}#post`, SK: `p#${rkey}`, GSI1PK: 'blog-post#published', - GSI1SK: `${record.publishedAt}#${rkey}`, + GSI1SK: `${new Date(Math.min(new Date(record.publishedAt).getTime(), Date.now())).toISOString()}#${rkey}`, entityType: 'blog-post', visibility: 'published', atUri: `at://${did}/site.standard.document/${rkey}`, @@ -231,7 +231,7 @@ async function fanInExistingPosts( const postRkey = (post.SK as string).slice('p#'.length) const item: Record = { PK: `u#${readerDid}#timeline`, - SK: `${post.publishedAt as string}#${postRkey}`, + SK: `${new Date(Math.min(new Date(post.publishedAt as string).getTime(), Date.now())).toISOString()}#${postRkey}`, entityType: 'timeline-item', authorDid, rkey: postRkey, diff --git a/infra/indexer/src/index.ts b/infra/indexer/src/index.ts index d30c843..f7f9c84 100644 --- a/infra/indexer/src/index.ts +++ b/infra/indexer/src/index.ts @@ -308,7 +308,7 @@ async function fanOutToTimeline( const readerDid = (subscriber.SK as string).slice('u#'.length) const item: Record = { PK: `u#${readerDid}#timeline`, - SK: `${record.publishedAt}#${rkey}`, + SK: `${new Date(Math.min(new Date(record.publishedAt).getTime(), Date.now())).toISOString()}#${rkey}`, entityType: 'timeline-item', authorDid, rkey, @@ -357,7 +357,7 @@ async function fanInExistingPosts(readerDid: string, authorDid: string, publicat const postRkey = (post.SK as string).slice('p#'.length) const item: Record = { PK: `u#${readerDid}#timeline`, - SK: `${post.publishedAt as string}#${postRkey}`, + SK: `${new Date(Math.min(new Date(post.publishedAt as string).getTime(), Date.now())).toISOString()}#${postRkey}`, entityType: 'timeline-item', authorDid, rkey: postRkey,