Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/web/__tests__/unit/caption-tracks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ function createCueList(text: string): TextTrackCueList {
function createVideo(
textTracks: FakeTextTrackList,
trackElements: FakeTrackElement[],
): HTMLVideoElement {
): HTMLVideoElement & FakeVideo {
return new FakeVideo(
textTracks,
trackElements,
) as unknown as HTMLVideoElement;
) as unknown as HTMLVideoElement & FakeVideo;
}

describe("bindCaptionTrackCueText", () => {
Expand Down
3 changes: 2 additions & 1 deletion apps/web/app/(site)/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";

import { Logo } from "@cap/ui";
import type { IconDefinition } from "@fortawesome/fontawesome-svg-core";
import {
faDiscord,
faLinkedinIn,
Expand All @@ -13,6 +12,8 @@ import Link from "next/link";
import type { ReactNode } from "react";
import { useState } from "react";

type IconDefinition = typeof faDiscord;

type FooterLink = {
label: string;
href: string;
Expand Down
36 changes: 12 additions & 24 deletions apps/web/app/api/video/ai/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { users, videos } from "@cap/database/schema";
import type { VideoMetadata } from "@cap/database/types";
import { provideOptionalAuth, VideosPolicy } from "@cap/web-backend";
import { Policy, type Video } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { Effect, Exit } from "effect";
import type { Video } from "@cap/web-domain";
import { and, eq } from "drizzle-orm";
import type { NextRequest } from "next/server";
import { startAiGeneration } from "@/lib/generate-ai";
import * as EffectRuntime from "@/lib/server";
import { isAiGenerationEnabled } from "@/utils/flags";

export const dynamic = "force-dynamic";
Expand All @@ -30,30 +27,21 @@ export async function GET(request: NextRequest) {
);
}

const exit = await Effect.gen(function* () {
const videosPolicy = yield* VideosPolicy;

return yield* Effect.promise(() =>
db().select().from(videos).where(eq(videos.id, videoId)),
).pipe(Policy.withPublicPolicy(videosPolicy.canView(videoId)));
}).pipe(provideOptionalAuth, EffectRuntime.runPromiseExit);

if (Exit.isFailure(exit)) {
return Response.json(
{ error: true, message: "Video not found" },
{ status: 404 },
);
}

const result = exit.value;
if (result.length === 0 || !result[0]) {
const [video] = await db()
.select({
ownerId: videos.ownerId,
metadata: videos.metadata,
transcriptionStatus: videos.transcriptionStatus,
})
.from(videos)
.where(and(eq(videos.id, videoId), eq(videos.ownerId, user.id)))
.limit(1);
if (!video) {
return Response.json(
{ error: true, message: "Video not found" },
{ status: 404 },
);
}

const video = result[0];
const metadata: VideoMetadata = (video.metadata as VideoMetadata) || {};

if (metadata.summary || metadata.chapters) {
Expand Down
Loading