Skip to content

Commit

Permalink
add notice when picture has been deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
MarSeventh committed Sep 11, 2024
1 parent af8c170 commit b8379f9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions functions/file/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export async function onRequest(context) { // Contents of context object
return new Response('Error: Please configure KV database', { status: 500 });
}
const imgRecord = await env.img_url.getWithMetadata(params.id);
// 图片是否存在
if (imgRecord === null) {
return new Response('Error: Image not found', { status: 404 });
}

if (imgRecord.metadata?.Channel === 'Telegram') {
targetUrl = `https://api.telegram.org/file/bot${env.TG_BOT_TOKEN}/${imgRecord.metadata.TgFilePath}`;
Expand Down

0 comments on commit b8379f9

Please sign in to comment.