Add override for discord bot to send image file directly.
This commit is contained in:
parent
9638a9a72c
commit
007f775f8b
1 changed files with 4 additions and 0 deletions
4
index.js
4
index.js
|
@ -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}" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue