Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(web): handle media fields on text comments and emails

Richie McIlroy42602d5a179c
diff --git a/apps/web/actions/videos/new-comment.ts b/apps/web/actions/videos/new-comment.ts
index 8cb9b62fe..8c2cf7ab5 100644
--- a/apps/web/actions/videos/new-comment.ts
+++ b/apps/web/actions/videos/new-comment.ts
@@ -78,6 +78,9 @@ export async function newComment(data: {
videoId: videoId,
timestamp: timestamp ?? null,
parentCommentId: parentCommentId,
+ mediaKey: null,
+ mediaDuration: null,
+ mediaMeta: null,
createdAt: new Date(),
updatedAt: new Date(),
};
diff --git a/apps/web/app/s/[videoId]/_components/Toolbar.tsx b/apps/web/app/s/[videoId]/_components/Toolbar.tsx
index 9bd0c5aa3..10773b78d 100644
--- a/apps/web/app/s/[videoId]/_components/Toolbar.tsx
+++ b/apps/web/app/s/[videoId]/_components/Toolbar.tsx
@@ -72,6 +72,9 @@ export const Toolbar = ({
type: "emoji",
timestamp: currentTime,
updatedAt: new Date(),
+ mediaKey: null,
+ mediaDuration: null,
+ mediaMeta: null,
sending: true,
};
@@ -117,6 +120,9 @@ export const Toolbar = ({
type: "text",
timestamp: currentTime,
updatedAt: new Date(),
+ mediaKey: null,
+ mediaDuration: null,
+ mediaMeta: null,
sending: true,
};
diff --git a/apps/web/lib/Notification.ts b/apps/web/lib/Notification.ts
index 4a6482224..bc655f071 100644
--- a/apps/web/lib/Notification.ts
+++ b/apps/web/lib/Notification.ts
@@ -7,7 +7,7 @@ import { comments, notifications, users, videos } from "@cap/database/schema";
import { serverEnv } from "@cap/env";
import type { Notification, NotificationBase } from "@cap/web-api-contract";
import { Comment, User, Video } from "@cap/web-domain";
-import { and, eq, gte, isNull, ne, or, sql } from "drizzle-orm";
+import { and, eq, gte, inArray, isNull, ne, or, sql } from "drizzle-orm";
import type { UserPreferences } from "@/app/(org)/dashboard/dashboard-data";
import { getSessionHash } from "@/lib/anonymous-names";
@@ -269,7 +269,9 @@ async function sendNewCommentEmail(params: {
.where(
and(
eq(comments.videoId, Video.VideoId.make(params.videoId)),
- eq(comments.type, "text"),
+ // Media comments email through the same path as text comments, so
+ // they must share the throttle window with them.
+ inArray(comments.type, ["text", "video", "audio"]),
or(
isNull(comments.parentCommentId),
eq(comments.parentCommentId, Comment.CommentId.make("")),