Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(web-backend): expose space passwords and settings in queries

Richie McIlroy9d913ce2c2f3
diff --git a/packages/web-backend/src/Spaces/SpacesRepo.ts b/packages/web-backend/src/Spaces/SpacesRepo.ts
index bf2a8d000..46035b912 100644
--- a/packages/web-backend/src/Spaces/SpacesRepo.ts
+++ b/packages/web-backend/src/Spaces/SpacesRepo.ts
@@ -29,6 +29,19 @@ export class SpacesRepo extends Effect.Service<SpacesRepo>()("SpacesRepo", {
)
.pipe(Effect.map(Array.get(0))),
+ passwordsForVideo: (videoId: Video.VideoId) =>
+ db.use((db) =>
+ db
+ .select({
+ id: Db.spaces.id,
+ name: Db.spaces.name,
+ password: Db.spaces.password,
+ })
+ .from(Db.spaceVideos)
+ .innerJoin(Db.spaces, Dz.eq(Db.spaceVideos.spaceId, Db.spaces.id))
+ .where(Dz.eq(Db.spaceVideos.videoId, videoId)),
+ ),
+
membership: (
userId: User.UserId,
spaceId: Space.SpaceIdOrOrganisationId,
diff --git a/packages/web-backend/src/Spaces/index.ts b/packages/web-backend/src/Spaces/index.ts
index c0aecf7ba..606094dc1 100644
--- a/packages/web-backend/src/Spaces/index.ts
+++ b/packages/web-backend/src/Spaces/index.ts
@@ -26,6 +26,11 @@ export class Spaces extends Effect.Service<Spaces>()("Spaces", {
name: Db.spaces.name,
organizationId: Db.spaces.organizationId,
createdById: Db.spaces.createdById,
+ iconUrl: Db.spaces.iconUrl,
+ settings: Db.spaces.settings,
+ hasPassword: Dz.sql`${Db.spaces.password} IS NOT NULL`.mapWith(
+ Boolean,
+ ),
})
.from(Db.spaces)
.where(Dz.eq(Db.spaces.id, spaceOrOrgId))