File tree Expand file tree Collapse file tree
apps/web/app/api/analytics/track Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,21 +100,23 @@ export async function POST(request: NextRequest) {
100100 } ,
101101 } ) ;
102102
103- const [ videoRecord ] = yield * Effect . tryPromise ( ( ) =>
104- db ( )
105- . select ( { ownerId : videos . ownerId } )
106- . from ( videos )
107- . where ( eq ( videos . id , Video . VideoId . make ( body . videoId ) ) )
108- . limit ( 1 ) ,
109- ) . pipe ( Effect . orElseSucceed ( ( ) => [ ] as { ownerId : string } [ ] ) ) ;
110-
111- if ( userId && videoRecord && userId === videoRecord . ownerId ) {
112- return ;
103+ if ( userId && ( ! body . ownerId || userId === body . ownerId ) ) {
104+ const [ videoRecord ] = yield * Effect . tryPromise ( ( ) =>
105+ db ( )
106+ . select ( { ownerId : videos . ownerId } )
107+ . from ( videos )
108+ . where ( eq ( videos . id , Video . VideoId . make ( body . videoId ) ) )
109+ . limit ( 1 ) ,
110+ ) . pipe ( Effect . orElseSucceed ( ( ) => [ ] as { ownerId : string } [ ] ) ) ;
111+
112+ if ( videoRecord && userId === videoRecord . ownerId ) {
113+ return ;
114+ }
113115 }
114116
115117 const tenantId =
116118 body . orgId ||
117- videoRecord ? .ownerId ||
119+ body . ownerId ||
118120 ( hostname ? `domain:${ hostname } ` : "public" ) ;
119121
120122 const tinybird = yield * Tinybird ;
You can’t perform that action at this time.
0 commit comments