Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ exact tag (`ghcr.io/calnode/calnode:0.1.0`) if you need stability between upgrad
matters for this release — verifies the key file is persisted and that a restart unwraps
the existing data key rather than generating a new one. On a publish it pulls the exact
digest the build job produced, so it cannot pass against a stale tag.
- **Calendar invites can be left to your own system.** *Calendar invite → Sent by* gains a
third choice, *No one*. Hosts still get the meeting, with its Meet/Teams link, on their
own calendar, but the booker is not a guest there, so their calendar provider sends no
invite, and Calnode attaches none to its emails. For setups that send their own
confirmation and invite. It needs no email setup; if email is set up, the booker's
confirmation, reschedule and cancellation emails still go out, without an invite.
Existing bookings keep the way they were invited.
- **Bookings say how their invite was sent.** The booking JSON (`GET /v1/bookings`,
`GET /v1/bookings/{id}` and the MCP tools) now includes `invite_delivery` (`calendar`,
`calnode` or `none`), and webhooks can add it as a payload field. It is not in the
default field set, so existing webhooks are unchanged.

## [0.11.2] - 2026-10-28

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ domains, Resend email, Google & Microsoft OAuth, Litestream backups, troubleshoo
- **CalDAV calendars** — iCloud / Fastmail / Nextcloud via app-password (free/busy + event write-back)
- Public booking + self-serve **reschedule/cancel** via signed manage links
- HTML branded email (logo, banner, business name, size/opacity) with add-to-calendar links
- Per-event-type **calendar invite sender**: the host's calendar, Calnode from your workspace address, or no one (your own system sends it)
- REST API (88 endpoints) + API keys; **HMAC webhooks** with per-webhook payloads + delivery log
- **Native MCP server** (10 tools incl. meeting notes + transcript; stdio via `calnode mcp` + Streamable HTTP at `/mcp`)
- **Conversational booking** ("Book by chat" on the booking page + embed widget; BYO-LLM, off by default)
Expand Down
25 changes: 20 additions & 5 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,24 @@ instance sender from Settings → Email (`applyInviteDelivery`, `BookingData.Hid
No sender address means no `ORGANIZER` line, never a fallback to the host. Host copies keep
the host as organizer and, for a `calnode` booking, leave the booker out entirely and go out as
`METHOD:PUBLISH` (`applyHostInvite`, `ICSWithoutAttendee`), so no host calendar holds them as
a guest it could re-invite. Reschedule, cancel, reassign and the reconciler read the mode from
the **booking**, not the event type, so a booking is always updated through the channel
its invite went out on. Switching an event type to `calnode` requires email to be set up
(validated on change).
a guest it could re-invite. `none` (migration 00071) is for integrations that deliver the
invite themselves: the hosts' events are written guestless exactly as for `calnode`
(`hostEventsGuestless`) and host copies behave the same, but no Calnode email to the booker
carries an `.ics`, whatever the host's calendar (`applyInviteDelivery`). The booker's emails
themselves still go out when email is set up; whether Calnode emails at all stays with the
mailer and the notification settings. Reschedule, cancel, reassign and the reconciler read
the mode from the **booking**, not the event type, so a booking is always updated through
the channel its invite went out on. Switching an event type to `calnode` requires email to
be set up (validated on change); `none` does not. The booking JSON carries the mode as
`invite_delivery`, and webhooks can select it as a payload field (not in the default set),
so an integration can tell per booking whether the booker already holds an invite.

00071 widened the 00068 `CHECK` without a table rebuild: SQLite cannot alter a `CHECK`, and
rebuilding `bookings` would mean carrying its foreign-key children and the double-booking
index through a `NO TRANSACTION` migration (compare 00042, which rebuilt only
`event_types`). Because the `CHECK` belongs to the `invite_delivery` column alone, the
migration adds a widened copy, fills it, drops the old column and renames the copy, inside
goose's normal transaction. The column now sits last in both tables.

**RSVPs to Calnode-sent invites (migration 00069, `rsvp_inbound.go`).** A booker's
Yes/No/Maybe is an iTIP `REPLY` their mail client emails to the invite's `ORGANIZER`. Each
Expand Down Expand Up @@ -794,7 +808,8 @@ as the desired state:
- **Per-webhook payload fields:** each webhook chooses which fields land in the `data`
object (`webhooks.fields` JSON, migration 00027) — incl. attendee PII + intake
answers. NULL ⇒ the original default set (so existing webhooks are unchanged and
never start leaking PII). The payload is enriched (`enrich`) + filtered per-webhook
never start leaking PII; fields added later that every booking carries, such as
`invite_delivery`, stay out of that set for the same reason). The payload is enriched (`enrich`) + filtered per-webhook
(`buildData`) at enqueue time, so each subscriber gets its own `data`. New webhooks
default to all fields ticked (self-hoster unticks what they don't want); a
delivery-log view (status/HTTP/attempts) is in the admin webhooks page.
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ export type EventType = {
show_taken_slots: boolean;
/** Who sends the booker's calendar invite. 'calendar': each host's connected calendar,
* from the host's own address. 'calnode': Calnode's own invite, from the email sender
* in Settings → Email, so no host's personal address reaches the booker. */
invite_delivery: 'calendar' | 'calnode';
* in Settings → Email, so no host's personal address reaches the booker. 'none': no
* invite from either; the hosts' events are guestless, for integrations that send their own. */
invite_delivery: 'calendar' | 'calnode' | 'none';
/** Whether Calnode can currently send invites (a sender and working email). Only
* returned on the single event type GET. */
invite_sender_ready?: boolean;
Expand Down Expand Up @@ -114,6 +115,8 @@ export type Booking = {
amount_paid_currency?: string;
/** The booker's RSVP to a Calnode-sent invite; absent until an answer arrives. */
rsvp_status?: 'accepted' | 'declined' | 'tentative';
/** Who sent the booker's calendar invite, fixed when the booking was made. */
invite_delivery?: 'calendar' | 'calnode' | 'none';
};

export type APIKey = {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/routes/event-types/[slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
const INVITE_DELIVERY = [
{ value: 'calendar', label: "The host's calendar" },
{ value: 'calnode', label: 'Calnode, from your workspace' },
{ value: 'none', label: 'No one (you send your own)' },
];

// ── Event type ───────────────────────────────────────────────────────────────
Expand Down Expand Up @@ -746,6 +747,9 @@
Invitees get the invite from your workspace's email sender
(<a href="{base}/settings/email" class="underline">Settings → Email</a>), never from a host's
own address. Hosts still see the meeting on their own calendar, with the meeting link.
{:else if form.invite_delivery === 'none'}
Neither the host's calendar nor Calnode sends the booker an invite, for when your own
system does. Hosts still see the meeting on their own calendar, with the meeting link.
{:else}
The host's connected calendar invites the booker, so the invite shows the host's own
email address. Choose Calnode to keep hosts' addresses private or to book as a team.
Expand Down
1 change: 1 addition & 0 deletions frontend/src/routes/webhooks/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
{ key: 'previous_start_at', label: 'Previous start (reschedule)' },
{ key: 'previous_end_at', label: 'Previous end (reschedule)' },
{ key: 'rsvp_status', label: 'RSVP answer (booking.rsvp)' },
{ key: 'invite_delivery', label: 'Invite sent by (calendar, calnode, none)' },
] },
{ group: 'Payment', fields: [
{ key: 'payment_status', label: 'Payment status' },
Expand Down
13 changes: 9 additions & 4 deletions internal/booking/booking.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ var (
)

// Who sends a booking's calendar invite to the booker (event_types/bookings.invite_delivery,
// migration 00068).
// migrations 00068 and 00071).
const (
// InviteByCalendar: the booker is a guest on each host's calendar event, and the host's
// provider (Google, Microsoft) emails the invite from the host's own account.
InviteByCalendar = "calendar"
// InviteByCalnode: the hosts' events are created without guests, and Calnode sends the
// invite itself, organized by the instance's sender identity instead of any one host.
InviteByCalnode = "calnode"
// InviteByNone: the hosts' events are created without guests, as for InviteByCalnode,
// but Calnode attaches no invite either. For integrations that deliver the invite
// themselves; with Calnode's own email set up, the booker's emails still go out.
InviteByNone = "none"
)

// Booking is a confirmed or cancelled appointment.
Expand All @@ -48,8 +52,8 @@ type Booking struct {
// ConfirmFailed reports whether the initial confirmation email failed (after
// retry). Operator-visible via the booking JSON; see migration 00064.
ConfirmFailed bool
// InviteDelivery is who sent this booking's invite (InviteByCalendar/InviteByCalnode),
// fixed at creation; reschedule, cancel and reassign follow it.
// InviteDelivery is who sent this booking's invite (InviteByCalendar/InviteByCalnode/
// InviteByNone), fixed at creation; reschedule, cancel and reassign follow it.
InviteDelivery string
}

Expand Down Expand Up @@ -108,7 +112,8 @@ type CreateParams struct {
MaxBookingsPerHour int
// InviteDelivery records who sends the booker's calendar invite for this booking:
// InviteByCalendar (the hosts' connected calendars; the default when empty) or
// InviteByCalnode (Calnode's own .ics, with the hosts' events created guestless).
// InviteByCalnode (Calnode's own .ics, with the hosts' events created guestless) or
// InviteByNone (guestless host events and no .ics; the integration sends the invite).
// Stored on the booking so its reschedule and cancel follow the mode it was created
// with, not whatever the event type is set to by then.
InviteDelivery string
Expand Down
124 changes: 124 additions & 0 deletions internal/db/invite_delivery_migration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package db_test

import (
"database/sql"
"os"
"strings"
"testing"

"github.com/calnode/calnode/internal/db"
"github.com/pressly/goose/v3"
)

// migrateTo70WithInviteModes starts from the schema before invite_delivery gained 'none'
// and seeds one event type and one booking per mode that existed then.
func migrateTo70WithInviteModes(t *testing.T) *sql.DB {
t.Helper()
database, err := db.Open("sqlite://:memory:")
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { database.Close() })
goose.SetBaseFS(os.DirFS("."))
if err := goose.SetDialect("sqlite3"); err != nil {
t.Fatal(err)
}
if err := goose.UpTo(database, "migrations", 70); err != nil {
t.Fatal(err)
}
for _, q := range []string{
`INSERT INTO users (id,email,name) VALUES ('owner','owner@example.com','Owner')`,
`INSERT INTO event_types (id,user_id,slug,name,duration_minutes,invite_delivery) VALUES ('et-cal','owner','cal','Cal',30,'calendar')`,
`INSERT INTO event_types (id,user_id,slug,name,duration_minutes,invite_delivery) VALUES ('et-cn','owner','cn','Cn',30,'calnode')`,
`INSERT INTO bookings (id,event_type_id,host_id,start_at,end_at,invite_delivery) VALUES ('b-cal','et-cal','owner','2026-11-02T10:00:00Z','2026-11-02T10:30:00Z','calendar')`,
`INSERT INTO bookings (id,event_type_id,host_id,start_at,end_at,invite_delivery) VALUES ('b-cn','et-cn','owner','2026-11-02T11:00:00Z','2026-11-02T11:30:00Z','calnode')`,
`INSERT INTO booking_attendees (id,booking_id,name,email,is_organizer) VALUES ('a-1','b-cn','Guest','guest@example.com',1)`,
} {
if _, err := database.Exec(q); err != nil {
t.Fatalf("seed %q: %v", q, err)
}
}
return database
}

// The column swap in 00071 must keep every stored mode, leave child rows and the
// double-booking guard alone, and accept 'none' while still rejecting unknown values.
func TestMigrate_inviteDeliveryNoneKeepsExistingModes(t *testing.T) {
database := migrateTo70WithInviteModes(t)
if err := db.Migrate(database); err != nil {
t.Fatal(err)
}

for table, want := range map[string]map[string]string{
"event_types": {"et-cal": "calendar", "et-cn": "calnode"},
"bookings": {"b-cal": "calendar", "b-cn": "calnode"},
} {
for id, mode := range want {
var got string
if err := database.QueryRow(`SELECT invite_delivery FROM `+table+` WHERE id = ?`, id).Scan(&got); err != nil {
t.Fatalf("%s %s: %v", table, id, err)
}
if got != mode {
t.Errorf("%s %s invite_delivery = %q after migrating; want %q", table, id, got, mode)
}
}
}
var attendees int
if err := database.QueryRow(`SELECT COUNT(*) FROM booking_attendees WHERE booking_id = 'b-cn'`).Scan(&attendees); err != nil || attendees != 1 {
t.Errorf("booking attendees after migrating = %d (%v); want the seeded one kept", attendees, err)
}

if _, err := database.Exec(`INSERT INTO event_types (id,user_id,slug,name,duration_minutes,invite_delivery) VALUES ('et-none','owner','none','None',30,'none')`); err != nil {
t.Fatalf("event type with invite_delivery 'none': %v", err)
}
if _, err := database.Exec(`INSERT INTO bookings (id,event_type_id,host_id,start_at,end_at,invite_delivery) VALUES ('b-none','et-none','owner','2026-11-02T12:00:00Z','2026-11-02T12:30:00Z','none')`); err != nil {
t.Fatalf("booking with invite_delivery 'none': %v", err)
}
for _, q := range []string{
`INSERT INTO event_types (id,user_id,slug,name,duration_minutes,invite_delivery) VALUES ('et-bad','owner','bad','Bad',30,'carrier-pigeon')`,
`INSERT INTO bookings (id,event_type_id,host_id,start_at,end_at,invite_delivery) VALUES ('b-bad','et-cal','owner','2026-11-02T13:00:00Z','2026-11-02T13:30:00Z','carrier-pigeon')`,
} {
if _, err := database.Exec(q); err == nil || !strings.Contains(err.Error(), "CHECK") {
t.Errorf("unknown invite_delivery accepted (err=%v); want the CHECK to reject it: %s", err, q)
}
}
var defaulted string
if _, err := database.Exec(`INSERT INTO bookings (id,event_type_id,host_id,start_at,end_at) VALUES ('b-def','et-cal','owner','2026-11-02T14:00:00Z','2026-11-02T14:30:00Z')`); err != nil {
t.Fatal(err)
}
if err := database.QueryRow(`SELECT invite_delivery FROM bookings WHERE id = 'b-def'`).Scan(&defaulted); err != nil || defaulted != "calendar" {
t.Errorf("default invite_delivery = %q (%v); want 'calendar'", defaulted, err)
}

// The double-booking guard is an index on bookings; a table rebuild could have lost it.
if _, err := database.Exec(`INSERT INTO bookings (id,event_type_id,host_id,start_at,end_at) VALUES ('b-dup','et-cal','owner','2026-11-02T10:00:00Z','2026-11-02T10:30:00Z')`); err == nil {
t.Error("double booking accepted after migrating; idx_bookings_no_double is gone")
}
}

// Rolling back maps 'none' to 'calnode', which an older binary reads as guestless too.
func TestMigrate_inviteDeliveryNoneDownKeepsEventsGuestless(t *testing.T) {
database := migrateTo70WithInviteModes(t)
if err := goose.UpTo(database, "migrations", 71); err != nil {
t.Fatal(err)
}
if _, err := database.Exec(`UPDATE bookings SET invite_delivery = 'none' WHERE id = 'b-cn'`); err != nil {
t.Fatal(err)
}
if _, err := database.Exec(`UPDATE event_types SET invite_delivery = 'none' WHERE id = 'et-cn'`); err != nil {
t.Fatal(err)
}
if err := goose.DownTo(database, "migrations", 70); err != nil {
t.Fatal(err)
}
var b, et string
if err := database.QueryRow(`SELECT invite_delivery FROM bookings WHERE id = 'b-cn'`).Scan(&b); err != nil {
t.Fatal(err)
}
if err := database.QueryRow(`SELECT invite_delivery FROM event_types WHERE id = 'et-cn'`).Scan(&et); err != nil {
t.Fatal(err)
}
if b != "calnode" || et != "calnode" {
t.Errorf("after down: booking %q, event type %q; want both 'calnode'", b, et)
}
}
33 changes: 33 additions & 0 deletions internal/db/migrations/00071_invite_delivery_none.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
-- +goose Up
-- A third invite_delivery mode, 'none': the hosts' events are created without guests,
-- exactly as for 'calnode', but Calnode attaches no invite to the booker's emails either.
-- For integrations that deliver the invite themselves (their own confirmation email with
-- their own .ics), where any invite from the provider or from Calnode would be a duplicate.
--
-- 00068 declared the allowed values as a column CHECK, and SQLite cannot ALTER a CHECK.
-- Rather than rebuild bookings and event_types (00042 rebuilt event_types with
-- NO TRANSACTION + foreign_keys=OFF; bookings has never been rebuilt, see 00037, and
-- carries the double-booking unique index and five child tables' foreign keys), the
-- column is swapped: add a widened copy, fill it, drop the old column, take its name.
-- DROP COLUMN is allowed because nothing else in the schema names invite_delivery (its
-- only CHECK is its own), so this runs in goose's normal transaction with foreign keys
-- on, and neither table's indexes or child rows are touched. The column moves to the end
-- of each table; every query names its columns.
ALTER TABLE event_types ADD COLUMN invite_delivery_new TEXT NOT NULL DEFAULT 'calendar'
CHECK (invite_delivery_new IN ('calendar', 'calnode', 'none'));
UPDATE event_types SET invite_delivery_new = invite_delivery;
ALTER TABLE event_types DROP COLUMN invite_delivery;
ALTER TABLE event_types RENAME COLUMN invite_delivery_new TO invite_delivery;

ALTER TABLE bookings ADD COLUMN invite_delivery_new TEXT NOT NULL DEFAULT 'calendar'
CHECK (invite_delivery_new IN ('calendar', 'calnode', 'none'));
UPDATE bookings SET invite_delivery_new = invite_delivery;
ALTER TABLE bookings DROP COLUMN invite_delivery;
ALTER TABLE bookings RENAME COLUMN invite_delivery_new TO invite_delivery;

-- +goose Down
-- The widened CHECK stays (as in 00042). 'none' rows become 'calnode', the mode an older
-- binary understands that also keeps the hosts' events guestless: read as 'calendar', the
-- next reschedule or reconcile would have the host's calendar invite the booker after all.
UPDATE bookings SET invite_delivery = 'calnode' WHERE invite_delivery = 'none';
UPDATE event_types SET invite_delivery = 'calnode' WHERE invite_delivery = 'none';
11 changes: 10 additions & 1 deletion internal/handler/booking_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ type bookableEventType struct {
// so the page can grey them out. Read by the public slots endpoint only: the MCP
// tool and the booking assistant must keep seeing bookable times and nothing else.
ShowTakenSlots bool
// InviteDelivery is who sends the booker's invite (booking.InviteByCalendar/ByCalnode),
// InviteDelivery is who sends the booker's invite (booking.InviteByCalendar/ByCalnode/ByNone),
// copied onto each booking at creation.
InviteDelivery string
}
Expand Down Expand Up @@ -657,6 +657,11 @@ type bookingJSON struct {
// ConfirmFailed flags a booking whose initial confirmation email failed after
// retry — operator-visible so a lost confirmation can be followed up manually.
ConfirmFailed bool `json:"confirm_failed,omitempty"`
// InviteDelivery is who sent this booking's calendar invite, fixed when it was made:
// "calendar" (the host's calendar invited the booker), "calnode" (Calnode's .ics) or
// "none" (nobody; the integration sends its own). Always present, so an integration
// can tell whether the booker already holds an invite.
InviteDelivery string `json:"invite_delivery" jsonschema:"who sent the booker's calendar invite: calendar (the host's calendar), calnode (Calnode's own email), or none (no invite was sent)"`
// RSVPStatus is the booker's answer to a Calnode-sent invite ("accepted", "declined",
// "tentative"), absent until one arrives. Admin list views only.
RSVPStatus string `json:"rsvp_status,omitempty"`
Expand Down Expand Up @@ -684,6 +689,10 @@ func toBookingJSON(b *booking.Booking) bookingJSON {
LocationType: b.LocationType,
CreatedAt: b.CreatedAt.UTC().Format(time.RFC3339),
UpdatedAt: b.UpdatedAt.UTC().Format(time.RFC3339),
InviteDelivery: b.InviteDelivery,
}
if j.InviteDelivery == "" {
j.InviteDelivery = booking.InviteByCalendar
}
// Payment fields are omitted for free bookings (payment_status defaults to 'none').
if b.PaymentStatus != "" && b.PaymentStatus != "none" {
Expand Down
Loading
Loading