import { db, userBlocks, eq, and, or } from "@epicure/db";

/** True if either user has blocked the other. */
export async function isBlockedEitherWay(userIdA: string, userIdB: string): Promise<boolean> {
  const row = await db.query.userBlocks.findFirst({
    where: or(
      and(eq(userBlocks.blockerId, userIdA), eq(userBlocks.blockedId, userIdB)),
      and(eq(userBlocks.blockerId, userIdB), eq(userBlocks.blockedId, userIdA))
    ),
  });
  return !!row;
}
