From 695cdc0c7f37e21257616d22c44a440357c5f82b Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 7 May 2026 16:50:34 -0500 Subject: [PATCH] Attach associatedRecord to external embeds on posts --- package.json | 2 +- src/lib/api/index.ts | 1 + src/lib/api/resolve.ts | 8 +++++++- src/lib/link-meta/link-meta.ts | 6 ++++++ yarn.lock | 8 ++++---- 5 files changed, 19 insertions(+), 6 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/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"