diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts index ede2fea64..faa16c921 100644 --- a/src/lib/api/index.ts +++ b/src/lib/api/index.ts @@ -14,6 +14,7 @@ import { type ComAtprotoLabelDefs, type ComAtprotoRepoApplyWrites, type ComAtprotoRepoStrongRef, + jsonToLex, RichText, } from '@atproto/api' import {TID} from '@atproto/common-web' @@ -436,7 +437,7 @@ async function resolveReply(agent: AtpAgent, replyTo: string) { }) return undefined } - const data = (await res.json()) as { + const data = jsonToLex(await res.json()) as { post?: { uri: string cid: string diff --git a/src/lib/api/resolve.ts b/src/lib/api/resolve.ts index ffae83152..5588b57d3 100644 --- a/src/lib/api/resolve.ts +++ b/src/lib/api/resolve.ts @@ -4,7 +4,7 @@ import { type AtpAgent, type ComAtprotoRepoStrongRef, } from '@atproto/api' -import {AtUri} from '@atproto/api' +import {AtUri, jsonToLex} from '@atproto/api' import {DM_SERVICE_HEADERS, IMAGE_SIZE_CONFIG_2K_1MB} from '#/lib/constants' import {getLinkMeta, type LinkMeta} from '#/lib/link-meta/link-meta' @@ -128,7 +128,7 @@ async function getCommunityPost(agent: AtpAgent, uri: string) { if (!res.ok) { throw new Error(`getCommunityPost ${res.status}`) } - const data = (await res.json()) as {post?: any} + const data = jsonToLex(await res.json()) as {post?: any} if (!data.post) throw new Error('getCommunityPost: post not found') return data.post } diff --git a/src/state/queries/community-feed.ts b/src/state/queries/community-feed.ts index 473067045..f107abd7b 100644 --- a/src/state/queries/community-feed.ts +++ b/src/state/queries/community-feed.ts @@ -3,6 +3,7 @@ import { type AppBskyFeedDefs, type AppBskyFeedPost, AtUri, + jsonToLex, moderatePost, type ModerationDecision, } from '@atproto/api' @@ -75,7 +76,7 @@ export function useCommunityFeedQuery(actor: string | undefined) { if (!res.ok) { throw new Error(`getCommunityFeed failed: ${res.status}`) } - return (await res.json()) as CommunityFeedPage + return jsonToLex(await res.json()) as CommunityFeedPage }, initialPageParam: undefined, getNextPageParam: lastPage => lastPage.cursor, @@ -112,7 +113,7 @@ export function useCommunityTimelineQuery(enabled: boolean) { if (!res.ok) { throw new Error(`getCommunityTimeline failed: ${res.status}`) } - return (await res.json()) as CommunityFeedPage + return jsonToLex(await res.json()) as CommunityFeedPage }, initialPageParam: undefined, getNextPageParam: lastPage => lastPage.cursor, @@ -139,7 +140,9 @@ export function useCommunityPostQuery(uri: string | undefined) { if (!res.ok) { throw new Error(`getCommunityPost failed: ${res.status}`) } - const data = (await res.json()) as {post: AppBskyFeedDefs.PostView} + const data = jsonToLex(await res.json()) as { + post: AppBskyFeedDefs.PostView + } return data.post }, enabled: !!uri, diff --git a/src/state/queries/notifications/util.ts b/src/state/queries/notifications/util.ts index d7453b5a8..d56c87b31 100644 --- a/src/state/queries/notifications/util.ts +++ b/src/state/queries/notifications/util.ts @@ -8,6 +8,7 @@ import { type AppBskyNotificationListNotifications, type AtpAgent, hasMutedWord, + jsonToLex, moderateNotification, type ModerationOpts, } from '@atproto/api' @@ -248,7 +249,9 @@ async function fetchSubjects( }) .then(async res => { if (!res.ok) return undefined - const data = (await res.json()) as {post?: AppBskyFeedDefs.PostView} + const data = jsonToLex(await res.json()) as { + post?: AppBskyFeedDefs.PostView + } return data.post }) .catch(() => undefined),