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.
This commit is contained in:
parent
b8115eec09
commit
3e4fb970c3
1 changed files with 6 additions and 6 deletions
|
|
@ -109,10 +109,10 @@ export interface MastodonConnectorOptions {
|
|||
sleep?: (ms: number) => Promise<void>;
|
||||
/** 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<MediaAsset>;
|
||||
/** 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<MediaAsset>;
|
||||
/** 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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue