Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(api): restrict first-view email to authenticated viewers only

Richie McIlroy9e854c9353e8
diff --git a/apps/web/app/api/analytics/track/route.ts b/apps/web/app/api/analytics/track/route.ts
index 708b4095e..61967ed98 100644
--- a/apps/web/app/api/analytics/track/route.ts
+++ b/apps/web/app/api/analytics/track/route.ts
@@ -136,30 +136,22 @@ export async function POST(request: NextRequest) {
},
]);
- yield* Effect.forkDaemon(
- Effect.tryPromise(() =>
- sendFirstViewEmail(
- userId
- ? {
- videoId: body.videoId,
- viewerUserId: userId,
- isAnonymous: false,
- }
- : {
- videoId: body.videoId,
- viewerName: sessionId
- ? getAnonymousName(sessionId)
- : "Someone",
- isAnonymous: true,
- },
+ if (userId) {
+ yield* Effect.forkDaemon(
+ Effect.tryPromise(() =>
+ sendFirstViewEmail({
+ videoId: body.videoId,
+ viewerUserId: userId,
+ isAnonymous: false,
+ }),
+ ).pipe(
+ Effect.catchAll((error) => {
+ console.error("Failed to send first view email:", error);
+ return Effect.void;
+ }),
),
- ).pipe(
- Effect.catchAll((error) => {
- console.error("Failed to send first view email:", error);
- return Effect.void;
- }),
- ),
- );
+ );
+ }
if (!userId && sessionId) {
const anonName = getAnonymousName(sessionId);