Skip to content

Commit 4186d64

Browse files
committed
fix: fix issue with validateRecord not validating bsky posts
post.record is a json object and its strings aren't typed. ValidateRecord requires there to be a `BlobRef` type on the thumb field. Since there wasn't, the validation failed. jsonToLex will type our json string so instead of an untyped Object for the thumb field, it will now be a BlobRef.
1 parent 60825d6 commit 4186d64

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

server/api/atproto/bluesky-comments.get.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
import { BlueSkyUriSchema } from '#shared/schemas/atproto'
1010
import { CACHE_MAX_AGE_ONE_MINUTE, BLUESKY_API, AT_URI_REGEX } from '#shared/utils/constants'
1111

12+
import { jsonToLex } from '@atproto/api'
13+
1214
type ThreadResponse = { thread: AppBskyFeedDefs.ThreadViewPost }
1315

1416
type LikesResponse = {
@@ -136,10 +138,11 @@ function parseThread(thread: AppBskyFeedDefs.ThreadViewPost): Comment | null {
136138

137139
const { post } = thread
138140

139-
const recordValidation = AppBskyFeedPost.validateRecord(post.record)
141+
// This casts our external.thumb as a blobRef which is needed to validateRecord
142+
const lexPostRecord = jsonToLex(post.record)
143+
const recordValidation = AppBskyFeedPost.validateRecord(lexPostRecord)
140144

141145
if (!recordValidation.success) return null
142-
143146
const record = recordValidation.value
144147

145148
const replies: Comment[] = []

0 commit comments

Comments
 (0)