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 type { z } from "../../openapi";
import type { getServiceStatus } from "../system/get-service-status";
import type { overviewWarningSchema } from "./response";

type Warning = z.infer<typeof overviewWarningSchema>;

export function configurationWarnings(
  services: Awaited<ReturnType<typeof getServiceStatus>>,
  registration: boolean,
  enabledAdmins: number,
): Warning[] {
  const warnings: Warning[] = [];
  if (!services.email.configured) warnings.push("smtp_not_configured");
  else if (services.email.status === "down") warnings.push("smtp_unreachable");
  if (services.redis.status === "down" || services.redis.status === "warning") {
    warnings.push("redis_unreachable");
  }
  if (services.storage.errorCode === "INCOMPLETE_CONFIG")
    warnings.push("storage_incomplete");
  // A 403 "warning" is expected for upload-only bucket policies.
  else if (services.storage.status === "down") {
    warnings.push("storage_unreachable");
  }
  if (registration && !services.email.configured)
    warnings.push("registration_without_email");
  if (enabledAdmins < 2) warnings.push("no_second_admin");
  return warnings;
}