[SDK] Add refreshSession and migrate the session-pinned infra (#11381)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -285,6 +285,12 @@ export const ComposePost = ({
|
||||
const pdsClient = usePdsClient()
|
||||
const queryClient = useQueryClient()
|
||||
const currentDid = currentAccount!.did
|
||||
/*
|
||||
* The host the video service-auth token is minted for. This is the same value
|
||||
* that seeds the session's PDS routing, so the audience always matches the host
|
||||
* the upload actually reaches; a mismatch would 401 the upload.
|
||||
*/
|
||||
const currentDispatchUrl = currentAccount!.pdsUrl ?? currentAccount!.service
|
||||
const {closeComposer} = useComposerControls()
|
||||
const {t: l, i18n} = useLingui()
|
||||
const requireAltTextEnabled = useRequireAltTextEnabled()
|
||||
@@ -479,7 +485,8 @@ export const ComposePost = ({
|
||||
},
|
||||
})
|
||||
},
|
||||
agent,
|
||||
pdsClient,
|
||||
currentDispatchUrl,
|
||||
currentDid,
|
||||
abortController.signal,
|
||||
i18n,
|
||||
@@ -489,7 +496,8 @@ export const ComposePost = ({
|
||||
[
|
||||
l,
|
||||
i18n,
|
||||
agent,
|
||||
pdsClient,
|
||||
currentDispatchUrl,
|
||||
currentDid,
|
||||
composerDispatch,
|
||||
ax.metric,
|
||||
@@ -661,7 +669,8 @@ export const ComposePost = ({
|
||||
},
|
||||
})
|
||||
},
|
||||
agent,
|
||||
pdsClient,
|
||||
currentDispatchUrl,
|
||||
currentDid,
|
||||
abortController.signal,
|
||||
i18n,
|
||||
@@ -677,7 +686,8 @@ export const ComposePost = ({
|
||||
[
|
||||
l,
|
||||
i18n,
|
||||
agent,
|
||||
pdsClient,
|
||||
currentDispatchUrl,
|
||||
currentDid,
|
||||
composerDispatch,
|
||||
ax.metric,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {type ImagePickerAsset} from 'expo-image-picker'
|
||||
import {type AppBskyVideoDefs, type AtpAgent, type BlobRef} from '@atproto/api'
|
||||
import {type BlobRef, type Client} from '@atproto/lex'
|
||||
import {type I18n} from '@lingui/core'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
|
||||
@@ -14,9 +14,10 @@ import {
|
||||
import {type VideoTelemetry} from '#/lib/media/video/telemetry'
|
||||
import {type CompressedVideo} from '#/lib/media/video/types'
|
||||
import {uploadVideo} from '#/lib/media/video/upload'
|
||||
import {createVideoAgent} from '#/lib/media/video/util'
|
||||
import {createTokenlessVideoServiceClient} from '#/lib/media/video/util'
|
||||
import {isNetworkError} from '#/lib/strings/errors'
|
||||
import {logger} from '#/logger'
|
||||
import {app} from '#/lexicons'
|
||||
import {
|
||||
advanceVideoProgress,
|
||||
didSkipVideoCompression,
|
||||
@@ -56,7 +57,7 @@ export type VideoAction =
|
||||
}
|
||||
| {
|
||||
type: 'update_job_status'
|
||||
jobStatus: AppBskyVideoDefs.JobStatus
|
||||
jobStatus: app.bsky.video.defs.JobStatus
|
||||
signal: AbortSignal
|
||||
}
|
||||
|
||||
@@ -126,7 +127,7 @@ type ProcessingState = {
|
||||
asset: ImagePickerAsset
|
||||
video: CompressedVideo
|
||||
jobId: string
|
||||
jobStatus: AppBskyVideoDefs.JobStatus | null
|
||||
jobStatus: app.bsky.video.defs.JobStatus | null
|
||||
pendingPublish?: undefined
|
||||
telemetry: VideoTelemetry
|
||||
altText: string
|
||||
@@ -295,7 +296,8 @@ function trunc2dp(num: number) {
|
||||
export async function processVideo(
|
||||
asset: ImagePickerAsset,
|
||||
dispatch: (action: VideoAction) => void,
|
||||
agent: AtpAgent,
|
||||
client: Client,
|
||||
dispatchUrl: string | URL,
|
||||
did: string,
|
||||
signal: AbortSignal,
|
||||
i18n: I18n,
|
||||
@@ -339,12 +341,13 @@ export async function processVideo(
|
||||
signal,
|
||||
})
|
||||
|
||||
let uploadResponse: AppBskyVideoDefs.JobStatus | undefined
|
||||
let uploadResponse: app.bsky.video.defs.JobStatus | undefined
|
||||
try {
|
||||
telemetry.uploadStarted(video.size)
|
||||
uploadResponse = await uploadVideo({
|
||||
video,
|
||||
agent,
|
||||
client,
|
||||
dispatchUrl,
|
||||
did,
|
||||
signal,
|
||||
i18n,
|
||||
@@ -381,12 +384,14 @@ export async function processVideo(
|
||||
return // Exit async loop
|
||||
}
|
||||
|
||||
const videoAgent = createVideoAgent()
|
||||
let status: AppBskyVideoDefs.JobStatus | undefined
|
||||
const videoClient = createTokenlessVideoServiceClient()
|
||||
let status: app.bsky.video.defs.JobStatus | undefined
|
||||
let blob: BlobRef | undefined
|
||||
try {
|
||||
const response = await videoAgent.app.bsky.video.getJobStatus({jobId})
|
||||
status = response.data.jobStatus
|
||||
const response = await videoClient.call(app.bsky.video.getJobStatus, {
|
||||
jobId,
|
||||
})
|
||||
status = response.jobStatus
|
||||
pollFailures = 0
|
||||
|
||||
if (status.state === 'JOB_STATE_COMPLETED') {
|
||||
|
||||
Reference in New Issue
Block a user