Add associatedRecord to external embeds, if available (#10445)

This commit is contained in:
Eric Bailey
2026-05-07 19:08:29 -05:00
committed by GitHub
parent 9a2cabf64c
commit fa8c2224b7
6 changed files with 24 additions and 11 deletions
+1 -1
View File
@@ -81,7 +81,7 @@
"icons:optimize": "svgo -f ./assets/icons" "icons:optimize": "svgo -f ./assets/icons"
}, },
"dependencies": { "dependencies": {
"@atproto/api": "^0.19.13", "@atproto/api": "^0.19.15",
"@atproto/syntax": "0.5.2", "@atproto/syntax": "0.5.2",
"@bitdrift/react-native": "^0.6.8", "@bitdrift/react-native": "^0.6.8",
"@braintree/sanitize-url": "^6.0.2", "@braintree/sanitize-url": "^6.0.2",
+1
View File
@@ -422,6 +422,7 @@ async function resolveMedia(
title: resolvedLink.title, title: resolvedLink.title,
description: resolvedLink.description, description: resolvedLink.description,
thumb: blob, thumb: blob,
associatedRecord: resolvedLink.associatedRecord,
}, },
} }
} }
+7 -1
View File
@@ -7,7 +7,7 @@ import {
import {AtUri} from '@atproto/api' import {AtUri} from '@atproto/api'
import {POST_IMG_MAX} from '#/lib/constants' 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 {resolveShortLink} from '#/lib/link-meta/resolve-short-link'
import {downloadAndResize} from '#/lib/media/manip' import {downloadAndResize} from '#/lib/media/manip'
import { import {
@@ -35,6 +35,11 @@ type ResolvedExternalLink = {
title: string title: string
description: string description: string
thumb: ComposerImage | undefined 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 = { type ResolvedPostRecord = {
@@ -240,6 +245,7 @@ async function resolveExternal(
title: result.title ?? '', title: result.title ?? '',
description: result.description ?? '', description: result.description ?? '',
thumb: result.image ? await imageToThumb(result.image) : undefined, thumb: result.image ? await imageToThumb(result.image) : undefined,
associatedRecord: result.associatedRecord,
} }
} }
+5 -5
View File
@@ -2,7 +2,7 @@ import {type Insets, Platform} from 'react-native'
import {type AppBskyActorDefs, BSKY_LABELER_DID} from '@atproto/api' import {type AppBskyActorDefs, BSKY_LABELER_DID} from '@atproto/api'
import {type ProxyHeaderValue} from '#/state/session/agent' 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 = export const LOCAL_DEV_SERVICE =
Platform.OS === 'android' ? 'http://10.0.2.2:2583' : 'http://localhost:2583' 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 const PROD_LINK_META_PROXY = 'https://cardyb.bsky.app/v1/extract?url='
export function LINK_META_PROXY(serviceUrl: string) { export function LINK_META_PROXY(_serviceUrl: string) {
if (IS_PROD_SERVICE(serviceUrl)) { if (IS_DEV) {
return PROD_LINK_META_PROXY return STAGING_LINK_META_PROXY
} }
return STAGING_LINK_META_PROXY return PROD_LINK_META_PROXY
} }
export const STATUS_PAGE_URL = 'https://status.bsky.app/' export const STATUS_PAGE_URL = 'https://status.bsky.app/'
+6
View File
@@ -22,6 +22,11 @@ export interface LinkMeta {
title?: string title?: string
description?: string description?: string
image?: 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( export async function getLinkMeta(
@@ -89,6 +94,7 @@ export async function getLinkMeta(
meta.description = body.description meta.description = body.description
meta.image = body.image meta.image = body.image
meta.title = body.title meta.title = body.title
meta.associatedRecord = body.associated_record
if (shouldFollowRedirect) { if (shouldFollowRedirect) {
meta.url = body.url meta.url = body.url
} }
+4 -4
View File
@@ -20,10 +20,10 @@
"@jridgewell/gen-mapping" "^0.3.0" "@jridgewell/gen-mapping" "^0.3.0"
"@jridgewell/trace-mapping" "^0.3.9" "@jridgewell/trace-mapping" "^0.3.9"
"@atproto/api@^0.19.13": "@atproto/api@^0.19.15":
version "0.19.13" version "0.19.15"
resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.19.13.tgz#92c74dbc2fd84d79d62715e520da69f7c9012f66" resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.19.15.tgz#3d057b3946ca02d15dd82cda083c83a00bb8bfe9"
integrity sha512-1/LVbETVQTJFYv3Oa2Px1B/uFCRAwU0cRaoEDqdABgLHMKcWLlYJR1f9IyMdJ2JyLxcRviz6vViJI2BB8D0jcQ== integrity sha512-MDXZIEJS8iksqEYa6W6Bz0gpe6aDnHDiZUymFFvzTCqWShCCbmefv3O07GgwSqLINoAuCUKJUZWkq20wR8fa9A==
dependencies: dependencies:
"@atproto/common-web" "^0.4.21" "@atproto/common-web" "^0.4.21"
"@atproto/lexicon" "^0.6.2" "@atproto/lexicon" "^0.6.2"