Skip to content

Commit

Permalink
fix: don't return array of objects for photos, return just object
Browse files Browse the repository at this point in the history
  • Loading branch information
Myphz committed Jan 2, 2024
1 parent 91a8a10 commit c326354
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/telegram/telegram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ export async function uploadFiles(files: MultipartFile[]) {
files.map(async (file) => ({ media: await file.toBuffer(), type: "document" })),
)) as unknown as InputMediaPhoto[];

return (await bot.sendMediaGroup(CHAT_ID, media)).map((msg, i) => ({
[files[i].fieldname]: msg.document?.file_id ?? throwError("Couldn't upload file!"),
}));
return (await bot.sendMediaGroup(CHAT_ID, media)).reduce(
(prev, curr, i) => ({
...prev,
[files[i].fieldname]: curr.document?.file_id ?? throwError("Couldn't upload file!"),
}),
{},
);
}

export async function getFileLink(fileId: string) {
Expand Down

0 comments on commit c326354

Please sign in to comment.