From fa8c2224b7b6e9ff33cd6f6febf1e2d8ba02716a Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 7 May 2026 19:08:29 -0500 Subject: [PATCH] Add `associatedRecord` to external embeds, if available (#10445) --- package.json | 2 +- src/lib/api/index.ts | 1 + src/lib/api/resolve.ts | 8 +++++++- src/lib/constants.ts | 10 +++++----- src/lib/link-meta/link-meta.ts | 6 ++++++ yarn.lock | 8 ++++---- 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 494ec12f2f..78d371f303 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "icons:optimize": "svgo -f ./assets/icons" }, "dependencies": { - "@atproto/api": "^0.19.13", + "@atproto/api": "^0.19.15", "@atproto/syntax": "0.5.2", "@bitdrift/react-native": "^0.6.8", "@braintree/sanitize-url": "^6.0.2", diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts index 1973afb3c1..d9a853a98e 100644 --- a/src/lib/api/index.ts +++ b/src/lib/api/index.ts @@ -422,6 +422,7 @@ async function resolveMedia( title: resolvedLink.title, description: resolvedLink.description, thumb: blob, + associatedRecord: resolvedLink.associatedRecord, }, } } diff --git a/src/lib/api/resolve.ts b/src/lib/api/resolve.ts index 1b798bd85b..fdf9878857 100644 --- a/src/lib/api/resolve.ts +++ b/src/lib/api/resolve.ts @@ -7,7 +7,7 @@ import { import {AtUri} from '@atproto/api' import {POST_IMG_MAX} from '#/lib/constants' -import {getLinkMeta} from '#/lib/link-meta/link-meta' +import {getLinkMeta, type LinkMeta} from '#/lib/link-meta/link-meta' import {resolveShortLink} from '#/lib/link-meta/resolve-short-link' import {downloadAndResize} from '#/lib/media/manip' import { @@ -35,6 +35,11 @@ type ResolvedExternalLink = { title: string description: string thumb: ComposerImage | undefined + /** + * The AT-URI of the Atmosphere record representing this external content, if + * it exists. Example: a site.standard.document record. + */ + associatedRecord?: LinkMeta['associatedRecord'] } type ResolvedPostRecord = { @@ -240,6 +245,7 @@ async function resolveExternal( title: result.title ?? '', description: result.description ?? '', thumb: result.image ? await imageToThumb(result.image) : undefined, + associatedRecord: result.associatedRecord, } } diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 7a5b74843b..80e697ace2 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -2,7 +2,7 @@ import {type Insets, Platform} from 'react-native' import {type AppBskyActorDefs, BSKY_LABELER_DID} from '@atproto/api' import {type ProxyHeaderValue} from '#/state/session/agent' -import {BLUESKY_PROXY_DID, CHAT_PROXY_DID} from '#/env' +import {BLUESKY_PROXY_DID, CHAT_PROXY_DID, IS_DEV} from '#/env' export const LOCAL_DEV_SERVICE = Platform.OS === 'android' ? 'http://10.0.2.2:2583' : 'http://localhost:2583' @@ -107,12 +107,12 @@ export const STAGING_LINK_META_PROXY = export const PROD_LINK_META_PROXY = 'https://cardyb.bsky.app/v1/extract?url=' -export function LINK_META_PROXY(serviceUrl: string) { - if (IS_PROD_SERVICE(serviceUrl)) { - return PROD_LINK_META_PROXY +export function LINK_META_PROXY(_serviceUrl: string) { + if (IS_DEV) { + return STAGING_LINK_META_PROXY } - return STAGING_LINK_META_PROXY + return PROD_LINK_META_PROXY } export const STATUS_PAGE_URL = 'https://status.bsky.app/' diff --git a/src/lib/link-meta/link-meta.ts b/src/lib/link-meta/link-meta.ts index 3d9a695f05..37292f5293 100644 --- a/src/lib/link-meta/link-meta.ts +++ b/src/lib/link-meta/link-meta.ts @@ -22,6 +22,11 @@ export interface LinkMeta { title?: string description?: string image?: string + /** + * The AT-URI of the Atmosphere record representing this external content, if + * it exists. Example: a site.standard.document record. + */ + associatedRecord?: string } export async function getLinkMeta( @@ -89,6 +94,7 @@ export async function getLinkMeta( meta.description = body.description meta.image = body.image meta.title = body.title + meta.associatedRecord = body.associated_record if (shouldFollowRedirect) { meta.url = body.url } diff --git a/yarn.lock b/yarn.lock index f8ffddd6a0..22dc1281b1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -20,10 +20,10 @@ "@jridgewell/gen-mapping" "^0.3.0" "@jridgewell/trace-mapping" "^0.3.9" -"@atproto/api@^0.19.13": - version "0.19.13" - resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.19.13.tgz#92c74dbc2fd84d79d62715e520da69f7c9012f66" - integrity sha512-1/LVbETVQTJFYv3Oa2Px1B/uFCRAwU0cRaoEDqdABgLHMKcWLlYJR1f9IyMdJ2JyLxcRviz6vViJI2BB8D0jcQ== +"@atproto/api@^0.19.15": + version "0.19.15" + resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.19.15.tgz#3d057b3946ca02d15dd82cda083c83a00bb8bfe9" + integrity sha512-MDXZIEJS8iksqEYa6W6Bz0gpe6aDnHDiZUymFFvzTCqWShCCbmefv3O07GgwSqLINoAuCUKJUZWkq20wR8fa9A== dependencies: "@atproto/common-web" "^0.4.21" "@atproto/lexicon" "^0.6.2"