Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -9,18 +9,19 @@ import { completeOAuthCallback } from "~/modules/calendar/services/CalendarConne
import { syncConnection } from "~/modules/calendar/services/CalendarSyncService.server";
import { verifyCalendarOAuthState } from "~/modules/calendar/services/oauthState.server";
import { calendarConnectionsPath } from "~/modules/calendar/routes/calendarRoutePaths";
import { runAuthenticatedProviderOAuthCallback } from "~/utils/integrations/providerOAuthCallbackAccess.server";
import ServerError from "~/components/ui/errors/ServerError";
function settingsRedirect(state: string | null, flag: "connected" | "error"): Response {
function settingsRedirect(state: string | null, messageKey: string): Response {
// Best-effort: recover the tenant slug from the (verified) state so the user
// lands back on their own settings page even on the error path.
if (state) {
const verified = verifyCalendarOAuthState(state);
if (verified.ok) {
return redirect(`${calendarConnectionsPath(verified.payload.tenantSlug)}?calendar=${flag}`);
return redirect(`${calendarConnectionsPath(verified.payload.tenantSlug)}?toast=${encodeURIComponent(messageKey)}`);
}
}
return redirect(`/?calendar=${flag}`);
return redirect("/");
}
export const loader = async ({ request }: LoaderFunctionArgs) => {
@@ -29,18 +30,26 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
const state = url.searchParams.get("state");
const providerError = url.searchParams.get("error");
if (providerError || !code || !state) {
return settingsRedirect(state, "error");
if (!state) {
return settingsRedirect(state, "calendar.toast.connectFailed");
}
const verified = verifyCalendarOAuthState(state);
if (!verified.ok || providerError || !code) return settingsRedirect(state, "calendar.toast.connectFailed");
try {
const { tenantSlug, tenantId, connectionId } = await completeOAuthCallback({ code, state });
// Best-effort initial pull so the calendar is populated right after connect
// (M25 "Initial-Sync läuft"). A failure here must not break the connect — the
// webhook + cron will catch up; the connection is already persisted.
await syncConnection(tenantId, connectionId).catch(() => undefined);
return redirect(`${calendarConnectionsPath(tenantSlug)}?calendar=connected`);
const { tenantSlug } = await runAuthenticatedProviderOAuthCallback({
request,
tenantId: verified.payload.tenantId,
userId: verified.payload.userId,
callback: async () => {
const completed = await completeOAuthCallback({ code, state });
// Best-effort initial pull so the calendar is populated right after connect.
await syncConnection(completed.tenantId, completed.connectionId).catch(() => undefined);
return completed;
},
});
return redirect(`${calendarConnectionsPath(tenantSlug)}?toast=${encodeURIComponent("calendar.toast.connected")}`);
} catch {
return settingsRedirect(state, "error");
return settingsRedirect(state, "calendar.toast.connectFailed");
}
};