Skip to content

Commit 8ea26ec

Browse files
authored
ensure more limits don't show when self hosting (#1312)
* ensure more limits don't show when self hosting * formatting * don't transcribe if no deepgram * format
1 parent d29648b commit 8ea26ec

File tree

11 files changed

+79
-194
lines changed

11 files changed

+79
-194
lines changed

apps/web/actions/videos/get-status.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { db } from "@cap/database";
44
import { users, videos } from "@cap/database/schema";
55
import type { VideoMetadata } from "@cap/database/types";
6+
import { serverEnv } from "@cap/env";
67
import { provideOptionalAuth, VideosPolicy } from "@cap/web-backend";
78
import { Policy, type Video } from "@cap/web-domain";
89
import { eq } from "drizzle-orm";
@@ -45,7 +46,7 @@ export async function getVideoStatus(
4546

4647
const metadata: VideoMetadata = (video.metadata as VideoMetadata) || {};
4748

48-
if (!video.transcriptionStatus) {
49+
if (!video.transcriptionStatus && serverEnv().DEEPGRAM_API_KEY) {
4950
console.log(
5051
`[Get Status] Transcription not started for video ${videoId}, triggering transcription`,
5152
);

apps/web/app/s/[videoId]/Share.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { ShareVideo } from "./_components/ShareVideo";
2222
import { Sidebar } from "./_components/Sidebar";
2323
import SummaryChapters from "./_components/SummaryChapters";
2424
import { Toolbar } from "./_components/Toolbar";
25+
import type { VideoData } from "./types";
2526

2627
type CommentWithAuthor = typeof commentsSchema.$inferSelect & {
2728
authorName: string | null;
@@ -34,16 +35,8 @@ export type CommentType = typeof commentsSchema.$inferSelect & {
3435
sending?: boolean;
3536
};
3637

37-
type VideoWithOrganizationInfo = typeof videos.$inferSelect & {
38-
organizationMembers?: string[];
39-
organizationId?: string;
40-
sharedOrganizations?: { id: string; name: string }[];
41-
hasPassword?: boolean;
42-
orgSettings?: OrganizationSettings | null;
43-
};
44-
4538
interface ShareProps {
46-
data: VideoWithOrganizationInfo;
39+
data: VideoData;
4740
comments: MaybePromise<CommentWithAuthor[]>;
4841
views: MaybePromise<number>;
4942
customDomain: string | null;

apps/web/app/s/[videoId]/_components/ImageViewer.tsx

Lines changed: 0 additions & 112 deletions
This file was deleted.

apps/web/app/s/[videoId]/_components/ShareHeader.tsx

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
"use client";
22

3-
import type { userSelectProps } from "@cap/database/auth/session";
43
import type { videos } from "@cap/database/schema";
54
import { buildEnv, NODE_ENV } from "@cap/env";
65
import { Button } from "@cap/ui";
7-
import { userIsPro } from "@cap/utils";
8-
import type { ImageUpload } from "@cap/web-domain";
6+
import { type ImageUpload, User } from "@cap/web-domain";
97
import { faChevronDown, faLock } from "@fortawesome/free-solid-svg-icons";
108
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
119
import { Check, Copy, Globe2 } from "lucide-react";
@@ -21,6 +19,7 @@ import { useCurrentUser } from "@/app/Layout/AuthContext";
2119
import { SignedImageUrl } from "@/components/SignedImageUrl";
2220
import { UpgradeModal } from "@/components/UpgradeModal";
2321
import { usePublicEnv } from "@/utils/public-env";
22+
import type { VideoData } from "../types";
2423

2524
export const ShareHeader = ({
2625
data,
@@ -30,11 +29,7 @@ export const ShareHeader = ({
3029
sharedSpaces = [],
3130
spacesData = null,
3231
}: {
33-
data: typeof videos.$inferSelect & {
34-
ownerName?: string | null;
35-
ownerImage?: ImageUpload.ImageUrl | null;
36-
ownerIsPro?: boolean;
37-
};
32+
data: VideoData;
3833
customDomain?: string | null;
3934
domainVerified?: boolean;
4035
sharedOrganizations?: { id: string; name: string }[];
@@ -65,7 +60,7 @@ export const ShareHeader = ({
6560
const contextSharedSpaces = contextData?.sharedSpaces || null;
6661
const effectiveSharedSpaces = contextSharedSpaces || sharedSpaces;
6762

68-
const isOwner = user && user.id === data.ownerId;
63+
const isOwner = user && user.id === data.owner.id;
6964

7065
const { webUrl } = usePublicEnv();
7166

@@ -132,8 +127,6 @@ export const ShareHeader = ({
132127
}
133128
};
134129

135-
const isVideoOwnerPro: boolean = data.ownerIsPro ?? false;
136-
137130
const handleSharingUpdated = () => {
138131
refresh();
139132
};
@@ -182,9 +175,11 @@ export const ShareHeader = ({
182175
}
183176
};
184177

178+
const userIsOwnerAndNotPro = user?.id === data.owner.id && !data.owner.isPro;
179+
185180
return (
186181
<>
187-
{isOwner && !isVideoOwnerPro && (
182+
{userIsOwnerAndNotPro && (
188183
<div className="flex sticky flex-col sm:flex-row inset-x-0 top-0 z-10 gap-4 justify-center items-center px-3 py-2 mx-auto w-[calc(100%-20px)] max-w-fit rounded-b-xl border bg-gray-4 border-gray-6">
189184
<p className="text-center text-gray-12">
190185
Shareable links are limited to 5 mins on the free plan.
@@ -238,16 +233,16 @@ export const ShareHeader = ({
238233
</div>
239234
<div className="flex gap-7 items-center">
240235
<div className="flex gap-2 items-center">
241-
{data.ownerName && (
236+
{data.name && (
242237
<SignedImageUrl
243-
name={data.ownerName}
244-
image={data.ownerImage}
238+
name={data.name}
239+
image={data.owner.image}
245240
className="size-8"
246241
letterClass="text-base"
247242
/>
248243
)}
249244
<div className="flex flex-col text-left">
250-
<p className="text-sm text-gray-12">{data.ownerName}</p>
245+
<p className="text-sm text-gray-12">{data.name}</p>
251246
<p className="text-xs text-gray-10">
252247
{moment(data.createdAt).fromNow()}
253248
</p>
@@ -285,7 +280,7 @@ export const ShareHeader = ({
285280
)}
286281
</Button>
287282
</div>
288-
{!isVideoOwnerPro && (
283+
{userIsOwnerAndNotPro && (
289284
<button
290285
type="button"
291286
className="flex items-center mt-2 mb-3 text-sm text-gray-400 duration-200 cursor-pointer hover:text-blue-500"

apps/web/app/s/[videoId]/_components/ShareVideo.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from "react";
1414
import type { OrganizationSettings } from "@/app/(org)/dashboard/dashboard-data";
1515
import { UpgradeModal } from "@/components/UpgradeModal";
16+
import type { VideoData } from "../types";
1617
import { CapVideoPlayer } from "./CapVideoPlayer";
1718
import { HLSVideoPlayer } from "./HLSVideoPlayer";
1819
import {
@@ -36,10 +37,8 @@ type CommentWithAuthor = typeof commentsSchema.$inferSelect & {
3637
export const ShareVideo = forwardRef<
3738
HTMLVideoElement,
3839
{
39-
data: typeof videos.$inferSelect & {
40-
ownerIsPro?: boolean;
40+
data: VideoData & {
4141
hasActiveUpload?: boolean;
42-
orgSettings?: OrganizationSettings | null;
4342
};
4443
comments: MaybePromise<CommentWithAuthor[]>;
4544
chapters?: { title: string; start: number }[];
@@ -166,19 +165,19 @@ export const ShareVideo = forwardRef<
166165
let enableCrossOrigin = false;
167166

168167
if (data.source.type === "desktopMP4") {
169-
videoSrc = `/api/playlist?userId=${data.ownerId}&videoId=${data.id}&videoType=mp4`;
168+
videoSrc = `/api/playlist?userId=${data.owner.id}&videoId=${data.id}&videoType=mp4`;
170169
// Start with CORS enabled for desktopMP4, but CapVideoPlayer will dynamically disable if needed
171170
enableCrossOrigin = true;
172171
} else if (
173172
NODE_ENV === "development" ||
174173
((data.skipProcessing === true || data.jobStatus !== "COMPLETE") &&
175174
data.source.type === "MediaConvert")
176175
) {
177-
videoSrc = `/api/playlist?userId=${data.ownerId}&videoId=${data.id}&videoType=master`;
176+
videoSrc = `/api/playlist?userId=${data.owner.id}&videoId=${data.id}&videoType=master`;
178177
} else if (data.source.type === "MediaConvert") {
179-
videoSrc = `/api/playlist?userId=${data.ownerId}&videoId=${data.id}&videoType=video`;
178+
videoSrc = `/api/playlist?userId=${data.owner.id}&videoId=${data.id}&videoType=video`;
180179
} else {
181-
videoSrc = `/api/playlist?userId=${data.ownerId}&videoId=${data.id}&videoType=video`;
180+
videoSrc = `/api/playlist?userId=${data.owner.id}&videoId=${data.id}&videoType=video`;
182181
}
183182

184183
return (
@@ -221,7 +220,7 @@ export const ShareVideo = forwardRef<
221220
)}
222221
</div>
223222

224-
{!data.ownerIsPro && (
223+
{!data.owner.isPro && (
225224
<div className="absolute top-4 left-4 z-30">
226225
<div
227226
className="block cursor-pointer"

apps/web/app/s/[videoId]/_components/Sidebar.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { AnimatePresence, motion } from "framer-motion";
77
import { forwardRef, Suspense, useState } from "react";
88
import type { OrganizationSettings } from "@/app/(org)/dashboard/dashboard-data";
99
import { useCurrentUser } from "@/app/Layout/AuthContext";
10+
import type { VideoData } from "../types";
1011
import { Activity } from "./tabs/Activity";
1112
import { Settings } from "./tabs/Settings";
1213
import { Summary } from "./tabs/Summary";
@@ -19,14 +20,8 @@ type CommentType = typeof commentsSchema.$inferSelect & {
1920
authorImage?: ImageUpload.ImageUrl | null;
2021
};
2122

22-
type VideoWithOrganizationInfo = typeof videos.$inferSelect & {
23-
organizationMembers?: string[];
24-
organizationId?: string;
25-
orgSettings?: OrganizationSettings | null;
26-
};
27-
2823
interface SidebarProps {
29-
data: VideoWithOrganizationInfo;
24+
data: VideoData;
3025
commentsData: CommentType[];
3126
optimisticComments: CommentType[];
3227
handleCommentSuccess: (comment: CommentType) => void;
@@ -91,10 +86,9 @@ export const Sidebar = forwardRef<{ scrollToBottom: () => void }, SidebarProps>(
9186
) => {
9287
const user = useCurrentUser();
9388

94-
const isOwnerOrMember: boolean = Boolean(
95-
user?.id === data.ownerId ||
96-
(data.organizationId &&
97-
data.organizationMembers?.includes(user?.id ?? "")),
89+
const isOwnerOrMember = Boolean(
90+
user?.id === data.owner.id ||
91+
(user && data.organizationMembers?.includes(user.id)),
9892
);
9993

10094
const defaultTab = !(
@@ -182,7 +176,7 @@ export const Sidebar = forwardRef<{ scrollToBottom: () => void }, SidebarProps>(
182176
/>
183177
);
184178
case "transcript":
185-
return <Transcript data={data} onSeek={onSeek} user={user} />;
179+
return <Transcript data={data} onSeek={onSeek} />;
186180
case "settings":
187181
return <Settings />;
188182
default:

apps/web/app/s/[videoId]/_components/Toolbar.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
import type { userSelectProps } from "@cap/database/auth/session";
2-
import type { videos } from "@cap/database/schema";
31
import { Button } from "@cap/ui";
4-
import { Comment, User } from "@cap/web-domain";
2+
import { Comment } from "@cap/web-domain";
53
import { AnimatePresence, motion } from "motion/react";
64
import { startTransition, useEffect, useState } from "react";
75
import { newComment } from "@/actions/videos/new-comment";
8-
import type { OrganizationSettings } from "@/app/(org)/dashboard/dashboard-data";
96
import { useCurrentUser } from "@/app/Layout/AuthContext";
107
import type { CommentType } from "../Share";
8+
import type { VideoData } from "../types";
119
import { AuthOverlay } from "./AuthOverlay";
1210

1311
const MotionButton = motion.create(Button);
1412

1513
// million-ignore
1614
interface ToolbarProps {
17-
data: typeof videos.$inferSelect & {
18-
orgSettings?: OrganizationSettings | null;
19-
};
15+
data: VideoData;
2016
onOptimisticComment?: (comment: CommentType) => void;
2117
onCommentSuccess?: (comment: CommentType) => void;
2218
disableReactions?: boolean;

0 commit comments

Comments
 (0)