From 8b8cab25e8c760db12fdd55b85171f177d6990f3 Mon Sep 17 00:00:00 2001
From: KitKat31337 <4126578+KitKat31337@users.noreply.github.com>
Date: Fri, 6 Nov 2026 18:48:54 +0000
Subject: [PATCH 1/2] feat: add unlisted event type visibility
---
docs/ARCHITECTURE.md | 20 ++
frontend/src/lib/api.ts | 2 +
.../event-types/VisibilitySelect.svelte | 23 +++
.../event-types/VisibilitySelect.test.ts | 32 +++
frontend/src/lib/i18n/en.json | 17 +-
frontend/src/lib/i18n/fr.json | 17 +-
frontend/src/routes/event-types/+page.svelte | 10 +-
.../routes/event-types/[slug]/+page.svelte | 17 +-
.../event_type_visibility_migration_test.go | 78 ++++++++
.../migrations/00072_event_type_unlisted.sql | 10 +
internal/handler/directory.go | 4 +-
internal/handler/event_type.go | 59 ++++--
internal/handler/event_type_duplicate.go | 4 +-
internal/handler/event_type_duplicate_test.go | 2 +-
internal/handler/event_type_unlisted_test.go | 182 ++++++++++++++++++
15 files changed, 436 insertions(+), 41 deletions(-)
create mode 100644 frontend/src/lib/components/event-types/VisibilitySelect.svelte
create mode 100644 frontend/src/lib/components/event-types/VisibilitySelect.test.ts
create mode 100644 internal/db/event_type_visibility_migration_test.go
create mode 100644 internal/db/migrations/00072_event_type_unlisted.sql
create mode 100644 internal/handler/event_type_unlisted_test.go
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index 0856972d..021f9605 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -818,6 +818,26 @@ as the desired state:
## 14. Visibility model
+Event types have three visibility choices, independent of **Active**:
+
+- **Public** (the default): direct booking is accessible and the event type is listed
+ in the existing person/team directories.
+- **Unlisted**: direct booking works normally, but directories omit the event type.
+ Anyone with the URL can book without signing in; this is discoverability, not access control.
+- **Private**: direct booking is inaccessible and directories omit the event type.
+
+Inactive event types remain unbookable and absent from directories in every visibility
+state. Administration lists and manages all three states under the existing ownership rules.
+Create/PATCH accepts `visibility` (`public`, `unlisted`, `private`); admin responses include it.
+Migration 00072 adds `is_unlisted` (default 0), retaining `is_public` as the direct-booking
+gate so all existing Public/Private values and booking checks stay unchanged. Direct booking,
+slots, questions, embeds and the assistant use that gate; only the directory queries check
+`is_unlisted`. The authenticated MCP booking catalog retains its existing bookability filter.
+Legacy PATCH clients can still use `is_public` to choose Public/Private (clearing Unlisted).
+If both fields are sent they must agree on direct accessibility; `visibility` sets the state.
+Duplication keeps visibility and still starts inactive. Rolling migration 00072 back makes
+Unlisted types Private, avoiding unexpected directory publication by an older binary.
+
- Members see **only bookings they host** — `ListByHost` matches `bookings.host_id`
**OR** any `booking_hosts` seat, so Group/fixed non-primary attendees see meetings
they're on (not just the ones they lead).
diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts
index cd6c8723..98f17211 100644
--- a/frontend/src/lib/api.ts
+++ b/frontend/src/lib/api.ts
@@ -34,7 +34,9 @@ export type EventType = {
// duration on create; editable so a 45-minute meeting can still be offered on the hour.
slot_interval_minutes: number;
is_active: boolean;
+ /** Direct-booking gate, true for both Public and Unlisted. */
is_public: boolean;
+ visibility: 'public' | 'unlisted' | 'private';
/** Show already-booked times struck through on the booking page instead of hiding
* them. Off by default: the slots endpoint is public, so this makes the host's
* booked hours visible to anyone with the link. */
diff --git a/frontend/src/lib/components/event-types/VisibilitySelect.svelte b/frontend/src/lib/components/event-types/VisibilitySelect.svelte
new file mode 100644
index 00000000..0b957231
--- /dev/null
+++ b/frontend/src/lib/components/event-types/VisibilitySelect.svelte
@@ -0,0 +1,23 @@
+
+
+
diff --git a/frontend/src/lib/components/event-types/VisibilitySelect.test.ts b/frontend/src/lib/components/event-types/VisibilitySelect.test.ts
new file mode 100644
index 00000000..43b8c3d6
--- /dev/null
+++ b/frontend/src/lib/components/event-types/VisibilitySelect.test.ts
@@ -0,0 +1,32 @@
+import { afterEach, expect, test } from 'vitest';
+import { page } from 'vitest/browser';
+import { cleanup, render } from 'vitest-browser-svelte';
+import VisibilitySelect from './VisibilitySelect.svelte';
+import { setLocale } from '$lib/i18n';
+
+afterEach(cleanup);
+
+test('visibility defaults to Public and explains each selection', async () => {
+ setLocale('en');
+ await render(VisibilitySelect);
+ const control = page.getByRole('button', { name: 'Visibility' });
+ await expect.element(control).toHaveTextContent('Public');
+ await expect.element(page.getByText('Listed in public directories and bookable by anyone with the link.')).toBeVisible();
+
+ for (const [label, hint] of [
+ ['Unlisted', 'Hidden from public directories. Anyone with the link can book; no sign-in is required.'],
+ ['Private', 'Hidden from public directories and unavailable through the public booking link.'],
+ ['Public', 'Listed in public directories and bookable by anyone with the link.']
+ ]) {
+ await control.click();
+ await page.getByRole('option', { name: label, exact: true }).click();
+ await expect.element(control).toHaveTextContent(label);
+ await expect.element(page.getByText(hint, { exact: true })).toBeVisible();
+ }
+});
+
+test('an existing Unlisted value is displayed on load', async () => {
+ setLocale('en');
+ await render(VisibilitySelect, { props: { value: 'unlisted' } });
+ await expect.element(page.getByRole('button', { name: 'Visibility' })).toHaveTextContent('Unlisted');
+});
diff --git a/frontend/src/lib/i18n/en.json b/frontend/src/lib/i18n/en.json
index 6572f081..e03065e3 100644
--- a/frontend/src/lib/i18n/en.json
+++ b/frontend/src/lib/i18n/en.json
@@ -545,6 +545,17 @@
}
},
"eventTypes": {
+ "visibility": {
+ "label": "Visibility",
+ "public": "Public",
+ "unlisted": "Unlisted",
+ "private": "Private",
+ "hint": {
+ "public": "Listed in public directories and bookable by anyone with the link.",
+ "unlisted": "Hidden from public directories. Anyone with the link can book; no sign-in is required.",
+ "private": "Hidden from public directories and unavailable through the public booking link."
+ }
+ },
"headTitle": "Event Types — Calnode",
"title": "Event Types",
"subtitle": {
@@ -1597,9 +1608,7 @@
},
"status": {
"active": "Active",
- "inactive": "Inactive",
- "listed": "Listed",
- "unlisted": "Unlisted (link only)"
+ "inactive": "Inactive"
},
"durationSuffix": " min"
},
@@ -1622,8 +1631,6 @@
"descriptionPlaceholder": "Optional — supports **bold** and *italic* markdown",
"status": "Status",
"active": "Active (accepting bookings)",
- "visibility": "Visibility",
- "public": "Public (visible in booking page)",
"showTaken": "Show booked times as unavailable",
"showTakenHint": "Booked times appear struck through on the booking page instead of being hidden, so visitors can see the calendar filling up. Only times inside your working hours are shown, never the rest of your day.",
"showTakenWarning": "Anyone with the booking link can see which hours are taken.",
diff --git a/frontend/src/lib/i18n/fr.json b/frontend/src/lib/i18n/fr.json
index 34f34ae4..6611bcbb 100644
--- a/frontend/src/lib/i18n/fr.json
+++ b/frontend/src/lib/i18n/fr.json
@@ -545,6 +545,17 @@
}
},
"eventTypes": {
+ "visibility": {
+ "label": "Visibilité",
+ "public": "Public",
+ "unlisted": "Non répertorié",
+ "private": "Privé",
+ "hint": {
+ "public": "Visible dans les annuaires publics. Toute personne disposant du lien peut réserver.",
+ "unlisted": "Masqué dans les annuaires publics. Toute personne disposant du lien peut réserver, sans connexion.",
+ "private": "Masqué dans les annuaires publics et inaccessible via le lien de réservation public."
+ }
+ },
"headTitle": "Types de rendez-vous — Calnode",
"title": "Types de rendez-vous",
"subtitle": {
@@ -1597,9 +1608,7 @@
},
"status": {
"active": "Actif",
- "inactive": "Inactif",
- "listed": "Répertorié",
- "unlisted": "Non répertorié (lien uniquement)"
+ "inactive": "Inactif"
},
"durationSuffix": " min"
},
@@ -1622,8 +1631,6 @@
"descriptionPlaceholder": "Facultatif — prend en charge le markdown **gras** et *italique*",
"status": "Statut",
"active": "Actif (accepte les réservations)",
- "visibility": "Visibilité",
- "public": "Public (visible sur la page de réservation)",
"showTaken": "Afficher les horaires réservés comme indisponibles",
"showTakenHint": "Les horaires réservés apparaissent barrés sur la page de réservation au lieu d'être masqués, afin que les visiteurs voient le calendrier se remplir. Seuls les horaires dans vos heures de travail sont affichés, jamais le reste de votre journée.",
"showTakenWarning": "Quiconque dispose du lien de réservation peut voir quels horaires sont pris.",
diff --git a/frontend/src/routes/event-types/+page.svelte b/frontend/src/routes/event-types/+page.svelte
index 9a1df60f..c52dac44 100644
--- a/frontend/src/routes/event-types/+page.svelte
+++ b/frontend/src/routes/event-types/+page.svelte
@@ -1,4 +1,5 @@