Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/web/actions/caps/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import {
spaceVideos,
videos,
} from "@cap/database/schema";
import type { Video } from "@cap/web-domain";
import type { Organisation, Space, Video } from "@cap/web-domain";
import { and, eq, inArray } from "drizzle-orm";
import { revalidatePath } from "next/cache";

interface ShareCapParams {
capId: Video.VideoId;
spaceIds: string[];
spaceIds: Space.SpaceIdOrOrganisationId[];
public?: boolean;
}

Expand Down Expand Up @@ -53,7 +53,7 @@ export async function shareCap({
.from(organizations)
.where(
and(
inArray(organizations.id, spaceIds),
inArray(organizations.id, spaceIds as Organisation.OrganisationId[]),
inArray(organizations.id, userOrganizationIds),
),
)
Expand Down
5 changes: 4 additions & 1 deletion apps/web/actions/organization/check-domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import { getCurrentUser } from "@cap/database/auth/session";
import { organizations } from "@cap/database/schema";
import { eq } from "drizzle-orm";
import { checkDomainStatus } from "./domain-utils";
import { Organisation } from "@cap/web-domain";

export async function checkOrganizationDomain(organizationId: string) {
export async function checkOrganizationDomain(
organizationId: Organisation.OrganisationId,
) {
const user = await getCurrentUser();

if (!user || !organizationId) {
Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/organization/create-space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Effect, Option } from "effect";
import { revalidatePath } from "next/cache";
import { v4 as uuidv4 } from "uuid";
import { runPromise } from "@/lib/server";
import { Space } from "@cap/web-domain";

interface CreateSpaceResponse {
success: boolean;
Expand Down Expand Up @@ -62,7 +63,7 @@ export async function createSpace(
}

// Generate the space ID early so we can use it in the file path
const spaceId = nanoId();
const spaceId = Space.SpaceId.make(nanoId());

const iconFile = formData.get("icon") as File | null;
let iconUrl = null;
Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/organization/delete-space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import { eq } from "drizzle-orm";
import { Effect, Option } from "effect";
import { revalidatePath } from "next/cache";
import { runPromise } from "@/lib/server";
import { Space } from "@cap/web-domain";

interface DeleteSpaceResponse {
success: boolean;
error?: string;
}

export async function deleteSpace(
spaceId: string,
spaceId: Space.SpaceIdOrOrganisationId,
): Promise<DeleteSpaceResponse> {
try {
const user = await getCurrentUser();
Expand Down
5 changes: 4 additions & 1 deletion apps/web/actions/organization/get-organization-sso-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
import { db } from "@cap/database";
import { organizations } from "@cap/database/schema";
import { eq } from "drizzle-orm";
import { Organisation } from "@cap/web-domain";

export async function getOrganizationSSOData(organizationId: string) {
export async function getOrganizationSSOData(
organizationId: Organisation.OrganisationId,
) {
if (!organizationId) {
throw new Error("Organization ID is required");
}
Expand Down
5 changes: 4 additions & 1 deletion apps/web/actions/organization/remove-domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { organizations } from "@cap/database/schema";
import { Organisation } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";

export async function removeOrganizationDomain(organizationId: string) {
export async function removeOrganizationDomain(
organizationId: Organisation.OrganisationId,
) {
const user = await getCurrentUser();

if (!user) {
Expand Down
5 changes: 4 additions & 1 deletion apps/web/actions/organization/remove-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { organizations } from "@cap/database/schema";
import { Organisation } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";

export async function removeOrganizationIcon(organizationId: string) {
export async function removeOrganizationIcon(
organizationId: Organisation.OrganisationId,
) {
const user = await getCurrentUser();

if (!user) {
Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/organization/remove-invite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import { getCurrentUser } from "@cap/database/auth/session";
import { organizationInvites, organizations } from "@cap/database/schema";
import { and, eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";
import { Organisation } from "@cap/web-domain";

export async function removeOrganizationInvite(
inviteId: string,
organizationId: string,
organizationId: Organisation.OrganisationId,
) {
const user = await getCurrentUser();

Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/organization/remove-member.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getCurrentUser } from "@cap/database/auth/session";
import { organizationMembers, organizations } from "@cap/database/schema";
import { and, eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";
import { Organisation } from "@cap/web-domain";

/**
* Remove a member from an organization. Only the owner can perform this action.
Expand All @@ -13,7 +14,7 @@ import { revalidatePath } from "next/cache";
*/
export async function removeOrganizationMember(
memberId: string,
organizationId: string,
organizationId: Organisation.OrganisationId,
) {
const user = await getCurrentUser();
if (!user) throw new Error("Unauthorized");
Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/organization/send-invites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import { OrganizationInvite } from "@cap/database/emails/organization-invite";
import { nanoId } from "@cap/database/helpers";
import { organizationInvites, organizations } from "@cap/database/schema";
import { serverEnv } from "@cap/env";
import { Organisation } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";

export async function sendOrganizationInvites(
invitedEmails: string[],
organizationId: string,
organizationId: Organisation.OrganisationId,
) {
const user = await getCurrentUser();

Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/organization/update-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { organizations } from "@cap/database/schema";
import { Organisation } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";

Expand All @@ -13,7 +14,7 @@ export async function updateOrganizationDetails({
}: {
organizationName?: string | null;
allowedEmailDomain?: string | null;
organizationId: string;
organizationId: Organisation.OrganisationId;
}) {
const user = await getCurrentUser();

Expand Down
6 changes: 5 additions & 1 deletion apps/web/actions/organization/update-domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ import { organizations } from "@cap/database/schema";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";
import { addDomain, checkDomainStatus } from "./domain-utils";
import { Organisation } from "@cap/web-domain";

export async function updateDomain(domain: string, organizationId: string) {
export async function updateDomain(
domain: string,
organizationId: Organisation.OrganisationId,
) {
const user = await getCurrentUser();

if (!user) {
Expand Down
5 changes: 3 additions & 2 deletions apps/web/actions/organization/update-space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { nanoIdLength } from "@cap/database/helpers";
import { spaceMembers, spaces } from "@cap/database/schema";
import { Space, User } from "@cap/web-domain";
import { S3Buckets } from "@cap/web-backend";
import { and, eq } from "drizzle-orm";
import { Effect, Option } from "effect";
Expand All @@ -16,9 +17,9 @@ export async function updateSpace(formData: FormData) {
const user = await getCurrentUser();
if (!user) return { success: false, error: "Unauthorized" };

const id = formData.get("id") as string;
const id = Space.SpaceId.make(formData.get("id") as string);
const name = formData.get("name") as string;
const members = formData.getAll("members[]") as string[];
const members = formData.getAll("members[]") as User.UserId[];
Comment thread
coderabbitai[bot] marked this conversation as resolved.
const iconFile = formData.get("icon") as File | null;

const [membership] = await db()
Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/organization/upload-organization-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import { JSDOM } from "jsdom";
import { revalidatePath } from "next/cache";
import { sanitizeFile } from "@/lib/sanitizeFile";
import { runPromise } from "@/lib/server";
import { Organisation } from "@cap/web-domain";

export async function uploadOrganizationIcon(
formData: FormData,
organizationId: string,
organizationId: Organisation.OrganisationId,
) {
const user = await getCurrentUser();

Expand Down
6 changes: 5 additions & 1 deletion apps/web/actions/organization/upload-space-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ import { Effect, Option } from "effect";
import { revalidatePath } from "next/cache";
import { sanitizeFile } from "@/lib/sanitizeFile";
import { runPromise } from "@/lib/server";
import { Space } from "@cap/web-domain";

export async function uploadSpaceIcon(formData: FormData, spaceId: string) {
export async function uploadSpaceIcon(
formData: FormData,
spaceId: Space.SpaceId,
) {
const user = await getCurrentUser();

if (!user) {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/actions/organizations/add-videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
sharedVideos,
videos,
} from "@cap/database/schema";
import type { Video } from "@cap/web-domain";
import type { Organisation, Video } from "@cap/web-domain";
import { and, eq, inArray } from "drizzle-orm";
import { revalidatePath } from "next/cache";

export async function addVideosToOrganization(
organizationId: string,
organizationId: Organisation.OrganisationId,
videoIds: Video.VideoId[],
) {
try {
Expand Down
5 changes: 4 additions & 1 deletion apps/web/actions/organizations/get-organization-videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { sharedVideos } from "@cap/database/schema";
import { Organisation } from "@cap/web-domain";
import { eq } from "drizzle-orm";

export async function getOrganizationVideoIds(organizationId: string) {
export async function getOrganizationVideoIds(
organizationId: Organisation.OrganisationId,
) {
try {
const user = await getCurrentUser();

Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/organizations/remove-videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import {
import type { Video } from "@cap/web-domain";
import { and, eq, inArray } from "drizzle-orm";
import { revalidatePath } from "next/cache";
import { Organisation } from "@cap/web-domain";

export async function removeVideosFromOrganization(
organizationId: string,
organizationId: Organisation.OrganisationId,
videoIds: Video.VideoId[],
) {
try {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/actions/spaces/add-videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { nanoId } from "@cap/database/helpers";
import { spaces, spaceVideos, videos } from "@cap/database/schema";
import type { Video } from "@cap/web-domain";
import type { Space, Video } from "@cap/web-domain";
import { and, eq, inArray } from "drizzle-orm";
import { revalidatePath } from "next/cache";

export async function addVideosToSpace(
spaceId: string,
spaceId: Space.SpaceIdOrOrganisationId,
videoIds: Video.VideoId[],
) {
try {
Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/spaces/get-space-videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { spaceVideos } from "@cap/database/schema";
import { Space } from "@cap/web-domain";
import { eq } from "drizzle-orm";

export async function getSpaceVideoIds(spaceId: string) {
export async function getSpaceVideoIds(spaceId: Space.SpaceIdOrOrganisationId) {
try {
const user = await getCurrentUser();

Expand Down
4 changes: 2 additions & 2 deletions apps/web/actions/spaces/remove-videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { folders, spaceVideos, videos } from "@cap/database/schema";
import type { Video } from "@cap/web-domain";
import type { Video, Space } from "@cap/web-domain";
import { and, eq, inArray } from "drizzle-orm";
import { revalidatePath } from "next/cache";

export async function removeVideosFromSpace(
spaceId: string,
spaceId: Space.SpaceIdOrOrganisationId,
videoIds: Video.VideoId[],
) {
try {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/actions/video/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { s3Buckets, videos, videoUploads } from "@cap/database/schema";
import { buildEnv, NODE_ENV, serverEnv } from "@cap/env";
import { userIsPro } from "@cap/utils";
import { S3Buckets } from "@cap/web-backend";
import { type Folder, Video } from "@cap/web-domain";
import { type Folder, Organisation, Video } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { Effect, Option } from "effect";
import { revalidatePath } from "next/cache";
Expand Down Expand Up @@ -175,7 +175,7 @@ export async function createVideoAndGetUploadUrl({
isScreenshot?: boolean;
isUpload?: boolean;
folderId?: Folder.FolderId;
orgId: string;
orgId: Organisation.OrganisationId;
// TODO: Remove this once we are happy with it's stability
supportsUploadProgress?: boolean;
}) {
Expand Down
7 changes: 4 additions & 3 deletions apps/web/actions/videos/delete-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import { getCurrentUser } from "@cap/database/auth/session";
import { comments, notifications } from "@cap/database/schema";
import { and, eq, sql } from "drizzle-orm";
import { revalidatePath } from "next/cache";
import type { Comment, Video } from "@cap/web-domain";

export async function deleteComment({
commentId,
parentId,
videoId,
}: {
commentId: string;
parentId?: string;
videoId: string;
commentId: Comment.CommentId;
parentId?: Comment.CommentId;
videoId: Video.VideoId;
}) {
const user = await getCurrentUser();

Expand Down
6 changes: 3 additions & 3 deletions apps/web/actions/videos/new-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { nanoId } from "@cap/database/helpers";
import { comments } from "@cap/database/schema";
import type { Video } from "@cap/web-domain";
import { Video, Comment } from "@cap/web-domain";
import { revalidatePath } from "next/cache";
import { createNotification } from "@/lib/Notification";

export async function newComment(data: {
content: string;
videoId: Video.VideoId;
type: "text" | "emoji";
parentCommentId: string;
parentCommentId: Comment.CommentId;
timestamp: number;
}) {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
const user = await getCurrentUser();
Expand All @@ -35,7 +35,7 @@ export async function newComment(data: {
if (!content || !videoId) {
throw new Error("Content and videoId are required");
}
const id = nanoId();
const id = Comment.CommentId.make(nanoId());

const newComment = {
id: id,
Expand Down
Loading
Loading