Proxy Telegram bot user avatars
All checks were successful
Build and deploy Backend / build (push) Successful in 31s
All checks were successful
Build and deploy Backend / build (push) Successful in 31s
This commit is contained in:
@@ -4,7 +4,10 @@ import mercurius from 'mercurius';
|
||||
import { config } from './config.js';
|
||||
import { prisma } from './prisma.js';
|
||||
import { resolvers, schema } from './graphql/schema.js';
|
||||
import { handleTelegramBotWebhook } from './auth/telegram-bot-login.js';
|
||||
import {
|
||||
fetchTelegramPhoto,
|
||||
handleTelegramBotWebhook,
|
||||
} from './auth/telegram-bot-login.js';
|
||||
|
||||
const app = Fastify({ logger: true });
|
||||
|
||||
@@ -33,6 +36,14 @@ app.post('/telegram/webhook', async (request, reply) => {
|
||||
return reply.send({ ok: true });
|
||||
});
|
||||
|
||||
app.get('/telegram/photo/:fileId', async (request, reply) => {
|
||||
const params = request.params as { fileId: string };
|
||||
const photo = await fetchTelegramPhoto(params.fileId);
|
||||
reply.header('content-type', photo.contentType);
|
||||
reply.header('cache-control', 'public, max-age=86400');
|
||||
return reply.send(photo.bytes);
|
||||
});
|
||||
|
||||
app.addHook('onClose', async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user