feat: add Telegram album purchase bot
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { purchaseDb } from '@/lib/db';
|
||||
import { Purchase } from '@/lib/types';
|
||||
import { notifyPurchaseApprovers } from '@/lib/telegram';
|
||||
|
||||
// GET - Get all purchases
|
||||
export async function GET(request: NextRequest) {
|
||||
@@ -54,6 +55,10 @@ export async function POST(request: NextRequest) {
|
||||
};
|
||||
|
||||
const created = purchaseDb.create(purchase);
|
||||
// Telegram delivery must not make a successfully recorded purchase fail.
|
||||
void notifyPurchaseApprovers(created).catch((error) => {
|
||||
console.error('Failed to notify Telegram approvers:', error);
|
||||
});
|
||||
return NextResponse.json(created, { status: 201 });
|
||||
} catch (error) {
|
||||
console.error('Error creating purchase:', error);
|
||||
|
||||
Reference in New Issue
Block a user