Proxy Telegram bot user avatars
All checks were successful
Build and deploy Backend / build (push) Successful in 31s

This commit is contained in:
Ruslan Bakiev
2026-05-08 19:37:10 +07:00
parent 71561724a5
commit de0e230632
3 changed files with 59 additions and 4 deletions

View File

@@ -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();
});