Add override for discord bot to send image file directly.

This commit is contained in:
Cameron Redmore 2025-02-15 13:18:57 +00:00
parent 9638a9a72c
commit 007f775f8b

View file

@ -126,6 +126,10 @@ fastify.get('/s/:date/:filename', async (request, reply) => {
<meta property="og:url" content="${process.env.HOST || ''}/s/${date}/${filename}" />\n`;
if (mimeType.startsWith('image/')) {
//If the user agent is DiscordBot, return the image directly
if (request.headers['user-agent'].includes('Discordbot')) {
return reply.redirect(`/f/${joinedPath}`);
}
fileContent = `<img src="/f/${joinedPath}" alt="${filename}" width="${width}" height="${height}" />`
ogTags += `<meta property="og:image" content="/f/${joinedPath}" />
<meta property="og:image:type" content="${mimeType}" />