@@ -5,6 +5,7 @@ import { getCurrentUser } from "@cap/database/auth/session";
55import {
66 comments ,
77 folders ,
8+ organizations ,
89 sharedVideos ,
910 spaces ,
1011 spaceVideos ,
@@ -13,7 +14,7 @@ import {
1314 videoUploads ,
1415} from "@cap/database/schema" ;
1516import type { Space } from "@cap/web-domain" ;
16- import { and , desc , eq , sql } from "drizzle-orm" ;
17+ import { and , desc , eq , isNull , sql } from "drizzle-orm" ;
1718
1819export async function getUserVideos ( spaceId : Space . SpaceIdOrOrganisationId ) {
1920 try {
@@ -64,7 +65,10 @@ export async function getUserVideos(spaceId: Space.SpaceIdOrOrganisationId) {
6465 )
6566 . leftJoin ( folders , eq ( sharedVideos . folderId , folders . id ) )
6667 . leftJoin ( spaces , eq ( folders . spaceId , spaces . id ) )
67- . where ( eq ( videos . ownerId , userId ) )
68+ . leftJoin ( organizations , eq ( videos . orgId , organizations . id ) )
69+ . where (
70+ and ( eq ( videos . ownerId , userId ) , isNull ( organizations . tombstoneAt ) ) ,
71+ )
6872 . groupBy (
6973 videos . id ,
7074 videos . ownerId ,
@@ -98,7 +102,10 @@ export async function getUserVideos(spaceId: Space.SpaceIdOrOrganisationId) {
98102 )
99103 . leftJoin ( folders , eq ( spaceVideos . folderId , folders . id ) )
100104 . leftJoin ( spaces , eq ( folders . spaceId , spaces . id ) )
101- . where ( eq ( videos . ownerId , userId ) )
105+ . leftJoin ( organizations , eq ( videos . orgId , organizations . id ) )
106+ . where (
107+ and ( eq ( videos . ownerId , userId ) , isNull ( organizations . tombstoneAt ) ) ,
108+ )
102109 . groupBy (
103110 videos . id ,
104111 videos . ownerId ,
0 commit comments