From 3e4fb970c392dcf6a28e23e923375398744a2fed Mon Sep 17 00:00:00 2001 From: glass beadian Date: Thu, 15 Oct 2026 19:25:16 +0000 Subject: [PATCH] fix: Mastodon connector loadAsset/openAsset receive the connection uploadAll/uploadAsset call the media hooks with (connection, assetId) so implementations can resolve the workspace; the registry adapter threads connection.workspaceId into the resolver. --- packages/connector-mastodon/src/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/connector-mastodon/src/index.ts b/packages/connector-mastodon/src/index.ts index 119e633..184b1b8 100644 --- a/packages/connector-mastodon/src/index.ts +++ b/packages/connector-mastodon/src/index.ts @@ -109,10 +109,10 @@ export interface MastodonConnectorOptions { sleep?: (ms: number) => Promise; /** Secret store. Default: in-memory (dev + contract tests). */ credentials?: CredentialAccessor; - /** Resolve a media asset id to its metadata (needed by publish with media). */ - loadAsset?: (assetId: string) => Promise; - /** Read asset bytes for multipart upload (needed by publish/uploadMedia). */ - openAsset?: (media: MediaAsset) => Promise<{ bytes: Uint8Array; filename: string }>; + /** Resolve a media asset id to its metadata (needed by publish with media). Receives the connection so implementations can resolve the workspace. */ + loadAsset?: (connection: ConnectorConnection, assetId: string) => Promise; + /** Read asset bytes for multipart upload (needed by publish/uploadMedia). Receives the connection so implementations can resolve the workspace. */ + openAsset?: (connection: ConnectorConnection, media: MediaAsset) => Promise<{ bytes: Uint8Array; filename: string }>; /** client_name shown on the instance's authorized-apps page. */ clientName?: string; /** Public website advertised with the registered app. */ @@ -466,7 +466,7 @@ export function createMastodonConnector(options: MastodonConnectorOptions = {}): if (options.openAsset === undefined) { throw new ConnectorError("media upload needs an openAsset option", PROVIDER); } - const { bytes, filename } = await options.openAsset(media); + const { bytes, filename } = await options.openAsset(connection, media); const body = new FormData(); body.append("file", new Blob([new Uint8Array(bytes)], { type: media.mimeType }), filename); if (description !== undefined) body.append("description", description); @@ -496,7 +496,7 @@ export function createMastodonConnector(options: MastodonConnectorOptions = {}): } const ids: string[] = []; for (const assetId of assetIds) { - const asset = await options.loadAsset(assetId); + const asset = await options.loadAsset(connection, assetId); ids.push((await uploadAsset(connection, asset, str(altText[assetId]))).remoteId); } return ids;