Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

1.1 KB
Raw Blame
import { and, eq, not } from "drizzle-orm";
import db from "../database";
import {
  userNotificationWorkspaceProjectTable,
  userNotificationWorkspaceRuleTable,
} from "../database/schema";
import { projectAccessCondition } from "../project-access/project-access-condition";

export async function findHiddenRuleProjectIds(
  userId: string,
  workspaceId: string,
): Promise<string[]> {
  const rows = await db
    .select({ projectId: userNotificationWorkspaceProjectTable.projectId })
    .from(userNotificationWorkspaceProjectTable)
    .innerJoin(
      userNotificationWorkspaceRuleTable,
      eq(
        userNotificationWorkspaceRuleTable.id,
        userNotificationWorkspaceProjectTable.workspaceRuleId,
      ),
    )
    .where(
      and(
        eq(userNotificationWorkspaceRuleTable.userId, userId),
        eq(userNotificationWorkspaceRuleTable.workspaceId, workspaceId),
        not(
          projectAccessCondition(
            userId,
            userNotificationWorkspaceProjectTable.projectId,
          ),
        ),
      ),
    );
  return rows.map((row) => row.projectId);
}