Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(notifications): respect pauseAnonViews preference in sendFirstViewEmail

Richie McIlroy2bcf9891c690
diff --git a/apps/web/lib/Notification.ts b/apps/web/lib/Notification.ts
index 10f7c8572..92afd06a4 100644
--- a/apps/web/lib/Notification.ts
+++ b/apps/web/lib/Notification.ts
@@ -329,6 +329,7 @@ export async function sendFirstViewEmail(
videoName: videos.name,
ownerId: videos.ownerId,
ownerEmail: users.email,
+ preferences: users.preferences,
})
.from(videos)
.innerJoin(users, eq(users.id, videos.ownerId))
@@ -340,6 +341,11 @@ export async function sendFirstViewEmail(
if (!params.isAnonymous && params.viewerUserId === videoWithOwner.ownerId)
return;
+ if (params.isAnonymous) {
+ const preferences = videoWithOwner.preferences as UserPreferences;
+ if (preferences?.notifications?.pauseAnonViews) return;
+ }
+
const [result] = await database
.update(videos)
.set({ firstViewEmailSentAt: new Date() })