Don't validate embeds when traversing cache (#2174)

zio/stable
dan 2023-12-11 22:30:32 +00:00 committed by GitHub
parent 0f7dbbba4a
commit 52ffd6aabb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 12 deletions

View File

@ -25,26 +25,18 @@ export function truncateAndInvalidate<T = any>(
export function getEmbeddedPost(
v: unknown,
): AppBskyEmbedRecord.ViewRecord | undefined {
if (
AppBskyEmbedRecord.isView(v) &&
AppBskyEmbedRecord.validateView(v).success
) {
if (AppBskyEmbedRecord.isView(v)) {
if (
AppBskyEmbedRecord.isViewRecord(v.record) &&
AppBskyFeedPost.isRecord(v.record.value) &&
AppBskyFeedPost.validateRecord(v.record.value).success
AppBskyFeedPost.isRecord(v.record.value)
) {
return v.record
}
}
if (
AppBskyEmbedRecordWithMedia.isView(v) &&
AppBskyEmbedRecordWithMedia.validateView(v).success
) {
if (AppBskyEmbedRecordWithMedia.isView(v)) {
if (
AppBskyEmbedRecord.isViewRecord(v.record.record) &&
AppBskyFeedPost.isRecord(v.record.record.value) &&
AppBskyFeedPost.validateRecord(v.record.record.value).success
AppBskyFeedPost.isRecord(v.record.record.value)
) {
return v.record.record
}