Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(calendar): distinguish creator from target calendar (#5974)

teob1f738daf660
diff --git a/.sqlx/query-038479edc9ca5b5ec65f8729b77ee3ae466d779973a064b09da232a6fe66836b.json b/.sqlx/query-038479edc9ca5b5ec65f8729b77ee3ae466d779973a064b09da232a6fe66836b.json
new file mode 100644
index 0000000000..d3f7dfe3f3
--- /dev/null
+++ b/.sqlx/query-038479edc9ca5b5ec65f8729b77ee3ae466d779973a064b09da232a6fe66836b.json
@@ -0,0 +1,56 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n INSERT INTO calendar_events (\n id, owner_id, source_link_id, ical_uid, title, description, location,\n status, visibility, transparency,\n starts_at, ends_at, start_date, end_date, time_zone,\n recurrence_lines, organizer_email, organizer_name,\n creator_email, creator_name,\n conference_url, conference_provider, sequence, is_read_only,\n canonical_source_kind,\n canonical_source_updated_at,\n reminders_use_default, reminder_overrides,\n created_at, updated_at\n )\n VALUES (\n $1, $2, $3, $4, $5, $6, $7,\n $8, $9, $10,\n $11, $12, $13, $14, $15,\n $16, $17, $18,\n $28, $29,\n $19, $27, $20, $21, $22, $24,\n $25, $26,\n $23, $24\n )\n ON CONFLICT (owner_id, source_link_id, ical_uid) DO UPDATE SET\n title = EXCLUDED.title,\n description = EXCLUDED.description,\n location = EXCLUDED.location,\n status = EXCLUDED.status,\n visibility = EXCLUDED.visibility,\n transparency = EXCLUDED.transparency,\n starts_at = EXCLUDED.starts_at,\n ends_at = EXCLUDED.ends_at,\n start_date = EXCLUDED.start_date,\n end_date = EXCLUDED.end_date,\n time_zone = EXCLUDED.time_zone,\n recurrence_lines = EXCLUDED.recurrence_lines,\n organizer_email = EXCLUDED.organizer_email,\n organizer_name = EXCLUDED.organizer_name,\n creator_email = EXCLUDED.creator_email,\n creator_name = EXCLUDED.creator_name,\n conference_url = EXCLUDED.conference_url,\n conference_provider = EXCLUDED.conference_provider,\n sequence = EXCLUDED.sequence,\n is_read_only = EXCLUDED.is_read_only,\n canonical_source_kind = EXCLUDED.canonical_source_kind,\n canonical_source_updated_at = EXCLUDED.canonical_source_updated_at,\n reminders_use_default = EXCLUDED.reminders_use_default,\n reminder_overrides = EXCLUDED.reminder_overrides,\n updated_at = GREATEST(calendar_events.updated_at, EXCLUDED.updated_at)\n WHERE\n EXCLUDED.sequence > calendar_events.sequence\n OR (\n EXCLUDED.sequence = calendar_events.sequence\n AND EXCLUDED.canonical_source_updated_at\n >= calendar_events.canonical_source_updated_at\n )\n -- `xmax = 0` distinguishes the INSERT from the DO UPDATE: a\n -- freshly inserted row carries no updating transaction id.\n RETURNING id, (xmax = 0) AS \"inserted!\"\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 1,
+ "name": "inserted!",
+ "type_info": "Bool"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid",
+ "Text",
+ "Uuid",
+ "Text",
+ "Text",
+ "Text",
+ "Text",
+ "Text",
+ "Text",
+ "Text",
+ "Timestamptz",
+ "Timestamptz",
+ "Date",
+ "Date",
+ "Text",
+ "TextArray",
+ "Text",
+ "Text",
+ "Text",
+ "Int4",
+ "Bool",
+ "Text",
+ "Timestamptz",
+ "Timestamptz",
+ "Bool",
+ "Jsonb",
+ "Text",
+ "Text",
+ "Text"
+ ]
+ },
+ "nullable": [
+ false,
+ null
+ ]
+ },
+ "hash": "038479edc9ca5b5ec65f8729b77ee3ae466d779973a064b09da232a6fe66836b"
+}
diff --git a/.sqlx/query-09567c7fdbca8c652db4d0037a498bf203a27e6d08737a809ae77efc4dd76680.json b/.sqlx/query-09567c7fdbca8c652db4d0037a498bf203a27e6d08737a809ae77efc4dd76680.json
deleted file mode 100644
index d731c73ce0..0000000000
--- a/.sqlx/query-09567c7fdbca8c652db4d0037a498bf203a27e6d08737a809ae77efc4dd76680.json
+++ /dev/null
@@ -1,54 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n INSERT INTO calendar_events (\n id, owner_id, source_link_id, ical_uid, title, description, location,\n status, visibility, transparency,\n starts_at, ends_at, start_date, end_date, time_zone,\n recurrence_lines, organizer_email, organizer_name,\n conference_url, conference_provider, sequence, is_read_only,\n canonical_source_kind,\n canonical_source_updated_at,\n reminders_use_default, reminder_overrides,\n created_at, updated_at\n )\n VALUES (\n $1, $2, $3, $4, $5, $6, $7,\n $8, $9, $10,\n $11, $12, $13, $14, $15,\n $16, $17, $18,\n $19, $27, $20, $21, $22, $24,\n $25, $26,\n $23, $24\n )\n ON CONFLICT (owner_id, source_link_id, ical_uid) DO UPDATE SET\n title = EXCLUDED.title,\n description = EXCLUDED.description,\n location = EXCLUDED.location,\n status = EXCLUDED.status,\n visibility = EXCLUDED.visibility,\n transparency = EXCLUDED.transparency,\n starts_at = EXCLUDED.starts_at,\n ends_at = EXCLUDED.ends_at,\n start_date = EXCLUDED.start_date,\n end_date = EXCLUDED.end_date,\n time_zone = EXCLUDED.time_zone,\n recurrence_lines = EXCLUDED.recurrence_lines,\n organizer_email = EXCLUDED.organizer_email,\n organizer_name = EXCLUDED.organizer_name,\n conference_url = EXCLUDED.conference_url,\n conference_provider = EXCLUDED.conference_provider,\n sequence = EXCLUDED.sequence,\n is_read_only = EXCLUDED.is_read_only,\n canonical_source_kind = EXCLUDED.canonical_source_kind,\n canonical_source_updated_at = EXCLUDED.canonical_source_updated_at,\n reminders_use_default = EXCLUDED.reminders_use_default,\n reminder_overrides = EXCLUDED.reminder_overrides,\n updated_at = GREATEST(calendar_events.updated_at, EXCLUDED.updated_at)\n WHERE\n EXCLUDED.sequence > calendar_events.sequence\n OR (\n EXCLUDED.sequence = calendar_events.sequence\n AND EXCLUDED.canonical_source_updated_at\n >= calendar_events.canonical_source_updated_at\n )\n -- `xmax = 0` distinguishes the INSERT from the DO UPDATE: a\n -- freshly inserted row carries no updating transaction id.\n RETURNING id, (xmax = 0) AS \"inserted!\"\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "id",
- "type_info": "Uuid"
- },
- {
- "ordinal": 1,
- "name": "inserted!",
- "type_info": "Bool"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid",
- "Text",
- "Uuid",
- "Text",
- "Text",
- "Text",
- "Text",
- "Text",
- "Text",
- "Text",
- "Timestamptz",
- "Timestamptz",
- "Date",
- "Date",
- "Text",
- "TextArray",
- "Text",
- "Text",
- "Text",
- "Int4",
- "Bool",
- "Text",
- "Timestamptz",
- "Timestamptz",
- "Bool",
- "Jsonb",
- "Text"
- ]
- },
- "nullable": [
- false,
- null
- ]
- },
- "hash": "09567c7fdbca8c652db4d0037a498bf203a27e6d08737a809ae77efc4dd76680"
-}
diff --git a/.sqlx/query-d128007b3e2cc1c2b89192f2cae967d43a6eb09fb2869d72e6183c88ff9e6bb8.json b/.sqlx/query-15cfd7c3ad14cb61788715f1890abdc06fe849aabd304ceb86f87562daf3f0e0.json
similarity index 61%
rename from .sqlx/query-d128007b3e2cc1c2b89192f2cae967d43a6eb09fb2869d72e6183c88ff9e6bb8.json
rename to .sqlx/query-15cfd7c3ad14cb61788715f1890abdc06fe849aabd304ceb86f87562daf3f0e0.json
index 5b8c906af4..74b8af6279 100644
--- a/.sqlx/query-d128007b3e2cc1c2b89192f2cae967d43a6eb09fb2869d72e6183c88ff9e6bb8.json
+++ b/.sqlx/query-15cfd7c3ad14cb61788715f1890abdc06fe849aabd304ceb86f87562daf3f0e0.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n UPDATE calendar_events\n SET title = $2,\n description = $3,\n location = $4,\n status = $5,\n visibility = $6,\n transparency = $7,\n starts_at = $8,\n ends_at = $9,\n start_date = $10,\n end_date = $11,\n time_zone = $12,\n recurrence_lines = $13,\n organizer_email = $14,\n organizer_name = $15,\n conference_url = $16,\n conference_provider = $25,\n sequence = $17,\n is_read_only = $18,\n canonical_source_kind = $19,\n canonical_source_updated_at = $20,\n reminders_use_default = $23,\n reminder_overrides = $24,\n created_at = $21,\n updated_at = GREATEST(calendar_events.updated_at, $22)\n WHERE id = $1\n ",
+ "query": "\n UPDATE calendar_events\n SET title = $2,\n description = $3,\n location = $4,\n status = $5,\n visibility = $6,\n transparency = $7,\n starts_at = $8,\n ends_at = $9,\n start_date = $10,\n end_date = $11,\n time_zone = $12,\n recurrence_lines = $13,\n organizer_email = $14,\n organizer_name = $15,\n creator_email = $26,\n creator_name = $27,\n conference_url = $16,\n conference_provider = $25,\n sequence = $17,\n is_read_only = $18,\n canonical_source_kind = $19,\n canonical_source_updated_at = $20,\n reminders_use_default = $23,\n reminder_overrides = $24,\n created_at = $21,\n updated_at = GREATEST(calendar_events.updated_at, $22)\n WHERE id = $1\n ",
"describe": {
"columns": [],
"parameters": {
@@ -29,10 +29,12 @@
"Timestamptz",
"Bool",
"Jsonb",
+ "Text",
+ "Text",
"Text"
]
},
"nullable": []
},
- "hash": "d128007b3e2cc1c2b89192f2cae967d43a6eb09fb2869d72e6183c88ff9e6bb8"
+ "hash": "15cfd7c3ad14cb61788715f1890abdc06fe849aabd304ceb86f87562daf3f0e0"
}
diff --git a/.sqlx/query-171fc2fe17cc55e036915fe8c0a2abe554f5e39f6eab2c75226ec9d6f96eec91.json b/.sqlx/query-6ebdeb1436de55d328923dd8f9359641122d1786f3ad15a48643238d3c838c03.json
similarity index 62%
rename from .sqlx/query-171fc2fe17cc55e036915fe8c0a2abe554f5e39f6eab2c75226ec9d6f96eec91.json
rename to .sqlx/query-6ebdeb1436de55d328923dd8f9359641122d1786f3ad15a48643238d3c838c03.json
index a4e17c1ef5..fc7bed20e1 100644
--- a/.sqlx/query-171fc2fe17cc55e036915fe8c0a2abe554f5e39f6eab2c75226ec9d6f96eec91.json
+++ b/.sqlx/query-6ebdeb1436de55d328923dd8f9359641122d1786f3ad15a48643238d3c838c03.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT\n occurrence.event_id,\n canonical_source.calendar_id AS \"canonical_calendar_id?\",\n occurrence.occurrence_key,\n occurrence.recurrence_id,\n occurrence.starts_at AS occurrence_starts_at,\n occurrence.ends_at AS occurrence_ends_at,\n occurrence.start_date AS occurrence_start_date,\n occurrence.end_date AS occurrence_end_date,\n occurrence.is_cancelled,\n event.owner_id,\n event.ical_uid,\n event.title,\n event.description,\n event.location,\n event.status,\n event.visibility,\n event.transparency,\n event.starts_at,\n event.ends_at,\n event.start_date,\n event.end_date,\n event.time_zone,\n event.recurrence_lines,\n event.organizer_email,\n event.organizer_name,\n event.conference_url,\n event.conference_provider,\n event.sequence,\n event.is_read_only,\n event.reminders_use_default,\n event.reminder_overrides,\n event.created_at,\n event.updated_at\n FROM calendar_event_occurrences occurrence\n JOIN calendar_events event ON event.id = occurrence.event_id\n LEFT JOIN LATERAL (\n SELECT source.calendar_id\n FROM calendar_event_sources source\n JOIN calendars calendar ON calendar.id = source.calendar_id\n JOIN calendar_accounts account ON account.id = source.account_id\n WHERE source.event_id = event.id\n AND NOT calendar.is_deleted\n AND account.sync_status <> 'disabled'\n ORDER BY\n source.source_sequence DESC,\n source.source_updated_at DESC,\n source.last_seen_at DESC,\n source.id DESC\n LIMIT 1\n ) canonical_source ON true\n WHERE occurrence.owner_id IN (\n SELECT $1::text\n UNION\n SELECT link.child_macro_id\n FROM macro_user_links link\n WHERE link.primary_macro_id = $1\n )\n AND event.status <> 'cancelled'\n AND NOT occurrence.is_cancelled\n AND (\n event.owner_id = $1\n OR EXISTS (\n SELECT 1\n FROM macro_user_links link\n WHERE link.link_id = event.source_link_id\n AND link.primary_macro_id = $1\n )\n )\n AND (\n occurrence.timed_span && tstzrange($2, $3, '[)')\n OR occurrence.day_span && daterange($4, $5, '[)')\n )\n AND (\n $6::timestamptz IS NULL\n OR (\n COALESCE(\n occurrence.starts_at,\n occurrence.start_date::timestamp AT TIME ZONE 'UTC'\n ),\n occurrence.event_id,\n occurrence.occurrence_key\n ) > ($6, $7, $8)\n )\n ORDER BY\n COALESCE(occurrence.starts_at, occurrence.start_date::timestamp AT TIME ZONE 'UTC'),\n occurrence.event_id,\n occurrence.occurrence_key\n LIMIT $9\n ",
+ "query": "\n SELECT\n occurrence.event_id,\n canonical_source.calendar_id AS \"canonical_calendar_id?\",\n occurrence.occurrence_key,\n occurrence.recurrence_id,\n occurrence.starts_at AS occurrence_starts_at,\n occurrence.ends_at AS occurrence_ends_at,\n occurrence.start_date AS occurrence_start_date,\n occurrence.end_date AS occurrence_end_date,\n occurrence.is_cancelled,\n event.owner_id,\n event.ical_uid,\n event.title,\n event.description,\n event.location,\n event.status,\n event.visibility,\n event.transparency,\n event.starts_at,\n event.ends_at,\n event.start_date,\n event.end_date,\n event.time_zone,\n event.recurrence_lines,\n event.organizer_email,\n event.organizer_name,\n event.creator_email,\n event.creator_name,\n event.conference_url,\n event.conference_provider,\n event.sequence,\n event.is_read_only,\n event.reminders_use_default,\n event.reminder_overrides,\n event.created_at,\n event.updated_at\n FROM calendar_event_occurrences occurrence\n JOIN calendar_events event ON event.id = occurrence.event_id\n LEFT JOIN LATERAL (\n SELECT source.calendar_id\n FROM calendar_event_sources source\n JOIN calendars calendar ON calendar.id = source.calendar_id\n JOIN calendar_accounts account ON account.id = source.account_id\n WHERE source.event_id = event.id\n AND NOT calendar.is_deleted\n AND account.sync_status <> 'disabled'\n ORDER BY\n source.source_sequence DESC,\n source.source_updated_at DESC,\n source.last_seen_at DESC,\n source.id DESC\n LIMIT 1\n ) canonical_source ON true\n WHERE occurrence.owner_id IN (\n SELECT $1::text\n UNION\n SELECT link.child_macro_id\n FROM macro_user_links link\n WHERE link.primary_macro_id = $1\n )\n AND event.status <> 'cancelled'\n AND NOT occurrence.is_cancelled\n AND (\n event.owner_id = $1\n OR EXISTS (\n SELECT 1\n FROM macro_user_links link\n WHERE link.link_id = event.source_link_id\n AND link.primary_macro_id = $1\n )\n )\n AND (\n occurrence.timed_span && tstzrange($2, $3, '[)')\n OR occurrence.day_span && daterange($4, $5, '[)')\n )\n AND (\n $6::timestamptz IS NULL\n OR (\n COALESCE(\n occurrence.starts_at,\n occurrence.start_date::timestamp AT TIME ZONE 'UTC'\n ),\n occurrence.event_id,\n occurrence.occurrence_key\n ) > ($6, $7, $8)\n )\n ORDER BY\n COALESCE(occurrence.starts_at, occurrence.start_date::timestamp AT TIME ZONE 'UTC'),\n occurrence.event_id,\n occurrence.occurrence_key\n LIMIT $9\n ",
"describe": {
"columns": [
{
@@ -130,41 +130,51 @@
},
{
"ordinal": 25,
- "name": "conference_url",
+ "name": "creator_email",
"type_info": "Text"
},
{
"ordinal": 26,
- "name": "conference_provider",
+ "name": "creator_name",
"type_info": "Text"
},
{
"ordinal": 27,
+ "name": "conference_url",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 28,
+ "name": "conference_provider",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 29,
"name": "sequence",
"type_info": "Int4"
},
{
- "ordinal": 28,
+ "ordinal": 30,
"name": "is_read_only",
"type_info": "Bool"
},
{
- "ordinal": 29,
+ "ordinal": 31,
"name": "reminders_use_default",
"type_info": "Bool"
},
{
- "ordinal": 30,
+ "ordinal": 32,
"name": "reminder_overrides",
"type_info": "Jsonb"
},
{
- "ordinal": 31,
+ "ordinal": 33,
"name": "created_at",
"type_info": "Timestamptz"
},
{
- "ordinal": 32,
+ "ordinal": 34,
"name": "updated_at",
"type_info": "Timestamptz"
}
@@ -210,6 +220,8 @@
true,
true,
true,
+ true,
+ true,
false,
false,
false,
@@ -218,5 +230,5 @@
false
]
},
- "hash": "171fc2fe17cc55e036915fe8c0a2abe554f5e39f6eab2c75226ec9d6f96eec91"
+ "hash": "6ebdeb1436de55d328923dd8f9359641122d1786f3ad15a48643238d3c838c03"
}
diff --git a/apps/web/src/features/calendar/components/EventDetails.tsx b/apps/web/src/features/calendar/components/EventDetails.tsx
index a8a71f7d85..3e599e1e2f 100644
--- a/apps/web/src/features/calendar/components/EventDetails.tsx
+++ b/apps/web/src/features/calendar/components/EventDetails.tsx
@@ -10,6 +10,7 @@ import { openExternalUrl } from '@core/util/url';
import { Collapsible } from '@kobalte/core/collapsible';
import ArrowSquareOutIcon from '@phosphor/arrow-square-out.svg';
import BellSimpleIcon from '@phosphor/bell-simple.svg';
+import CalendarBlankIcon from '@phosphor/calendar-blank.svg';
import CaretDownIcon from '@phosphor/caret-down.svg';
import CheckIcon from '@phosphor/check.svg';
import GlobeIcon from '@phosphor/globe.svg';
@@ -36,6 +37,10 @@ import {
import { Dynamic } from 'solid-js/web';
import type { CalendarEvent, CalendarTimeFormat } from '../types';
import { isSameLocalDate, parseLocalDate } from '../utils/calendar-date';
+import {
+ type CalendarPerson,
+ eventAttribution,
+} from '../utils/event-attribution';
import {
isPhoneOnlyLocation,
parseEventLocation,
@@ -321,25 +326,6 @@ function safeConferenceUrl(value: string | undefined) {
}
}
-interface CalendarOrganizer {
- displayName?: string;
- email?: string;
- isSelf: boolean;
-}
-
-function findOrganizer(event: CalendarEvent): CalendarOrganizer | undefined {
- const organizerAttendee = event.attendees.find(
- (attendee) => attendee.isOrganizer
- );
- const displayName =
- event.organizerName ?? organizerAttendee?.displayName ?? undefined;
- const email = event.organizerEmail ?? organizerAttendee?.email;
-
- return displayName || email
- ? { displayName, email, isSelf: organizerAttendee?.isSelf ?? false }
- : undefined;
-}
-
/**
* The location row. A phone number written into the location becomes a call
* link, so a dial-in number takes one click instead of being retyped into a
@@ -410,22 +396,51 @@ function EventRemindersItem(props: {
);
}
-function CalendarOrganizerItem(props: { organizer: CalendarOrganizer }) {
+function calendarPersonDisplayName(person: CalendarPerson) {
+ const email = person.email ?? '';
+ const macroId = person.email ? emailToMacroId(person.email) : undefined;
+ const macroName = getDisplayName(macroId).trim();
+ if (isUsableDisplayName(macroName, email)) return macroName;
+
+ const providerName = person.displayName?.trim() ?? '';
+ if (providerName && (!email || isUsableDisplayName(providerName, email))) {
+ return providerName;
+ }
+
+ return email || providerName;
+}
+
+function CalendarSourceItem(props: {
+ calendarName: string;
+ creator?: CalendarPerson;
+}) {
+ const createdBy = () =>
+ props.creator ? calendarPersonDisplayName(props.creator) : undefined;
+
+ return (
+ <div class="contents">
+ <CalendarBlankIcon class="mt-0.5 size-5 text-ink-extra-muted sm:size-4" />
+ <div class="min-w-0">
+ <span class="block select-text truncate text-ink-muted">
+ {props.calendarName}
+ </span>
+ <Show when={createdBy()}>
+ {(name) => (
+ <div class="text-xs text-ink-extra-muted sm:text-xxs">
+ Created by: {name()}
+ </div>
+ )}
+ </Show>
+ </div>
+ </div>
+ );
+}
+
+function CalendarOrganizerItem(props: { organizer: CalendarPerson }) {
const macroId = props.organizer.email
? emailToMacroId(props.organizer.email)
: undefined;
- const displayName = () => {
- const email = props.organizer.email ?? '';
- const macroName = getDisplayName(macroId).trim();
- if (isUsableDisplayName(macroName, email)) return macroName;
-
- const providerName = props.organizer.displayName?.trim() ?? '';
- if (providerName && (!email || isUsableDisplayName(providerName, email))) {
- return providerName;
- }
-
- return email || providerName;
- };
+ const displayName = () => calendarPersonDisplayName(props.organizer);
const iconProps: UserIconProps | undefined = props.organizer.email
? macroId
@@ -480,7 +495,7 @@ export function EventDetails(props: {
props.event.conferenceProvider === 'google_meet'
? 'Join Google Meet'
: 'Join meeting';
- const organizer = createMemo(() => findOrganizer(props.event));
+ const attribution = createMemo(() => eventAttribution(props.event));
const originalTimeZone = createMemo(() =>
formatOriginalTimeZone(props.event, props.timeFormat)
);
@@ -569,7 +584,11 @@ export function EventDetails(props: {
defaultReminders={props.defaultReminders}
/>
- <Show when={organizer()}>
+ <CalendarSourceItem
+ calendarName={attribution().calendarName}
+ creator={attribution().creator}
+ />
+ <Show when={attribution().organizer}>
{(eventOrganizer) => (
<CalendarOrganizerItem organizer={eventOrganizer()} />
)}
diff --git a/apps/web/src/features/calendar/hooks/use-calendar-sources.ts b/apps/web/src/features/calendar/hooks/use-calendar-sources.ts
index d136a72f65..ab87c230a7 100644
--- a/apps/web/src/features/calendar/hooks/use-calendar-sources.ts
+++ b/apps/web/src/features/calendar/hooks/use-calendar-sources.ts
@@ -21,6 +21,8 @@ export function useCalendarSources() {
id: calendar.id,
name: calendarDisplayLabel(calendar, spansInboxes),
color: calendar.color ?? DEFAULT_CALENDAR_SOURCE.color,
+ emailAddress: calendar.emailAddress,
+ isPrimary: calendar.isPrimary,
}));
});
const sourceById = createMemo(
diff --git a/apps/web/src/features/calendar/types.ts b/apps/web/src/features/calendar/types.ts
index 124ace56a8..c0082814a4 100644
--- a/apps/web/src/features/calendar/types.ts
+++ b/apps/web/src/features/calendar/types.ts
@@ -28,6 +28,10 @@ export interface CalendarSource {
name: string;
/** Semantic CSS color used for events from this source. */
color: string;
+ /** Connected inbox address, when the source came from a visible calendar. */
+ emailAddress?: string;
+ /** Whether this source is its connected inbox's primary calendar. */
+ isPrimary?: boolean;
}
/** Calendar occurrence data, independent from FullCalendar. */
@@ -55,6 +59,10 @@ export interface CalendarEvent {
organizerName?: string;
/** Event organizer email address. */
organizerEmail?: string;
+ /** Provider-reported creator display name. */
+ creatorName?: string;
+ /** Provider-reported creator email address. */
+ creatorEmail?: string;
/** Attendees and their RSVP metadata. */
attendees: CalendarAttendee[];
/** Per-user reminder configuration; absent means the calendar default. */
@@ -88,6 +96,10 @@ export const DEFAULT_CALENDAR_SOURCE: CalendarSource = {
color: 'var(--color-accent)',
};
+function optionalText(value: string | null | undefined) {
+ return value ?? undefined;
+}
+
/** Maps one backend occurrence projection into the calendar event model. */
export function mapCalendarOccurrence(
item: CalendarOccurrenceItem,
@@ -115,6 +127,8 @@ export function mapCalendarOccurrence(
undefined,
organizerName: event.organizerName ?? undefined,
organizerEmail: event.organizerEmail ?? undefined,
+ creatorName: optionalText(event.creatorName),
+ creatorEmail: optionalText(event.creatorEmail),
attendees: event.attendees ?? [],
reminders: event.reminders ?? undefined,
calendarId: event.calendarId ?? undefined,
diff --git a/apps/web/src/features/calendar/utils/event-attribution.test.ts b/apps/web/src/features/calendar/utils/event-attribution.test.ts
new file mode 100644
index 0000000000..c5b46224c0
--- /dev/null
+++ b/apps/web/src/features/calendar/utils/event-attribution.test.ts
@@ -0,0 +1,157 @@
+import { describe, expect, it } from 'vitest';
+import type { CalendarEvent } from '../types';
+import { eventAttribution } from './event-attribution';
+
+function event(overrides: Partial<CalendarEvent>): CalendarEvent {
+ return {
+ id: '["event","occurrence"]',
+ eventId: 'event',
+ occurrenceKey: 'occurrence',
+ isCancelled: false,
+ isReadOnly: false,
+ attendees: [],
+ recurrenceLines: [],
+ title: 'd',
+ start: '2026-08-27T19:00:00.000Z',
+ end: '2026-08-27T20:45:00.000Z',
+ allDay: false,
+ calendar: {
+ id: 'jackson-cal',
+ name: 'Jackson Kustec',
+ color: 'orange',
+ emailAddress: '[email protected]',
+ isPrimary: true,
+ },
+ ...overrides,
+ };
+}
+
+describe('eventAttribution', () => {
+ it('shows the calendar and creator when the organizer is the calendar owner', () => {
+ const attribution = eventAttribution(
+ event({
+ organizerName: 'Jackson Kustec',
+ organizerEmail: '[email protected]',
+ creatorName: 'Teo Nys',
+ creatorEmail: '[email protected]',
+ })
+ );
+
+ expect(attribution.calendarName).toBe('Jackson Kustec');
+ expect(attribution.creator).toEqual({
+ displayName: 'Teo Nys',
+ email: '[email protected]',
+ isSelf: false,
+ });
+ expect(attribution.organizer).toBeUndefined();
+ });
+
+ it('does not label the calendar owner as organizer when creator is unknown', () => {
+ const attribution = eventAttribution(
+ event({
+ organizerName: 'Jackson Kustec',
+ organizerEmail: '[email protected]',
+ })
+ );
+
+ expect(attribution.calendarName).toBe('Jackson Kustec');
+ expect(attribution.creator).toBeUndefined();
+ expect(attribution.organizer).toBeUndefined();
+ });
+
+ it('shows a distinct meeting organizer on the viewer calendar', () => {
+ const attribution = eventAttribution(
+ event({
+ calendar: {
+ id: 'teo-cal',
+ color: 'blue',
+ emailAddress: '[email protected]',
+ isPrimary: true,
+ },
+ organizerName: 'Alex Organizer',
+ organizerEmail: '[email protected]',
+ creatorName: 'Alex Organizer',
+ creatorEmail: '[email protected]',
+ })
+ );
+
+ expect(attribution.calendarName).toBe('[email protected]');
+ expect(attribution.creator).toBeUndefined();
+ expect(attribution.organizer).toEqual({
+ displayName: 'Alex Organizer',
+ email: '[email protected]',
+ isSelf: false,
+ });
+ });
+
+ it('hides creator and organizer on the writer’s own calendar', () => {
+ const attribution = eventAttribution(
+ event({
+ calendar: {
+ id: 'teo-cal',
+ color: 'blue',
+ emailAddress: '[email protected]',
+ isPrimary: true,
+ },
+ organizerName: 'Teo Nys',
+ organizerEmail: '[email protected]',
+ creatorName: 'Teo Nys',
+ creatorEmail: '[email protected]',
+ })
+ );
+
+ expect(attribution.calendarName).toBe('[email protected]');
+ expect(attribution.creator).toBeUndefined();
+ expect(attribution.organizer).toBeUndefined();
+ });
+
+ it('does not treat the viewer inbox as the calendar on a shared calendar', () => {
+ const attribution = eventAttribution(
+ event({
+ calendar: {
+ id: 'jackson-cal',
+ name: 'Jackson Kustec',
+ color: 'orange',
+ emailAddress: '[email protected]',
+ isPrimary: false,
+ },
+ organizerName: 'Jackson Kustec',
+ organizerEmail: '[email protected]',
+ creatorName: 'Teo Nys',
+ creatorEmail: '[email protected]',
+ })
+ );
+
+ expect(attribution.calendarName).toBe('Jackson Kustec');
+ expect(attribution.creator).toEqual({
+ displayName: 'Teo Nys',
+ email: '[email protected]',
+ isSelf: false,
+ });
+ expect(attribution.organizer).toBeUndefined();
+ });
+
+ it('matches a multi-inbox calendar label to the calendar owner, not the inbox', () => {
+ const attribution = eventAttribution(
+ event({
+ calendar: {
+ id: 'jackson-cal',
+ name: 'Jackson Kustec — [email protected]',
+ color: 'orange',
+ emailAddress: '[email protected]',
+ isPrimary: false,
+ },
+ organizerName: 'Jackson Kustec',
+ organizerEmail: '[email protected]',
+ creatorName: 'Teo Nys',
+ creatorEmail: '[email protected]',
+ })
+ );
+
+ expect(attribution.calendarName).toBe('Jackson Kustec — [email protected]');
+ expect(attribution.creator?.displayName).toBe('Teo Nys');
+ expect(attribution.organizer).toBeUndefined();
+ });
+});
diff --git a/apps/web/src/features/calendar/utils/event-attribution.ts b/apps/web/src/features/calendar/utils/event-attribution.ts
new file mode 100644
index 0000000000..79f55ab9de
--- /dev/null
+++ b/apps/web/src/features/calendar/utils/event-attribution.ts
@@ -0,0 +1,105 @@
+import type { CalendarEvent, CalendarSource } from '../types';
+
+/** A person attributed on an event: organizer or creator. */
+export interface CalendarPerson {
+ displayName?: string;
+ email?: string;
+ isSelf: boolean;
+}
+
+/** Calendar, creator, and organizer rows for the event details popover. */
+export interface EventAttribution {
+ calendarName: string;
+ creator?: CalendarPerson;
+ organizer?: CalendarPerson;
+}
+
+function normalize(value?: string) {
+ const trimmed = value?.trim();
+ return trimmed === undefined || trimmed === '' ? undefined : trimmed;
+}
+
+function emailsEqual(left?: string, right?: string) {
+ const first = normalize(left)?.toLowerCase();
+ const second = normalize(right)?.toLowerCase();
+ return first !== undefined && first === second;
+}
+
+function namesEqual(left?: string, right?: string) {
+ const first = normalize(left)?.toLowerCase();
+ const second = normalize(right)?.toLowerCase();
+ return first !== undefined && first === second;
+}
+
+function sameAsCalendar(person: CalendarPerson, calendar: CalendarSource) {
+ const personName = normalize(person.displayName);
+ const calendarName = normalize(calendar.name);
+ if (personName && calendarName) {
+ if (namesEqual(personName, calendarName)) return true;
+ if (
+ calendarName.toLowerCase().startsWith(`${personName.toLowerCase()} —`)
+ ) {
+ return true;
+ }
+ }
+
+ if (person.email && emailsEqual(person.email, calendar.name)) {
+ return true;
+ }
+
+ // The connected inbox identifies the calendar only on the account primary.
+ // On a shared calendar it is the viewer's inbox, not the calendar owner —
+ // matching it would hide "Created by" when you write onto someone else's
+ // calendar through your own grant.
+ return (
+ calendar.isPrimary === true &&
+ person.email !== undefined &&
+ emailsEqual(person.email, calendar.emailAddress)
+ );
+}
+
+function findOrganizer(event: CalendarEvent): CalendarPerson | undefined {
+ const organizerAttendee = event.attendees.find(
+ (attendee) => attendee.isOrganizer
+ );
+ const displayName =
+ event.organizerName ?? organizerAttendee?.displayName ?? undefined;
+ const email = event.organizerEmail ?? organizerAttendee?.email;
+
+ return displayName || email
+ ? { displayName, email, isSelf: organizerAttendee?.isSelf ?? false }
+ : undefined;
+}
+
+function findCreator(event: CalendarEvent): CalendarPerson | undefined {
+ const displayName = event.creatorName;
+ const email = event.creatorEmail;
+ if (!displayName && !email) return undefined;
+
+ const attendee = event.attendees.find((candidate) =>
+ emailsEqual(candidate.email, email)
+ );
+ return { displayName, email, isSelf: attendee?.isSelf ?? false };
+}
+
+/**
+ * Splits the calendar the event lives on from who created it and who
+ * organizes it. Google reports the calendar owner as organizer when someone
+ * writes onto a shared calendar; the creator is the writer.
+ */
+export function eventAttribution(event: CalendarEvent): EventAttribution {
+ const organizer = findOrganizer(event);
+ const creator = findCreator(event);
+ const showCreator =
+ creator !== undefined &&
+ !sameAsCalendar(creator, event.calendar) &&
+ (organizer === undefined || sameAsCalendar(organizer, event.calendar));
+ const showOrganizer =
+ organizer !== undefined && !sameAsCalendar(organizer, event.calendar);
+
+ return {
+ calendarName: event.calendar.name || 'Calendar',
+ creator: showCreator ? creator : undefined,
+ organizer: showOrganizer ? organizer : undefined,
+ };
+}
diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEvent.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEvent.ts
index 1bd11a9634..4427b80ddc 100644
--- a/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEvent.ts
+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEvent.ts
@@ -8,6 +8,8 @@ import type { CalendarAttendee } from './calendarAttendee';
import type { CalendarEventCalendarId } from './calendarEventCalendarId';
import type { CalendarEventConferenceProvider } from './calendarEventConferenceProvider';
import type { CalendarEventConferenceUrl } from './calendarEventConferenceUrl';
+import type { CalendarEventCreatorEmail } from './calendarEventCreatorEmail';
+import type { CalendarEventCreatorName } from './calendarEventCreatorName';
import type { CalendarEventDescription } from './calendarEventDescription';
import type { CalendarEventLocation } from './calendarEventLocation';
import type { CalendarEventOrganizerEmail } from './calendarEventOrganizerEmail';
@@ -32,6 +34,13 @@ projections stored before calendars were attributed. */
conferenceUrl?: CalendarEventConferenceUrl;
/** Entity creation time. */
createdAt: string;
+ /** Provider-reported creator email. Distinct from the organizer when
+someone writes onto a calendar they do not own. Omitted from stored
+projections when unknown so events ingested before this field still
+compare equal. */
+ creatorEmail?: CalendarEventCreatorEmail;
+ /** Provider-reported creator display name. */
+ creatorName?: CalendarEventCreatorName;
/** Optional event body. */
description?: CalendarEventDescription;
/** RFC 5545 UID used to reconcile provider and email sources. */
diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventCreatorEmail.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventCreatorEmail.ts
new file mode 100644
index 0000000000..46a8016990
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventCreatorEmail.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * email_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Provider-reported creator email. Distinct from the organizer when
+someone writes onto a calendar they do not own. Omitted from stored
+projections when unknown so events ingested before this field still
+compare equal.
+ */
+export type CalendarEventCreatorEmail = string | null;
diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventCreatorName.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventCreatorName.ts
new file mode 100644
index 0000000000..86b6dc680a
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/calendarEventCreatorName.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * email_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Provider-reported creator display name.
+ */
+export type CalendarEventCreatorName = string | null;
diff --git a/apps/web/src/lib/service-clients/service-email/generated/schemas/index.ts b/apps/web/src/lib/service-clients/service-email/generated/schemas/index.ts
index 5eba1c5c0e..acf77c3c15 100644
--- a/apps/web/src/lib/service-clients/service-email/generated/schemas/index.ts
+++ b/apps/web/src/lib/service-clients/service-email/generated/schemas/index.ts
@@ -152,6 +152,8 @@ export * from './calendarEvent';
export * from './calendarEventCalendarId';
export * from './calendarEventConferenceProvider';
export * from './calendarEventConferenceUrl';
+export * from './calendarEventCreatorEmail';
+export * from './calendarEventCreatorName';
export * from './calendarEventDescription';
export * from './calendarEventLocation';
export * from './calendarEventOrganizerEmail';
diff --git a/apps/web/src/lib/service-clients/service-email/openapi.json b/apps/web/src/lib/service-clients/service-email/openapi.json
index fb9ed1df53..7d6f24d400 100644
--- a/apps/web/src/lib/service-clients/service-email/openapi.json
+++ b/apps/web/src/lib/service-clients/service-email/openapi.json
@@ -4555,6 +4555,14 @@
"format": "date-time",
"description": "Entity creation time."
},
+ "creatorEmail": {
+ "type": ["string", "null"],
+ "description": "Provider-reported creator email. Distinct from the organizer when\nsomeone writes onto a calendar they do not own. Omitted from stored\nprojections when unknown so events ingested before this field still\ncompare equal."
+ },
+ "creatorName": {
+ "type": ["string", "null"],
+ "description": "Provider-reported creator display name."
+ },
"description": {
"type": ["string", "null"],
"description": "Optional event body."
diff --git a/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEvent.ts b/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEvent.ts
index fd2b60a5bf..23a8cef454 100644
--- a/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEvent.ts
+++ b/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEvent.ts
@@ -8,6 +8,8 @@ import type { CalendarAttendee } from './calendarAttendee';
import type { CalendarEventCalendarId } from './calendarEventCalendarId';
import type { CalendarEventConferenceProvider } from './calendarEventConferenceProvider';
import type { CalendarEventConferenceUrl } from './calendarEventConferenceUrl';
+import type { CalendarEventCreatorEmail } from './calendarEventCreatorEmail';
+import type { CalendarEventCreatorName } from './calendarEventCreatorName';
import type { CalendarEventDescription } from './calendarEventDescription';
import type { CalendarEventLocation } from './calendarEventLocation';
import type { CalendarEventOrganizerEmail } from './calendarEventOrganizerEmail';
@@ -32,6 +34,13 @@ projections stored before calendars were attributed. */
conferenceUrl?: CalendarEventConferenceUrl;
/** Entity creation time. */
createdAt: string;
+ /** Provider-reported creator email. Distinct from the organizer when
+someone writes onto a calendar they do not own. Omitted from stored
+projections when unknown so events ingested before this field still
+compare equal. */
+ creatorEmail?: CalendarEventCreatorEmail;
+ /** Provider-reported creator display name. */
+ creatorName?: CalendarEventCreatorName;
/** Optional event body. */
description?: CalendarEventDescription;
/** RFC 5545 UID used to reconcile provider and email sources. */
diff --git a/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventCreatorEmail.ts b/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventCreatorEmail.ts
new file mode 100644
index 0000000000..e471be81c7
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventCreatorEmail.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Provider-reported creator email. Distinct from the organizer when
+someone writes onto a calendar they do not own. Omitted from stored
+projections when unknown so events ingested before this field still
+compare equal.
+ */
+export type CalendarEventCreatorEmail = string | null;
diff --git a/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventCreatorName.ts b/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventCreatorName.ts
new file mode 100644
index 0000000000..6c3e830dd7
--- /dev/null
+++ b/apps/web/src/lib/service-clients/service-storage/generated/schemas/calendarEventCreatorName.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Provider-reported creator display name.
+ */
+export type CalendarEventCreatorName = string | null;
diff --git a/apps/web/src/lib/service-clients/service-storage/generated/schemas/index.ts b/apps/web/src/lib/service-clients/service-storage/generated/schemas/index.ts
index b11d65782e..99fec350c0 100644
--- a/apps/web/src/lib/service-clients/service-storage/generated/schemas/index.ts
+++ b/apps/web/src/lib/service-clients/service-storage/generated/schemas/index.ts
@@ -170,6 +170,8 @@ export * from './calendarEvent';
export * from './calendarEventCalendarId';
export * from './calendarEventConferenceProvider';
export * from './calendarEventConferenceUrl';
+export * from './calendarEventCreatorEmail';
+export * from './calendarEventCreatorName';
export * from './calendarEventDescription';
export * from './calendarEventFilters';
export * from './calendarEventFiltersEndsAfter';
diff --git a/apps/web/src/lib/service-clients/service-storage/generated/zod.ts b/apps/web/src/lib/service-clients/service-storage/generated/zod.ts
index f5b4daacd0..4cf7e634f6 100644
--- a/apps/web/src/lib/service-clients/service-storage/generated/zod.ts
+++ b/apps/web/src/lib/service-clients/service-storage/generated/zod.ts
@@ -841,6 +841,16 @@ export const listOccurrencesResponse = zod
.nullish()
.describe('Direct join URL when known.'),
createdAt: zod.iso.datetime({}).describe('Entity creation time.'),
+ creatorEmail: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Provider-reported creator email. Distinct from the organizer when\nsomeone writes onto a calendar they do not own. Omitted from stored\nprojections when unknown so events ingested before this field still\ncompare equal.'
+ ),
+ creatorName: zod
+ .string()
+ .nullish()
+ .describe('Provider-reported creator display name.'),
description: zod
.string()
.nullish()
diff --git a/apps/web/src/lib/service-clients/service-storage/openapi.json b/apps/web/src/lib/service-clients/service-storage/openapi.json
index 517ea9743b..949d900e0b 100644
--- a/apps/web/src/lib/service-clients/service-storage/openapi.json
+++ b/apps/web/src/lib/service-clients/service-storage/openapi.json
@@ -13331,6 +13331,14 @@
"format": "date-time",
"description": "Entity creation time."
},
+ "creatorEmail": {
+ "type": ["string", "null"],
+ "description": "Provider-reported creator email. Distinct from the organizer when\nsomeone writes onto a calendar they do not own. Omitted from stored\nprojections when unknown so events ingested before this field still\ncompare equal."
+ },
+ "creatorName": {
+ "type": ["string", "null"],
+ "description": "Provider-reported creator display name."
+ },
"description": {
"type": ["string", "null"],
"description": "Optional event body."
diff --git a/crates/calendar_events/src/domain/models.rs b/crates/calendar_events/src/domain/models.rs
index 9c2051c19c..e225fa3a41 100644
--- a/crates/calendar_events/src/domain/models.rs
+++ b/crates/calendar_events/src/domain/models.rs
@@ -470,6 +470,15 @@ pub struct CalendarEvent {
pub organizer_email: Option<String>,
/// Organizer display name.
pub organizer_name: Option<String>,
+ /// Provider-reported creator email. Distinct from the organizer when
+ /// someone writes onto a calendar they do not own. Omitted from stored
+ /// projections when unknown so events ingested before this field still
+ /// compare equal.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub creator_email: Option<String>,
+ /// Provider-reported creator display name.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub creator_name: Option<String>,
/// Direct join URL when known.
pub conference_url: Option<String>,
/// Which conferencing system backs `conference_url`. `None` whenever no
diff --git a/crates/calendar_events/src/domain/models/test.rs b/crates/calendar_events/src/domain/models/test.rs
index 7f7126a442..9fe155dc4f 100644
--- a/crates/calendar_events/src/domain/models/test.rs
+++ b/crates/calendar_events/src/domain/models/test.rs
@@ -162,6 +162,8 @@ fn default_reminders_stay_out_of_serialized_projections() {
recurrence_lines: Vec::new(),
organizer_email: None,
organizer_name: None,
+ creator_email: None,
+ creator_name: None,
conference_url: None,
conference_provider: None,
sequence: 0,
@@ -174,9 +176,12 @@ fn default_reminders_stay_out_of_serialized_projections() {
// Projections stored before reminders were modeled have no `reminders`
// key. Serializing the default as nothing keeps them comparing equal to
- // fresh normalizations, so full snapshots stay no-ops.
+ // fresh normalizations, so full snapshots stay no-ops. The same holds
+ // for creator fields added later.
let serialized = serde_json::to_value(&event).unwrap();
assert!(serialized.get("reminders").is_none());
+ assert!(serialized.get("creatorEmail").is_none());
+ assert!(serialized.get("creatorName").is_none());
let legacy: CalendarEvent = serde_json::from_value(serialized).unwrap();
assert_eq!(legacy.reminders, EventReminders::default());
diff --git a/crates/calendar_events/src/domain/mutations/test.rs b/crates/calendar_events/src/domain/mutations/test.rs
index d59c51aa37..5ecdf01655 100644
--- a/crates/calendar_events/src/domain/mutations/test.rs
+++ b/crates/calendar_events/src/domain/mutations/test.rs
@@ -87,6 +87,8 @@ fn echo_upsert(target_owner: &str) -> CalendarEventUpsert {
recurrence_lines: Vec::new(),
organizer_email: None,
organizer_name: None,
+ creator_email: None,
+ creator_name: None,
conference_url: None,
conference_provider: None,
sequence: 0,
diff --git a/crates/calendar_events/src/domain/service/test.rs b/crates/calendar_events/src/domain/service/test.rs
index 7b54341f13..1b7c5e7d4d 100644
--- a/crates/calendar_events/src/domain/service/test.rs
+++ b/crates/calendar_events/src/domain/service/test.rs
@@ -214,6 +214,8 @@ fn valid_upsert() -> CalendarEventUpsert {
recurrence_lines: Vec::new(),
organizer_email: None,
organizer_name: None,
+ creator_email: None,
+ creator_name: None,
conference_url: None,
conference_provider: None,
sequence: 0,
diff --git a/crates/calendar_events/src/inbound/toolset/test.rs b/crates/calendar_events/src/inbound/toolset/test.rs
index 0504cf3277..343463fd4b 100644
--- a/crates/calendar_events/src/inbound/toolset/test.rs
+++ b/crates/calendar_events/src/inbound/toolset/test.rs
@@ -89,6 +89,8 @@ fn sample_event(recurrence_lines: Vec<String>) -> crate::domain::models::Calenda
recurrence_lines,
organizer_email: Some("[email protected]".to_string()),
organizer_name: None,
+ creator_email: None,
+ creator_name: None,
conference_url: Some("https://meet.google.com/abc".to_string()),
conference_provider: Some(crate::domain::models::ConferenceProvider::GoogleMeet),
sequence: 0,
diff --git a/crates/calendar_events/src/outbound/google.rs b/crates/calendar_events/src/outbound/google.rs
index 468dc95d30..061baaa549 100644
--- a/crates/calendar_events/src/outbound/google.rs
+++ b/crates/calendar_events/src/outbound/google.rs
@@ -1782,6 +1782,14 @@ fn map_upsert(
.organizer
.as_ref()
.and_then(|value| value.display_name.clone()),
+ creator_email: master
+ .creator
+ .as_ref()
+ .and_then(|value| value.email.clone()),
+ creator_name: master
+ .creator
+ .as_ref()
+ .and_then(|value| value.display_name.clone()),
conference_provider: conference_provider(
master.conference_data.as_ref(),
join_url.is_some(),
@@ -2135,6 +2143,8 @@ struct GoogleEvent {
recurring_event_id: Option<String>,
original_start_time: Option<GoogleEventDateTime>,
organizer: Option<GooglePerson>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ creator: Option<GooglePerson>,
#[serde(default)]
attendees: Option<Vec<GoogleAttendee>>,
hangout_link: Option<String>,
diff --git a/crates/calendar_events/src/outbound/google/test.rs b/crates/calendar_events/src/outbound/google/test.rs
index 3dba9fdc49..2ef151fe04 100644
--- a/crates/calendar_events/src/outbound/google/test.rs
+++ b/crates/calendar_events/src/outbound/google/test.rs
@@ -37,6 +37,57 @@ fn calendar_access_role_is_reflected_on_mapped_events() {
assert!(upsert.event.is_read_only);
}
+#[test]
+fn creator_is_mapped_separately_from_the_organizer() {
+ let master: GoogleEvent = serde_json::from_value(serde_json::json!({
+ "id": "provider-event",
+ "iCalUID": "[email protected]",
+ "summary": "On someone else's calendar",
+ "start": {"dateTime": "2026-08-27T19:00:00Z", "timeZone": "UTC"},
+ "end": {"dateTime": "2026-08-27T20:45:00Z", "timeZone": "UTC"},
+ "organizer": {"email": "[email protected]", "displayName": "Jackson Kustec"},
+ "creator": {"email": "[email protected]", "displayName": "Teo Nys"},
+ "created": "2026-08-27T01:00:00Z",
+ "updated": "2026-08-27T01:00:00Z"
+ }))
+ .unwrap();
+ let range = OccurrenceRange {
+ starts_at: DateTime::parse_from_rfc3339("2026-08-01T00:00:00Z")
+ .unwrap()
+ .with_timezone(&Utc),
+ ends_at: DateTime::parse_from_rfc3339("2026-09-01T00:00:00Z")
+ .unwrap()
+ .with_timezone(&Utc),
+ start_date: NaiveDate::from_ymd_opt(2026, 8, 1).unwrap(),
+ end_date: NaiveDate::from_ymd_opt(2026, 9, 1).unwrap(),
+ };
+ let target = GoogleCalendarTarget {
+ owner_id: "macro|[email protected]".to_string(),
+ email_link_id: Uuid::now_v7(),
+ account_id: Uuid::now_v7(),
+ calendar_id: Uuid::now_v7(),
+ provider_calendar_id: "primary".to_string(),
+ is_read_only: false,
+ range,
+ };
+
+ let upsert = map_upsert(&target, master, Vec::new(), Vec::new()).unwrap();
+
+ assert_eq!(
+ upsert.event.organizer_email.as_deref(),
+ );
+ assert_eq!(
+ upsert.event.organizer_name.as_deref(),
+ Some("Jackson Kustec")
+ );
+ assert_eq!(
+ upsert.event.creator_email.as_deref(),
+ );
+ assert_eq!(upsert.event.creator_name.as_deref(), Some("Teo Nys"));
+}
+
#[test]
fn malformed_recurring_instance_does_not_overstate_snapshot_coverage() {
let master: GoogleEvent = serde_json::from_value(serde_json::json!({
diff --git a/crates/calendar_events/src/outbound/pg.rs b/crates/calendar_events/src/outbound/pg.rs
index 6a26e319b6..3ee308537a 100644
--- a/crates/calendar_events/src/outbound/pg.rs
+++ b/crates/calendar_events/src/outbound/pg.rs
@@ -299,6 +299,8 @@ struct OccurrenceJoinRow {
recurrence_lines: Vec<String>,
organizer_email: Option<String>,
organizer_name: Option<String>,
+ creator_email: Option<String>,
+ creator_name: Option<String>,
conference_url: Option<String>,
conference_provider: Option<String>,
sequence: i32,
@@ -712,6 +714,7 @@ impl CalendarRepository for PgCalendarRepository {
status, visibility, transparency,
starts_at, ends_at, start_date, end_date, time_zone,
recurrence_lines, organizer_email, organizer_name,
+ creator_email, creator_name,
conference_url, conference_provider, sequence, is_read_only,
canonical_source_kind,
canonical_source_updated_at,
@@ -723,6 +726,7 @@ impl CalendarRepository for PgCalendarRepository {
$8, $9, $10,
$11, $12, $13, $14, $15,
$16, $17, $18,
+ $28, $29,
$19, $27, $20, $21, $22, $24,
$25, $26,
$23, $24
@@ -742,6 +746,8 @@ impl CalendarRepository for PgCalendarRepository {
recurrence_lines = EXCLUDED.recurrence_lines,
organizer_email = EXCLUDED.organizer_email,
organizer_name = EXCLUDED.organizer_name,
+ creator_email = EXCLUDED.creator_email,
+ creator_name = EXCLUDED.creator_name,
conference_url = EXCLUDED.conference_url,
conference_provider = EXCLUDED.conference_provider,
sequence = EXCLUDED.sequence,
@@ -792,6 +798,8 @@ impl CalendarRepository for PgCalendarRepository {
.event
.conference_provider
.map(ConferenceProvider::as_str),
+ upsert.event.creator_email.as_deref(),
+ upsert.event.creator_name.as_deref(),
)
.fetch_optional(&mut *tx)
.await
@@ -897,6 +905,8 @@ impl CalendarRepository for PgCalendarRepository {
event.recurrence_lines,
event.organizer_email,
event.organizer_name,
+ event.creator_email,
+ event.creator_name,
event.conference_url,
event.conference_provider,
event.sequence,
@@ -2617,6 +2627,8 @@ async fn restore_best_source_or_delete(
recurrence_lines = $13,
organizer_email = $14,
organizer_name = $15,
+ creator_email = $26,
+ creator_name = $27,
conference_url = $16,
conference_provider = $25,
sequence = $17,
@@ -2657,6 +2669,8 @@ async fn restore_best_source_or_delete(
.event
.conference_provider
.map(ConferenceProvider::as_str),
+ projection.event.creator_email.as_deref(),
+ projection.event.creator_name.as_deref(),
)
.execute(&mut **tx)
.await
@@ -3293,6 +3307,8 @@ fn event_from_join(
recurrence_lines: row.recurrence_lines,
organizer_email: row.organizer_email,
organizer_name: row.organizer_name,
+ creator_email: row.creator_email,
+ creator_name: row.creator_name,
conference_url: row.conference_url,
conference_provider: row.conference_provider.as_deref().map(conference_provider),
sequence: u32::try_from(row.sequence).unwrap_or_default(),
diff --git a/crates/calendar_events/src/outbound/pg/test.rs b/crates/calendar_events/src/outbound/pg/test.rs
index 26803cf6b0..345ad3d14d 100644
--- a/crates/calendar_events/src/outbound/pg/test.rs
+++ b/crates/calendar_events/src/outbound/pg/test.rs
@@ -139,6 +139,8 @@ fn timed_upsert(
recurrence_lines: vec!["RRULE:FREQ=DAILY;COUNT=2".to_string()],
organizer_email: Some("[email protected]".to_string()),
organizer_name: Some("Organizer".to_string()),
+ creator_email: Some("[email protected]".to_string()),
+ creator_name: Some("Creator".to_string()),
conference_url: None,
conference_provider: None,
sequence,
@@ -1203,6 +1205,10 @@ async fn occurrence_range_uses_overlap_indexes_and_preserves_attendees(pool: PgP
assert_eq!(result.len(), 2);
assert!(result.iter().all(|(event, _)| event.attendees.len() == 1));
+ assert!(result.iter().all(|(event, _)| {
+ event.creator_email.as_deref() == Some("[email protected]")
+ && event.creator_name.as_deref() == Some("Creator")
+ }));
}
/// A Google out-of-office auto-decline records the decline on the exception
@@ -2610,6 +2616,8 @@ fn reminder_upsert(
recurrence_lines: Vec::new(),
organizer_email: None,
organizer_name: None,
+ creator_email: None,
+ creator_name: None,
conference_url: None,
conference_provider: None,
sequence: 0,
diff --git a/crates/macro_db_client/migrations/20260827011847_calendar_event_creator.sql b/crates/macro_db_client/migrations/20260827011847_calendar_event_creator.sql
new file mode 100644
index 0000000000..16ebd62f31
--- /dev/null
+++ b/crates/macro_db_client/migrations/20260827011847_calendar_event_creator.sql
@@ -0,0 +1,7 @@
+-- Google Calendar reports a creator separately from the organizer. When
+-- someone writes onto a calendar they do not own, the calendar owner is the
+-- organizer and the writer is the creator. Persist both so the product can
+-- label the calendar and "Created by" without conflating them.
+ALTER TABLE calendar_events
+ ADD COLUMN creator_email text,
+ ADD COLUMN creator_name text;
diff --git a/packages/sdk/generated/email/types.gen.ts b/packages/sdk/generated/email/types.gen.ts
index 2a9a323b75..fe9dda071c 100644
--- a/packages/sdk/generated/email/types.gen.ts
+++ b/packages/sdk/generated/email/types.gen.ts
@@ -612,6 +612,17 @@ export type CalendarEvent = {
* Entity creation time.
*/
createdAt: string;
+ /**
+ * Provider-reported creator email. Distinct from the organizer when
+ * someone writes onto a calendar they do not own. Omitted from stored
+ * projections when unknown so events ingested before this field still
+ * compare equal.
+ */
+ creatorEmail?: string | null;
+ /**
+ * Provider-reported creator display name.
+ */
+ creatorName?: string | null;
/**
* Optional event body.
*/
diff --git a/packages/sdk/generated/storage/types.gen.ts b/packages/sdk/generated/storage/types.gen.ts
index 804ecafb0d..d9301c7109 100644
--- a/packages/sdk/generated/storage/types.gen.ts
+++ b/packages/sdk/generated/storage/types.gen.ts
@@ -1258,6 +1258,17 @@ export type CalendarEvent = {
* Entity creation time.
*/
createdAt: string;
+ /**
+ * Provider-reported creator email. Distinct from the organizer when
+ * someone writes onto a calendar they do not own. Omitted from stored
+ * projections when unknown so events ingested before this field still
+ * compare equal.
+ */
+ creatorEmail?: string | null;
+ /**
+ * Provider-reported creator display name.
+ */
+ creatorName?: string | null;
/**
* Optional event body.
*/
diff --git a/packages/sdk/specs/email.json b/packages/sdk/specs/email.json
index fb9ed1df53..7d6f24d400 100644
--- a/packages/sdk/specs/email.json
+++ b/packages/sdk/specs/email.json
@@ -4555,6 +4555,14 @@
"format": "date-time",
"description": "Entity creation time."
},
+ "creatorEmail": {
+ "type": ["string", "null"],
+ "description": "Provider-reported creator email. Distinct from the organizer when\nsomeone writes onto a calendar they do not own. Omitted from stored\nprojections when unknown so events ingested before this field still\ncompare equal."
+ },
+ "creatorName": {
+ "type": ["string", "null"],
+ "description": "Provider-reported creator display name."
+ },
"description": {
"type": ["string", "null"],
"description": "Optional event body."
diff --git a/packages/sdk/specs/storage.json b/packages/sdk/specs/storage.json
index 517ea9743b..949d900e0b 100644
--- a/packages/sdk/specs/storage.json
+++ b/packages/sdk/specs/storage.json
@@ -13331,6 +13331,14 @@
"format": "date-time",
"description": "Entity creation time."
},
+ "creatorEmail": {
+ "type": ["string", "null"],
+ "description": "Provider-reported creator email. Distinct from the organizer when\nsomeone writes onto a calendar they do not own. Omitted from stored\nprojections when unknown so events ingested before this field still\ncompare equal."
+ },
+ "creatorName": {
+ "type": ["string", "null"],
+ "description": "Provider-reported creator display name."
+ },
"description": {
"type": ["string", "null"],
"description": "Optional event body."