Skip to content

Commit

Permalink
correct content type
Browse files Browse the repository at this point in the history
  • Loading branch information
tcm390 committed Dec 19, 2024
1 parent 98fbe39 commit 7ac6616
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
14 changes: 2 additions & 12 deletions packages/client-twitter/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,6 @@ export async function buildConversationThread(
return thread;
}

export function getMediaType(attachment: Media) {
if (attachment.contentType?.startsWith("video")) {
return "video";
} else if (attachment.contentType?.startsWith("image")) {
return "image";
} else {
throw new Error(`Unsupported media type`);
}
}

export async function sendTweet(
client: ClientBase,
content: Content,
Expand Down Expand Up @@ -207,14 +197,14 @@ export async function sendTweet(
const mediaBuffer = Buffer.from(
await response.arrayBuffer()
);
const mediaType = getMediaType(attachment);
const mediaType = attachment.contentType;
return { data: mediaBuffer, mediaType };
} else if (fs.existsSync(attachment.url)) {
// Handle local file paths
const mediaBuffer = await fs.promises.readFile(
path.resolve(attachment.url)
);
const mediaType = getMediaType(attachment);
const mediaType = attachment.contentType;
return { data: mediaBuffer, mediaType };
} else {
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-image-generation/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ const imageGeneration: Action = {
source: "imageGeneration",
description: "...", //caption.title,
text: "...", //caption.description,
contentType: "image",
contentType: "image/png",
},
],
},
Expand Down

0 comments on commit 7ac6616

Please sign in to comment.