diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/api/index.ts | 38 | ||||
-rw-r--r-- | src/lib/media/video/types.ts | 36 |
2 files changed, 27 insertions, 47 deletions
diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts index 94c8869a1..fa2e4ba6c 100644 --- a/src/lib/api/index.ts +++ b/src/lib/api/index.ts @@ -3,12 +3,14 @@ import { AppBskyEmbedImages, AppBskyEmbedRecord, AppBskyEmbedRecordWithMedia, + AppBskyEmbedVideo, AppBskyFeedPostgate, + AtUri, + BlobRef, BskyAgent, ComAtprotoLabelDefs, RichText, } from '@atproto/api' -import {AtUri} from '@atproto/api' import {logger} from '#/logger' import {writePostgateRecord} from '#/state/queries/postgate' @@ -43,10 +45,7 @@ interface PostOpts { uri: string cid: string } - video?: { - uri: string - cid: string - } + video?: BlobRef extLink?: ExternalEmbedDraft images?: ImageModel[] labels?: string[] @@ -61,18 +60,16 @@ export async function post(agent: BskyAgent, opts: PostOpts) { | AppBskyEmbedImages.Main | AppBskyEmbedExternal.Main | AppBskyEmbedRecord.Main + | AppBskyEmbedVideo.Main | AppBskyEmbedRecordWithMedia.Main | undefined let reply - let rt = new RichText( - {text: opts.rawText.trimEnd()}, - { - cleanNewlines: true, - }, - ) + let rt = new RichText({text: opts.rawText.trimEnd()}, {cleanNewlines: true}) opts.onStateChange?.('Processing...') + await rt.detectFacets(agent) + rt = shortenLinks(rt) rt = stripInvalidMentions(rt) @@ -129,6 +126,25 @@ export async function post(agent: BskyAgent, opts: PostOpts) { } } + // add video embed if present + if (opts.video) { + if (opts.quote) { + embed = { + $type: 'app.bsky.embed.recordWithMedia', + record: embed, + media: { + $type: 'app.bsky.embed.video', + video: opts.video, + } as AppBskyEmbedVideo.Main, + } as AppBskyEmbedRecordWithMedia.Main + } else { + embed = { + $type: 'app.bsky.embed.video', + video: opts.video, + } as AppBskyEmbedVideo.Main + } + } + // add external embed if present if (opts.extLink && !opts.images?.length) { if (opts.extLink.embed) { diff --git a/src/lib/media/video/types.ts b/src/lib/media/video/types.ts deleted file mode 100644 index c458da96e..000000000 --- a/src/lib/media/video/types.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * TEMPORARY: THIS IS A TEMPORARY PLACEHOLDER. THAT MEANS IT IS TEMPORARY. I.E. WILL BE REMOVED. NOT TO USE IN PRODUCTION. - * @temporary - * PS: This is a temporary placeholder for the video types. It will be removed once the actual types are implemented. - * Not joking, this is temporary. - */ - -export interface JobStatus { - jobId: string - did: string - cid: string - state: JobState - progress?: number - errorHuman?: string - errorMachine?: string -} - -export enum JobState { - JOB_STATE_UNSPECIFIED = 'JOB_STATE_UNSPECIFIED', - JOB_STATE_CREATED = 'JOB_STATE_CREATED', - JOB_STATE_ENCODING = 'JOB_STATE_ENCODING', - JOB_STATE_ENCODED = 'JOB_STATE_ENCODED', - JOB_STATE_UPLOADING = 'JOB_STATE_UPLOADING', - JOB_STATE_UPLOADED = 'JOB_STATE_UPLOADED', - JOB_STATE_CDN_PROCESSING = 'JOB_STATE_CDN_PROCESSING', - JOB_STATE_CDN_PROCESSED = 'JOB_STATE_CDN_PROCESSED', - JOB_STATE_FAILED = 'JOB_STATE_FAILED', - JOB_STATE_COMPLETED = 'JOB_STATE_COMPLETED', -} - -export interface UploadVideoResponse { - job_id: string - did: string - cid: string - state: JobState -} |