Add voice transcription admin review flow
All checks were successful
Build and deploy Backend / build (push) Successful in 7m29s

This commit is contained in:
Ruslan Bakiev
2026-05-14 08:44:20 +07:00
parent 0668660e85
commit 3a072a7165
13 changed files with 355 additions and 69 deletions

View File

@@ -9,7 +9,10 @@ import {
handleTelegramBotWebhook,
} from './auth/telegram-bot-login.js';
const app = Fastify({ logger: true });
const app = Fastify({
logger: true,
bodyLimit: 25 * 1024 * 1024,
});
app.register(mercurius, {
schema,
@@ -46,6 +49,36 @@ app.get('/telegram/photo/:fileId', async (request, reply) => {
return reply.send(photo.bytes);
});
app.get('/audio/voice-experiences/:experienceId', async (request, reply) => {
const params = request.params as { experienceId: string };
const query = request.query as { token?: string };
if (!query.token) {
return reply.code(401).send({ error: 'Audio token is required.' });
}
const experience = await prisma.voiceExperience.findUnique({
where: { id: params.experienceId },
select: {
audioAccessToken: true,
audioContentBase64: true,
audioMimeType: true,
},
});
if (
!experience ||
experience.audioAccessToken !== query.token ||
!experience.audioContentBase64 ||
!experience.audioMimeType
) {
return reply.code(404).send({ error: 'Audio was not found.' });
}
reply.header('content-type', experience.audioMimeType);
reply.header('cache-control', 'no-store');
return reply.send(Buffer.from(experience.audioContentBase64, 'base64'));
});
app.addHook('onClose', async () => {
await prisma.$disconnect();
});