From a03b8042285a1fbfe347c74d72f81dcf90ddd76a Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Thu, 24 Oct 2024 21:45:51 +0100 Subject: [PATCH] fix: use bsky types from `@atproto/api` --- modules/runtime/server/_social/bluesky.get.ts | 50 ++----------------- 1 file changed, 3 insertions(+), 47 deletions(-) diff --git a/modules/runtime/server/_social/bluesky.get.ts b/modules/runtime/server/_social/bluesky.get.ts index 7038d40e..98952a4a 100644 --- a/modules/runtime/server/_social/bluesky.get.ts +++ b/modules/runtime/server/_social/bluesky.get.ts @@ -1,51 +1,7 @@ +import type { AppBskyFeedPost, AppBskyEmbedImages } from '@atproto/api' import { AtpAgent } from '@atproto/api' import MagicString from 'magic-string' -interface PostRecord { - $type: 'app.bsky.feed.post' - createdAt: string - facets: { - features: Array< - | { - $type: 'app.bsky.richtext.facet#link' - uri: string - } - | { - $type: 'app.bsky.richtext.facet#mention' - did: string - } - > - index: { - byteEnd: number - byteStart: number - } - }[] - embed?: { - $type: 'app.bsky.embed.images' - images: { - alt: string - image: { - $type: 'blob' - mimeType: 'image/jpeg' - ref: { - $link: string - } - size: number - } - }[] - } - text: string -} - -interface PostEmbed { - $type: 'app.bsky.embed.images#view' - images: { - alt: string - fullsize: string - thumb: string - }[] -} - export default defineLazyEventHandler(async () => { const { identifier, password } = useRuntimeConfig().social.networks.bluesky const agent = new AtpAgent({ service: 'https://bsky.social' }) @@ -68,8 +24,8 @@ export default defineLazyEventHandler(async () => { && !p.reply, ) .map(p => { - const post = p.post.record as PostRecord - const embed = p.post.embed as PostEmbed | undefined + const post = p.post.record as AppBskyFeedPost.Record + const embed = p.post.embed as AppBskyEmbedImages.Main | undefined const text = new MagicString(post.text) for (const facet of post.facets || []) { const startIndex = [...post.text].findIndex( -- 2.51.2