fix: deliver alt texts to providers at publish time
Intake stores alt texts positionally (aligned with mediaAssetIds) but the Mastodon upload reads an asset-id-keyed providerMetadata.altText map, so descriptions were silently dropped. postOf translates the array into the map.
This commit is contained in:
parent
e7bf870de9
commit
2d881f5e41
1 changed files with 14 additions and 1 deletions
|
|
@ -23,7 +23,20 @@ function connectionOf(job: ClaimedJob): ConnectorConnection {
|
|||
function postOf(job: ClaimedJob): NormalizedPost {
|
||||
const visibility = job.post.visibility;
|
||||
if (!["public", "unlisted", "private", "followers", "provider_default"].includes(visibility)) throw new Error("INVALID_POST_VISIBILITY");
|
||||
return { ...job.post, visibility: visibility as NormalizedPost["visibility"] };
|
||||
const post = job.post;
|
||||
// Positional alt texts (aligned with mediaAssetIds at intake) become the
|
||||
// connector's asset-id → description map; the Mastodon upload reads it.
|
||||
const providerMetadata: Record<string, unknown> = { ...post.providerMetadata };
|
||||
const altTexts = post.altTexts;
|
||||
if (Array.isArray(altTexts) && altTexts.length > 0) {
|
||||
const altText: Record<string, string> = {};
|
||||
post.mediaAssetIds.forEach((id, index) => {
|
||||
const text = altTexts[index];
|
||||
if (typeof text === "string" && text.trim() !== "") altText[id] = text;
|
||||
});
|
||||
if (Object.keys(altText).length > 0) providerMetadata.altText = altText;
|
||||
}
|
||||
return { ...post, visibility: visibility as NormalizedPost["visibility"], providerMetadata };
|
||||
}
|
||||
/** Persist only documented remote evidence; unknown fields never enter DB/history. */
|
||||
export function safeMetadata(metadata: Record<string, unknown>): Record<string, unknown> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue