Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(api): short-circuit owner check before database query
Richie McIlroy509b9f5e4e80
diff --git a/apps/web/app/api/analytics/track/route.ts b/apps/web/app/api/analytics/track/route.tsindex 146b79428..66f9c82c0 100644--- a/apps/web/app/api/analytics/track/route.ts+++ b/apps/web/app/api/analytics/track/route.ts@@ -99,18 +99,18 @@ export async function POST(request: NextRequest) {return currentUser.id;},});- const ownerId = userId- ? yield* Effect.tryPromise(() =>- db()- .select({ ownerId: videos.ownerId })- .from(videos)- .where(eq(videos.id, Video.VideoId.make(body.videoId)))- .limit(1)- .then((rows) => rows[0]?.ownerId ?? null),- ).pipe(Effect.orElseSucceed(() => body.ownerId ?? null))- : (body.ownerId ?? null);- if (userId && ownerId && userId === ownerId) {- return;+ if (userId && body.ownerId && userId === body.ownerId) {+ const ownerIdResult = yield* Effect.tryPromise(() =>+ db()+ .select({ ownerId: videos.ownerId })+ .from(videos)+ .where(eq(videos.id, Video.VideoId.make(body.videoId)))+ .limit(1)+ .then((rows) => rows[0]?.ownerId ?? null),+ ).pipe(Effect.orElseSucceed(() => null as string | null));+ if (ownerIdResult && userId === ownerIdResult) {+ return;+ }}const tinybird = yield* Tinybird;