fix webhook

This commit is contained in:
Omer Sabic 2024-06-13 22:33:40 +02:00
parent 9ad2437a79
commit 4ae120d2ce

View File

@ -52,7 +52,7 @@ export const webhookRoutes = (fastify, _, done) => {
// Example processing: log the video IDs of new videos // Example processing: log the video IDs of new videos
const entry = feed.entry[0]; const entry = feed.entry[0];
if(!entry) return reply.code(200).send(); if(!entry) return reply.code(200).send();
const [{users: user, sites: site}] = await db.select().from(users).leftJoin(sites, eq(users.id, sites.user_id)).where(eq(users.channel_id, "UC" + feed["yt:channelId"][0])); const [{users: user, sites: site}] = await db.select().from(users).leftJoin(sites, eq(users.id, sites.user_id)).where(eq(users.channel_id, entry["yt:channelId"][0]));
if (!user || !site) throw new Error("User not found"); if (!user || !site) throw new Error("User not found");
if (user.tokens < 3) throw new Error("Not enough tokens"); if (user.tokens < 3) throw new Error("Not enough tokens");