Add associatedRecord to external embeds, if available (#10445)
This commit is contained in:
+1
-1
@@ -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",
|
||||
|
||||
@@ -422,6 +422,7 @@ async function resolveMedia(
|
||||
title: resolvedLink.title,
|
||||
description: resolvedLink.description,
|
||||
thumb: blob,
|
||||
associatedRecord: resolvedLink.associatedRecord,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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/'
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user