-
Notifications
You must be signed in to change notification settings - Fork 770
fix: viewing private videos through spaces #892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
da1412c
82130aa
6815133
7ebca85
162a876
91f4e19
2d43544
49b4ee6
5847ded
f3d5335
65559ff
bc44140
79ef139
5ac1a70
62672ce
207a296
f2b1165
758a92c
44ace89
795e43a
ff34dd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,34 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import * as Db from "@cap/database/schema"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import type { Video } from "@cap/web-domain"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import * as Dz from "drizzle-orm"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { Effect } from "effect"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import { Database } from "../Database"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
export class OrganisationsRepo extends Effect.Service<OrganisationsRepo>()( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"OrganisationsRepo", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
effect: Effect.gen(function* () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const db = yield* Database; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
membershipForVideo: (userId: string, videoId: Video.VideoId) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
db.execute((db) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
db | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.select({ membershipId: Db.organizationMembers.id }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.from(Db.organizationMembers) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.leftJoin( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Db.sharedVideos, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Dz.eq(Db.spaceMembers.spaceId, Db.sharedVideos.id), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
.where( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Dz.and( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Dz.eq(Db.spaceMembers.userId, userId), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Dz.eq(Db.sharedVideos.id, videoId), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Incorrect table references in organization membership query The query uses Apply this diff to fix the table references: membershipForVideo: (userId: string, videoId: Video.VideoId) =>
db.execute((db) =>
db
.select({ membershipId: Db.organizationMembers.id })
.from(Db.organizationMembers)
.leftJoin(
Db.sharedVideos,
- Dz.eq(Db.spaceMembers.spaceId, Db.sharedVideos.id),
+ Dz.eq(Db.organizationMembers.organizationId, Db.sharedVideos.organizationId),
)
.where(
Dz.and(
- Dz.eq(Db.spaceMembers.userId, userId),
- Dz.eq(Db.sharedVideos.id, videoId),
+ Dz.eq(Db.organizationMembers.userId, userId),
+ Dz.eq(Db.sharedVideos.videoId, videoId),
),
),
), 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as Db from "@cap/database/schema"; | ||
import type { Video } from "@cap/web-domain"; | ||
import * as Dz from "drizzle-orm"; | ||
import { Effect } from "effect"; | ||
|
||
import { Database } from "../Database"; | ||
|
||
export class SpacesRepo extends Effect.Service<SpacesRepo>()("SpacesRepo", { | ||
effect: Effect.gen(function* () { | ||
const db = yield* Database; | ||
|
||
return { | ||
membershipForVideo: (userId: string, videoId: Video.VideoId) => | ||
db.execute((db) => | ||
db | ||
.select({ membershipId: Db.spaceMembers.id }) | ||
.from(Db.spaceMembers) | ||
.leftJoin( | ||
Db.spaceVideos, | ||
Dz.eq(Db.spaceMembers.spaceId, Db.spaceVideos.spaceId), | ||
) | ||
.where( | ||
Dz.and( | ||
Dz.eq(Db.spaceMembers.userId, userId), | ||
Dz.eq(Db.spaceVideos.videoId, videoId), | ||
), | ||
), | ||
), | ||
}; | ||
}), | ||
}) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Undefined isSpaceMember defaults to “not a member.” Ensure all call sites pass it if needed.
When omitted,
!isSpaceMember
evaluates truthy, which can affect access logic. Please verify all call sites were updated to pass the correct membership value.🏁 Script executed:
Length of output: 91
🏁 Script executed:
Length of output: 2677
🏁 Script executed:
Length of output: 1924
Ensure all call sites pass the new
isSpaceMember
argumentThe
isSpaceMember
parameter now drives shared‐space access logic, and omitting it leaves itundefined
(treated as “not a member”) via!isSpaceMember
. Call sites outside of a space context should explicitly passfalse
, and pages within a space should continue passing their computed flag. Please update:• apps/web/actions/videos/get-status.ts (line 229)
Change
await userHasAccessToVideo(userPromise, video)
to
await userHasAccessToVideo(userPromise, video, false)
• apps/web/app/embed/[videoId]/page.tsx
– line 46:
await userHasAccessToVideo(userPromise, video)
→await userHasAccessToVideo(userPromise, video, false)
– line 162:
await userHasAccessToVideo(user, video)
→await userHasAccessToVideo(user, video, false)
🤖 Prompt for AI Agents