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.

fix(calendar): preserve team ooo rows during unrelated syncs (#8150)

gbirman61c94d15ecaa
diff --git a/apps/web/src/lib/queries/calendar/sync.ts b/apps/web/src/lib/queries/calendar/sync.ts
index ea4f4d51d0..f9a5492783 100644
--- a/apps/web/src/lib/queries/calendar/sync.ts
+++ b/apps/web/src/lib/queries/calendar/sync.ts
@@ -4,7 +4,6 @@ import { calendarKeys, RSVP_MUTATION_KEY } from './keys';
import { invalidateCalendarEventPreviews } from './mention-preview';
import { invalidateCalendarOccurrences } from './occurrences';
import { refreshTeamCalendarQueries } from './team-cache';
-import { invalidateTeamOutOfOffice } from './team-ooo';
/**
* Refetches everything the calendar UI reads: every mounted occurrence
@@ -17,7 +16,6 @@ export function invalidateCalendarViews(): void {
void invalidateCalendarInvitations();
invalidateCalendarOccurrences();
invalidateCalendarEventPreviews();
- invalidateTeamOutOfOffice();
queryClient.invalidateQueries({
queryKey: calendarKeys.visibleCalendars.queryKey,
});
@@ -34,14 +32,23 @@ export function invalidateCalendarViews(): void {
export function handleRefreshCalendar(payload: unknown): void {
const event =
typeof payload === 'object' && payload !== null
- ? (payload as { event?: unknown; link_id?: unknown })
+ ? (payload as {
+ event?: unknown;
+ link_id?: unknown;
+ team_ooo_changed?: unknown;
+ })
: undefined;
if (event?.event === 'team_sharing_changed') {
- void refreshTeamCalendarQueries();
+ void refreshTeamCalendarQueries({
+ outOfOfficeChanged: event.team_ooo_changed !== false,
+ });
return;
}
if (event?.event !== 'synced' || typeof event.link_id !== 'string') return;
- void refreshTeamCalendarQueries();
+ // Old servers and unknown hints retain immediate revocation behavior.
+ void refreshTeamCalendarQueries({
+ outOfOfficeChanged: event.team_ooo_changed !== false,
+ });
// An in-flight RSVP holds optimistic occurrence state a refetch would
// clobber; the last RSVP to settle re-invalidates occurrences itself, so
@@ -51,7 +58,6 @@ export function handleRefreshCalendar(payload: unknown): void {
invalidateCalendarOccurrences();
}
invalidateCalendarEventPreviews();
- invalidateTeamOutOfOffice();
queryClient.invalidateQueries({
queryKey: calendarKeys.visibleCalendars.queryKey,
});
diff --git a/apps/web/src/lib/queries/calendar/team-cache.ts b/apps/web/src/lib/queries/calendar/team-cache.ts
index aa86606362..b4593c442c 100644
--- a/apps/web/src/lib/queries/calendar/team-cache.ts
+++ b/apps/web/src/lib/queries/calendar/team-cache.ts
@@ -64,16 +64,24 @@ export function resetTeamCalendarSession() {
}
/**
- * Clear teammates' payloads first: a revoked title must disappear even if the
- * refetch fails. The viewer's own team and settings only refetch, so their
- * controls never drop back to loading, and a setting with a save in flight
- * waits for that save to refetch it.
+ * Clear teammates' payloads unless the server excluded OOO changes: a revoked
+ * title must disappear even if the refetch fails. The viewer's own team and
+ * settings only refetch, so their controls never drop back to loading, and a
+ * setting with a save in flight waits for that save to refetch it.
*/
-export async function refreshTeamCalendarQueries() {
+export async function refreshTeamCalendarQueries(options?: {
+ outOfOfficeChanged: boolean;
+}) {
const saving = (mutationKey: QueryKey) =>
queryClient.isMutating({ mutationKey }) > 0;
await Promise.all([
- queryClient.resetQueries({ queryKey: calendarKeys.teamOutOfOffice._def }),
+ options?.outOfOfficeChanged === false
+ ? queryClient.invalidateQueries({
+ queryKey: calendarKeys.teamOutOfOffice._def,
+ })
+ : queryClient.resetQueries({
+ queryKey: calendarKeys.teamOutOfOffice._def,
+ }),
queryClient.invalidateQueries({
queryKey: calendarTeamKeys.identity._def,
}),
diff --git a/apps/web/src/lib/queries/calendar/team-ooo.ts b/apps/web/src/lib/queries/calendar/team-ooo.ts
index a508b60a3e..bcdd29518f 100644
--- a/apps/web/src/lib/queries/calendar/team-ooo.ts
+++ b/apps/web/src/lib/queries/calendar/team-ooo.ts
@@ -1,5 +1,4 @@
import { throwOnErr } from '@core/util/result';
-import { queryClient } from '@queries/client';
import { storageServiceClient } from '@service-storage/client';
import type { TeamOutOfOfficeItem } from '@service-storage/generated/schemas/teamOutOfOfficeItem';
import { queryOptions, useQuery } from '@tanstack/solid-query';
@@ -88,9 +87,3 @@ export function useTeamOutOfOfficeQuery(
);
});
}
-
-export function invalidateTeamOutOfOffice() {
- return queryClient.invalidateQueries({
- queryKey: calendarKeys.teamOutOfOffice._def,
- });
-}
diff --git a/apps/web/src/lib/queries/calendar/tests/sync.test.ts b/apps/web/src/lib/queries/calendar/tests/sync.test.ts
index b0de7abee2..05bb568f6c 100644
--- a/apps/web/src/lib/queries/calendar/tests/sync.test.ts
+++ b/apps/web/src/lib/queries/calendar/tests/sync.test.ts
@@ -35,16 +35,15 @@ describe('handleRefreshCalendar', () => {
});
expect(invalidateCalendarOccurrencesMock).toHaveBeenCalledTimes(1);
- expect(refreshTeamCalendarQueriesMock).toHaveBeenCalledTimes(1);
+ expect(refreshTeamCalendarQueriesMock).toHaveBeenCalledWith({
+ outOfOfficeChanged: true,
+ });
expect(invalidateQueriesMock).toHaveBeenCalledWith({
queryKey: calendarKeys.invitations._def,
});
expect(invalidateQueriesMock).toHaveBeenCalledWith({
queryKey: calendarKeys.visibleCalendars.queryKey,
});
- expect(invalidateQueriesMock).toHaveBeenCalledWith({
- queryKey: calendarKeys.teamOutOfOffice._def,
- });
});
it('defers the occurrence refetch while an RSVP is in flight', () => {
@@ -81,7 +80,36 @@ describe('handleRefreshCalendar', () => {
it('clears team projections on sharing changes without touching own optimistic events', () => {
handleRefreshCalendar({ event: 'team_sharing_changed' });
- expect(refreshTeamCalendarQueriesMock).toHaveBeenCalledTimes(1);
+ expect(refreshTeamCalendarQueriesMock).toHaveBeenCalledWith({
+ outOfOfficeChanged: true,
+ });
expect(invalidateCalendarOccurrencesMock).not.toHaveBeenCalled();
});
+
+ it.each(['synced', 'team_sharing_changed'])(
+ 'keeps OOO rows when %s explicitly excludes OOO changes',
+ (event) => {
+ handleRefreshCalendar({
+ event,
+ link_id: 'inbox',
+ team_ooo_changed: false,
+ });
+ expect(refreshTeamCalendarQueriesMock).toHaveBeenCalledWith({
+ outOfOfficeChanged: false,
+ });
+ }
+ );
+
+ it.each([true, undefined, null, 'false', 0])(
+ 'clears OOO rows for a missing or unsafe hint: %s',
+ (team_ooo_changed) => {
+ handleRefreshCalendar({
+ event: 'team_sharing_changed',
+ team_ooo_changed,
+ });
+ expect(refreshTeamCalendarQueriesMock).toHaveBeenCalledWith({
+ outOfOfficeChanged: true,
+ });
+ }
+ );
});
diff --git a/apps/web/src/lib/queries/calendar/tests/team-cache.test.ts b/apps/web/src/lib/queries/calendar/tests/team-cache.test.ts
index 99bc1d015b..b233e4ca52 100644
--- a/apps/web/src/lib/queries/calendar/tests/team-cache.test.ts
+++ b/apps/web/src/lib/queries/calendar/tests/team-cache.test.ts
@@ -47,6 +47,41 @@ describe('team authorization invalidation', () => {
unsubscribe();
});
+ it('keeps OOO rows and their selection during an unrelated calendar refresh', async () => {
+ const queryKey = calendarKeys.teamOutOfOffice(
+ 'alice',
+ undefined,
+ 'team'
+ ).queryKey;
+ const cached = [{ title: 'Vacation' }];
+ queryClient.setQueryData(queryKey, cached);
+ let finish!: (rows: typeof cached) => void;
+ const observer = new QueryObserver(queryClient, {
+ queryKey,
+ queryFn: () =>
+ new Promise<typeof cached>((resolve) => {
+ finish = resolve;
+ }),
+ staleTime: Infinity,
+ });
+ const unsubscribe = observer.subscribe(() => {});
+ const closeSelection = vi.fn();
+ const unsubscribeReset = subscribeToTeamCalendarReset(closeSelection);
+ const refresh = refreshTeamCalendarQueries({ outOfOfficeChanged: false });
+ expect(observer.getCurrentResult().data).toEqual(cached);
+ expect(observer.getCurrentResult().isPending).toBe(false);
+ expect(observer.getCurrentResult().isFetching).toBe(true);
+ expect(closeSelection).not.toHaveBeenCalled();
+ finish([{ title: 'Updated vacation' }]);
+ await refresh;
+ expect(observer.getCurrentResult().data).toEqual([
+ { title: 'Updated vacation' },
+ ]);
+ expect(closeSelection).not.toHaveBeenCalled();
+ unsubscribeReset();
+ unsubscribe();
+ });
+
it("keeps the viewer's own team and settings visible while they refetch", async () => {
const identity = { userId: 'alice', teamId: 'team' };
const keys = [
diff --git a/apps/web/src/lib/service-clients/service-calendar/generated/schemas/refreshCalendarEventOneOf.ts b/apps/web/src/lib/service-clients/service-calendar/generated/schemas/refreshCalendarEventOneOf.ts
index 2ca478867b..ce726500e9 100644
--- a/apps/web/src/lib/service-clients/service-calendar/generated/schemas/refreshCalendarEventOneOf.ts
+++ b/apps/web/src/lib/service-clients/service-calendar/generated/schemas/refreshCalendarEventOneOf.ts
@@ -13,4 +13,6 @@ export type RefreshCalendarEventOneOf = {
event: RefreshCalendarEventOneOfEvent;
/** Connected inbox whose calendars changed. */
link_id: string;
+ /** False only when the run excludes changes to teammate OOO projections. */
+ team_ooo_changed: boolean;
};
diff --git a/apps/web/src/lib/service-clients/service-calendar/generated/schemas/refreshCalendarEventOneOfThree.ts b/apps/web/src/lib/service-clients/service-calendar/generated/schemas/refreshCalendarEventOneOfThree.ts
index a7947f5285..28382bebf3 100644
--- a/apps/web/src/lib/service-clients/service-calendar/generated/schemas/refreshCalendarEventOneOfThree.ts
+++ b/apps/web/src/lib/service-clients/service-calendar/generated/schemas/refreshCalendarEventOneOfThree.ts
@@ -7,8 +7,10 @@
import type { RefreshCalendarEventOneOfThreeEvent } from './refreshCalendarEventOneOfThreeEvent';
/**
- * A team entitlement changed; discard cached team projections before refetching.
+ * Team projections need refreshing after a sync or entitlement change.
*/
export type RefreshCalendarEventOneOfThree = {
event: RefreshCalendarEventOneOfThreeEvent;
+ /** True for sharing changes and any possibly affected OOO projection. */
+ team_ooo_changed: boolean;
};
diff --git a/apps/web/src/lib/service-clients/service-calendar/openapi.json b/apps/web/src/lib/service-clients/service-calendar/openapi.json
index 7337bf77ce..8af17d5d41 100644
--- a/apps/web/src/lib/service-clients/service-calendar/openapi.json
+++ b/apps/web/src/lib/service-clients/service-calendar/openapi.json
@@ -1145,7 +1145,7 @@
{
"type": "object",
"description": "A sync run committed changes for `link_id`; viewers should refetch.",
- "required": ["link_id", "event"],
+ "required": ["link_id", "team_ooo_changed", "event"],
"properties": {
"event": {
"type": "string",
@@ -1155,17 +1155,25 @@
"type": "string",
"format": "uuid",
"description": "Connected inbox whose calendars changed."
+ },
+ "team_ooo_changed": {
+ "type": "boolean",
+ "description": "False only when the run excludes changes to teammate OOO projections."
}
}
},
{
"type": "object",
- "description": "A team entitlement changed; discard cached team projections before refetching.",
- "required": ["event"],
+ "description": "Team projections need refreshing after a sync or entitlement change.",
+ "required": ["team_ooo_changed", "event"],
"properties": {
"event": {
"type": "string",
"enum": ["team_sharing_changed"]
+ },
+ "team_ooo_changed": {
+ "type": "boolean",
+ "description": "True for sharing changes and any possibly affected OOO projection."
}
}
}
diff --git a/crates/calendar_events/AGENTS.md b/crates/calendar_events/AGENTS.md
index c218a7bb42..61ad73c2ac 100644
--- a/crates/calendar_events/AGENTS.md
+++ b/crates/calendar_events/AGENTS.md
@@ -54,6 +54,8 @@ dispatch, team availability, and Google/Postgres persistence.
occurrence projections, not separate events — don't model them as new entities.
- Imported point (non-recurring) events must survive sync and cache round-trips
unchanged (#7762) — a regression here silently drops user events.
+- Preserve the conservative OOO refresh hint on write outcomes and sync reports;
+ its contract is in [team sharing](../../docs/design/calendar-team-sharing.md).
## Related
diff --git a/crates/calendar_events/src/domain/models.rs b/crates/calendar_events/src/domain/models.rs
index 2738be76d3..552c40dfea 100644
--- a/crates/calendar_events/src/domain/models.rs
+++ b/crates/calendar_events/src/domain/models.rs
@@ -1371,6 +1371,8 @@ impl CalendarCreationTarget {
pub struct StoredGoogleCalendar {
/// Persisted Macro calendar identifier.
pub id: Uuid,
+ /// Calendar metadata changed and may invalidate teammate OOO projections.
+ pub team_ooo_changed: bool,
/// Last provider continuation token successfully committed for this calendar.
pub sync_token: Option<String>,
/// Exact recurrence window materialized by the last full snapshot.
@@ -1535,6 +1537,8 @@ pub struct GoogleCalendarSyncSnapshot {
/// What one Google backfill run changed, for change-driven notifications.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct GoogleBackfillRunReport {
+ /// A source, calendar, or failed coverage check may have changed OOO access.
+ pub team_ooo_changed: bool,
/// Events written through the ingestion upsert this run.
pub events_upserted: usize,
/// Cancellation tombstones the change feed reported this run.
@@ -1549,7 +1553,10 @@ impl GoogleBackfillRunReport {
/// Whether the run plausibly changed the local projection. Quiet
/// token-only polls report nothing and skip client notifications.
pub fn changed(&self) -> bool {
- self.events_upserted > 0 || self.cancellations_observed > 0 || self.events_retired > 0
+ self.team_ooo_changed
+ || self.events_upserted > 0
+ || self.cancellations_observed > 0
+ || self.events_retired > 0
}
}
@@ -1563,9 +1570,14 @@ pub enum RefreshCalendarEvent {
Synced {
/// Connected inbox whose calendars changed.
link_id: Uuid,
+ /// False only when the run excludes changes to teammate OOO projections.
+ team_ooo_changed: bool,
+ },
+ /// Team projections need refreshing after a sync or entitlement change.
+ TeamSharingChanged {
+ /// True for sharing changes and any possibly affected OOO projection.
+ team_ooo_changed: bool,
},
- /// A team entitlement changed; discard cached team projections before refetching.
- TeamSharingChanged,
}
/// Identity of one scheduled reminder firing: an occurrence, an offset, and
diff --git a/crates/calendar_events/src/domain/models/test.rs b/crates/calendar_events/src/domain/models/test.rs
index 298a5bda09..f971ac0f46 100644
--- a/crates/calendar_events/src/domain/models/test.rs
+++ b/crates/calendar_events/src/domain/models/test.rs
@@ -75,6 +75,7 @@ fn sync_plan_extends_only_the_uncovered_tail() {
let materialized = OccurrenceRange::historical_sync(now);
let stored = StoredGoogleCalendar {
id: Uuid::now_v7(),
+ team_ooo_changed: false,
sync_token: Some("token".to_string()),
materialized_range: Some(materialized.clone()),
synced_at: None,
@@ -107,6 +108,7 @@ fn sync_plan_extends_only_the_uncovered_tail() {
let uninitialized = StoredGoogleCalendar {
id: Uuid::now_v7(),
+ team_ooo_changed: false,
sync_token: None,
materialized_range: Some(materialized.clone()),
synced_at: None,
@@ -120,6 +122,7 @@ fn sync_plan_extends_only_the_uncovered_tail() {
let unmaterialized = StoredGoogleCalendar {
id: Uuid::now_v7(),
+ team_ooo_changed: false,
sync_token: Some("token".to_string()),
materialized_range: None,
synced_at: None,
@@ -137,6 +140,7 @@ fn watch_renewal_skips_calendars_that_recently_refused_push() {
let now = Utc.with_ymd_and_hms(2026, 9, 23, 12, 0, 0).unwrap();
let calendar = StoredGoogleCalendar {
id: Uuid::now_v7(),
+ team_ooo_changed: false,
sync_token: None,
materialized_range: None,
synced_at: None,
diff --git a/crates/calendar_events/src/domain/mutations.rs b/crates/calendar_events/src/domain/mutations.rs
index b89201b7c7..de881b5981 100644
--- a/crates/calendar_events/src/domain/mutations.rs
+++ b/crates/calendar_events/src/domain/mutations.rs
@@ -103,7 +103,9 @@ where
return;
}
self.publish_retirements(retired);
- self.refresh.calendar_changed(owner_id, email_link_id).await;
+ self.refresh
+ .calendar_changed(owner_id, email_link_id, true)
+ .await;
}
/// Announce what a write did to the canonical row. A write that changed
@@ -201,7 +203,7 @@ where
self.publish_write_outcome(&outcome);
if outcome.change != CalendarEventChange::Unchanged {
self.refresh
- .calendar_changed(&outcome.owner_id, email_link_id)
+ .calendar_changed(&outcome.owner_id, email_link_id, outcome.team_ooo_changed)
.await;
}
if let Some(viewer) = viewer {
@@ -543,7 +545,7 @@ where
// The purge removed whole calendars, and no sync echo will ever
// arrive for a disconnected link, so viewers have to be nudged here.
self.refresh
- .calendar_changed(requester_id, email_link_id)
+ .calendar_changed(requester_id, email_link_id, true)
.await;
Ok(())
}
diff --git a/crates/calendar_events/src/domain/mutations/test.rs b/crates/calendar_events/src/domain/mutations/test.rs
index a60b3a3e05..995006dace 100644
--- a/crates/calendar_events/src/domain/mutations/test.rs
+++ b/crates/calendar_events/src/domain/mutations/test.rs
@@ -215,11 +215,13 @@ impl CalendarRepository for FakeRepo {
panic!("mutations must persist through the UserMutation authority");
};
let owner_id = upsert.event.owner_id.clone();
+ let team_ooo_changed = upsert.event.event_type == EventType::OutOfOffice;
self.upserts.lock().unwrap().push(upsert);
Ok(CalendarEventWriteOutcome {
event_id: self.persisted_event_id.unwrap_or_else(Uuid::now_v7),
owner_id,
change: self.write_change,
+ team_ooo_changed,
})
}
@@ -723,15 +725,16 @@ impl macro_event_broker::MacroEventBroker for RecordingEventBroker {
/// Records every viewer refresh nudge the service emits.
#[derive(Clone, Default)]
struct RecordingRefreshNotifier {
- notified: Arc<Mutex<Vec<(String, Uuid)>>>,
+ notified: Arc<Mutex<Vec<(String, Uuid, bool)>>>,
}
impl CalendarRefreshNotifier for RecordingRefreshNotifier {
- async fn calendar_changed(&self, owner_id: &str, email_link_id: Uuid) {
- self.notified
- .lock()
- .expect("notifier lock")
- .push((owner_id.to_string(), email_link_id));
+ async fn calendar_changed(&self, owner_id: &str, email_link_id: Uuid, team_ooo_changed: bool) {
+ self.notified.lock().expect("notifier lock").push((
+ owner_id.to_string(),
+ email_link_id,
+ team_ooo_changed,
+ ));
}
}
@@ -992,6 +995,10 @@ async fn a_persisted_mutation_nudges_the_links_calendar_viewers() {
let notified = refresh.notified.lock().expect("notifier lock").clone();
assert_eq!(notified.len(), 1);
assert_eq!(notified[0].0, "macro|[email protected]");
+ assert!(
+ !notified[0].2,
+ "ordinary event edits preserve cached OOO rows"
+ );
}
#[tokio::test]
@@ -2493,7 +2500,7 @@ async fn disconnecting_calendar_nudges_the_links_calendar_viewers() {
assert_eq!(
refresh.notified.lock().expect("notifier lock").as_slice(),
- [("macro|user".to_string(), link_id)]
+ [("macro|user".to_string(), link_id, true)]
);
}
diff --git a/crates/calendar_events/src/domain/ports.rs b/crates/calendar_events/src/domain/ports.rs
index 631bc5a7b6..a41beb6849 100644
--- a/crates/calendar_events/src/domain/ports.rs
+++ b/crates/calendar_events/src/domain/ports.rs
@@ -379,6 +379,8 @@ pub struct CalendarEventWriteOutcome {
pub owner_id: String,
/// What happened to the row.
pub change: CalendarEventChange,
+ /// A changed source was or is OOO; it may revoke a teammate's status/title.
+ pub team_ooo_changed: bool,
}
/// One event's fate after its sources were retired.
@@ -638,11 +640,13 @@ pub trait CalendarRepository: Send + Sync + 'static {
/// Macro-originated mutation changed them. Best effort: implementations log
/// and swallow delivery failures, since the mutation is already committed.
pub trait CalendarRefreshNotifier: Send + Sync + 'static {
- /// Signal that `email_link_id`'s calendar projection changed.
+ /// Signal that `email_link_id`'s calendar projection changed. Only pass
+ /// `team_ooo_changed: false` when the change cannot affect team OOO access.
fn calendar_changed(
&self,
owner_id: &str,
email_link_id: Uuid,
+ team_ooo_changed: bool,
) -> impl Future<Output = ()> + Send;
}
diff --git a/crates/calendar_events/src/domain/service.rs b/crates/calendar_events/src/domain/service.rs
index 5bc3c3f29a..38c04dd706 100644
--- a/crates/calendar_events/src/domain/service.rs
+++ b/crates/calendar_events/src/domain/service.rs
@@ -748,6 +748,7 @@ where
.upsert_google_calendar(key, lease_token, account_id, provider_calendar)
.await?;
let calendar_id = stored_calendar.id;
+ report.team_ooo_changed |= stored_calendar.team_ooo_changed;
calendar_ids.push(calendar_id);
if super::models::is_system_calendar(&provider_calendar_id)
&& stored_calendar.synced_at.is_some_and(|synced_at| {
@@ -813,6 +814,7 @@ where
"isolating a failed Google Calendar and continuing the account sync"
);
isolated_failures.push((calendar_id, error.message().to_owned()));
+ report.team_ooo_changed = true;
// A retryable failure outranks a permanent one so a total
// failure still surfaces as retryable.
last_isolated_error = Some(match last_isolated_error {
@@ -838,6 +840,7 @@ where
})
.await?;
self.publish_write_outcome(&outcome);
+ report.team_ooo_changed |= outcome.team_ooo_changed;
calendar_count += 1;
}
// The upserts above committed individually, so they count even
@@ -867,6 +870,7 @@ where
// gone once the commit lands, so nothing downstream can rediscover
// it by re-reading Postgres.
report.events_retired += retired.len();
+ report.team_ooo_changed |= !retired.is_empty() || cancellation_count > 0;
self.publish_retirements(retired);
// Tombstones only apply inside the snapshot commit, so they
// count once it succeeds.
@@ -966,6 +970,7 @@ where
.reconcile_google_calendar_list(key, lease_token, account_id, calendar_ids)
.await?;
report.events_retired += retired.len();
+ report.team_ooo_changed |= !retired.is_empty();
self.publish_retirements(retired);
Ok(())
diff --git a/crates/calendar_events/src/domain/service/test.rs b/crates/calendar_events/src/domain/service/test.rs
index 1ef1229cc3..b92b91f8c1 100644
--- a/crates/calendar_events/src/domain/service/test.rs
+++ b/crates/calendar_events/src/domain/service/test.rs
@@ -22,6 +22,8 @@ use std::sync::{Arc, Mutex};
#[derive(Clone, Default)]
struct FakeRepo {
+ team_ooo_changed: bool,
+ calendar_ooo_changed: bool,
upserts: Arc<Mutex<Vec<CalendarEventUpsert>>>,
stored_synced_at: Option<chrono::DateTime<Utc>>,
sync_snapshots: Arc<Mutex<Vec<GoogleCalendarSyncSnapshot>>>,
@@ -64,11 +66,14 @@ impl CalendarRepository for FakeRepo {
};
let id = upsert.event.id;
let owner_id = upsert.event.owner_id.clone();
+ let team_ooo_changed =
+ self.team_ooo_changed || upsert.event.event_type == EventType::OutOfOffice;
self.upserts.lock().unwrap().push(upsert);
Ok(CalendarEventWriteOutcome {
event_id: id,
owner_id,
change: CalendarEventChange::Created,
+ team_ooo_changed,
})
}
@@ -170,6 +175,7 @@ impl CalendarRepository for FakeRepo {
) -> Result<StoredGoogleCalendar, Report> {
Ok(StoredGoogleCalendar {
id: Uuid::nil(),
+ team_ooo_changed: self.calendar_ooo_changed,
sync_token: None,
materialized_range: None,
synced_at: self.stored_synced_at,
@@ -623,6 +629,86 @@ impl GoogleCalendarProvider for PartialFailureGoogleProvider {
}
}
+/// A single healthy calendar with an optional changed event.
+#[derive(Clone)]
+struct ChangedCalendarProvider {
+ with_event: bool,
+}
+
+impl GoogleCalendarProvider for ChangedCalendarProvider {
+ async fn list_calendars(
+ &self,
+ _access_token: &str,
+ _email_link_id: Uuid,
+ ) -> Result<Vec<ProviderCalendar>, GoogleProviderError> {
+ Ok(vec![provider_calendar("primary", true)])
+ }
+
+ async fn sync_events(
+ &self,
+ access_token: &str,
+ context: GoogleEventSyncContext,
+ ) -> Result<GoogleEventSyncBatch, GoogleProviderError> {
+ let mut batch = PartialFailureGoogleProvider
+ .sync_events(access_token, context)
+ .await?;
+ if !self.with_event {
+ batch.upserts.clear();
+ }
+ Ok(batch)
+ }
+
+ async fn watch_calendar(
+ &self,
+ _access_token: &str,
+ _email_link_id: Uuid,
+ _provider_calendar_id: &str,
+ _channel_id: Uuid,
+ _config: &GoogleWatchConfig,
+ ) -> Result<GoogleWatchChannel, GoogleProviderError> {
+ unreachable!("watch is disabled in these tests")
+ }
+}
+
+#[tokio::test]
+async fn backfill_refresh_reports_source_and_calendar_ooo_changes() {
+ for (with_event, source_changed, calendar_changed) in [
+ (true, false, false),
+ (true, true, false),
+ (true, false, true),
+ (false, false, true),
+ (false, false, false),
+ ] {
+ let coordinator = GoogleCalendarBackfillCoordinator::new(
+ FakeRepo {
+ team_ooo_changed: source_changed,
+ calendar_ooo_changed: calendar_changed,
+ ..FakeRepo::default()
+ },
+ ChangedCalendarProvider { with_event },
+ FakeLifecycle::claimed(),
+ NoopMacroEventBroker,
+ None,
+ );
+ let mut report = GoogleBackfillRunReport::default();
+ coordinator
+ .run(
+ CalendarBackfillJobKey {
+ job_id: Uuid::now_v7(),
+ email_link_id: Uuid::now_v7(),
+ },
+ "secret",
+ OccurrenceRange::maintenance_horizon(Utc::now()),
+ &mut report,
+ )
+ .await
+ .unwrap();
+ assert_eq!(report.changed(), with_event || calendar_changed);
+ assert_eq!(report.team_ooo_changed, source_changed || calendar_changed);
+ }
+}
+
/// Fails the poll of every calendar it lists.
#[derive(Clone)]
struct TotalFailureGoogleProvider;
@@ -873,6 +959,10 @@ async fn one_failed_calendar_is_isolated_and_the_account_completes() {
"the healthy calendar's commit must still land"
);
assert!(report.changed());
+ assert!(
+ report.team_ooo_changed,
+ "isolated failures cannot certify unchanged OOO access"
+ );
let recorded = recorded_sync_errors.lock().unwrap();
assert_eq!(
recorded.len(),
@@ -1171,6 +1261,10 @@ async fn a_cancelled_provider_event_publishes_a_deletion() {
.await
.unwrap();
+ assert!(
+ report.team_ooo_changed,
+ "retired sources must withdraw cached OOO rows"
+ );
let published = broker.published.lock().unwrap().clone();
let deleted: Vec<&String> = published
.iter()
@@ -1347,7 +1441,11 @@ async fn a_fresh_system_calendar_keeps_a_failing_calendar_isolated() {
.await
.expect("a fresh system calendar keeps the account healthy");
- assert_eq!(report, GoogleBackfillRunReport::default());
+ assert!(report.changed());
+ assert!(
+ report.team_ooo_changed,
+ "failed coverage cannot certify unchanged OOO access"
+ );
assert_eq!(
recorded_sync_errors.lock().unwrap().as_slice(),
["the primary calendar's poll failed"]
diff --git a/crates/calendar_events/src/outbound/pg.rs b/crates/calendar_events/src/outbound/pg.rs
index 392a33f676..bf1f4d35d4 100644
--- a/crates/calendar_events/src/outbound/pg.rs
+++ b/crates/calendar_events/src/outbound/pg.rs
@@ -247,6 +247,7 @@ impl PgCalendarRepository {
false,
)
.await?
+ .0
.id;
log.commit(tx).await?;
Ok(id)
@@ -766,6 +767,22 @@ impl CalendarRepository for PgCalendarRepository {
.fetch_optional(&mut *tx)
.await
.map_err(report)?;
+ // The old source matters too: changing OOO to a regular event withdraws
+ // a status teammates may already have cached. Unknown legacy payloads
+ // cannot certify an unrelated update.
+ let team_ooo_changed = upsert.event.event_type == EventType::OutOfOffice
+ || existing.as_ref().is_some_and(|row| {
+ row.normalized_payload
+ .get("event")
+ .and_then(serde_json::Value::as_object)
+ .is_none_or(|event| {
+ // Regular events omit eventType in stored projections.
+ event.get("eventType").is_some_and(|kind| {
+ serde_json::from_value::<EventType>(kind.clone())
+ .map_or(true, |kind| kind == EventType::OutOfOffice)
+ })
+ })
+ });
if let Some(row) = &existing {
let incoming =
serde_json::to_value(StoredSourceProjection::from(&upsert)).map_err(report)?;
@@ -776,6 +793,7 @@ impl CalendarRepository for PgCalendarRepository {
event_id: row.event_id,
owner_id: upsert.event.owner_id.clone(),
change: CalendarEventChange::Unchanged,
+ team_ooo_changed: false,
});
}
}
@@ -877,6 +895,7 @@ impl CalendarRepository for PgCalendarRepository {
event_id,
owner_id: upsert.event.owner_id.clone(),
change: CalendarEventChange::Unchanged,
+ team_ooo_changed: false,
});
};
if provider_sync {
@@ -933,6 +952,7 @@ impl CalendarRepository for PgCalendarRepository {
} else {
CalendarEventChange::Updated
},
+ team_ooo_changed,
})
}
@@ -1314,7 +1334,7 @@ impl CalendarRepository for PgCalendarRepository {
let mut tx = self.pool.begin().await.map_err(report)?;
fence_google_mutation_tx(&mut tx, key, lease_token, Some(account_id)).await?;
let mut log = ChangeLogBatch::default();
- let calendar = upsert_calendar_tx(
+ let (calendar, team_ooo_changed) = upsert_calendar_tx(
&mut tx,
&mut log,
key.email_link_id,
@@ -1324,7 +1344,7 @@ impl CalendarRepository for PgCalendarRepository {
)
.await?;
log.commit(tx).await?;
- stored_google_calendar(calendar)
+ stored_google_calendar(calendar, team_ooo_changed)
}
#[tracing::instrument(skip(self, sync), fields(job_id = %key.job_id), err)]
@@ -2386,7 +2406,7 @@ async fn upsert_calendar_tx(
account_id: Uuid,
calendar: ProviderCalendar,
provider_sync: bool,
-) -> Result<StoredCalendarRow, Report> {
+) -> Result<(StoredCalendarRow, bool), Report> {
// Snapshot the reminder-relevant state before the upsert: a change to the
// default reminders or the zone that anchors all-day starts invalidates
// the firing schedule of every event that follows this calendar.
@@ -2504,7 +2524,10 @@ async fn upsert_calendar_tx(
if visibly_changed {
log.record(email_link_id, CalendarChangeOp::UpsertCalendar(row.id));
}
- Ok(row)
+ Ok((
+ row,
+ visibly_changed || reminders_invalidated || access_changed,
+ ))
}
/// The sync error a calendar shows clients, if any, locking its row for the
@@ -2531,7 +2554,10 @@ async fn visible_calendar_sync_error_tx(
}))
}
-fn stored_google_calendar(row: StoredCalendarRow) -> Result<StoredGoogleCalendar, Report> {
+fn stored_google_calendar(
+ row: StoredCalendarRow,
+ team_ooo_changed: bool,
+) -> Result<StoredGoogleCalendar, Report> {
let materialized_range = match (
row.materialized_starts_at,
row.materialized_ends_at,
@@ -2555,6 +2581,7 @@ fn stored_google_calendar(row: StoredCalendarRow) -> Result<StoredGoogleCalendar
};
Ok(StoredGoogleCalendar {
id: row.id,
+ team_ooo_changed,
sync_token: row.sync_token,
materialized_range,
synced_at: row.synced_at,
diff --git a/crates/calendar_events/src/outbound/pg/test.rs b/crates/calendar_events/src/outbound/pg/test.rs
index e74f5fdb59..6dfa51c7a1 100644
--- a/crates/calendar_events/src/outbound/pg/test.rs
+++ b/crates/calendar_events/src/outbound/pg/test.rs
@@ -1,6 +1,7 @@
use super::*;
mod point_events;
mod snapshot_coverage;
+mod team_refresh;
mod team_sharing;
mod team_sync_coverage;
use crate::domain::models::{
diff --git a/crates/calendar_events/src/outbound/pg/test/team_refresh.rs b/crates/calendar_events/src/outbound/pg/test/team_refresh.rs
new file mode 100644
index 0000000000..2388ea2035
--- /dev/null
+++ b/crates/calendar_events/src/outbound/pg/test/team_refresh.rs
@@ -0,0 +1,121 @@
+use super::*;
+use crate::outbound::pg::source_access::verify_calendar_snapshot;
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn calendar_metadata_changes_never_certify_unchanged_ooo(pool: PgPool) {
+ let owner = "macro|[email protected]";
+ let link = insert_link(&pool, owner).await;
+ let repo = PgCalendarRepository::new(pool.clone());
+ let (account, calendar_id) = provider_ids(&repo, link).await;
+ let mut tx = pool.begin().await.unwrap();
+ let mut log = ChangeLogBatch::default();
+ let mut calendar = ProviderCalendar {
+ provider_calendar_id: "primary".to_string(),
+ name: "Primary".to_string(),
+ description: None,
+ time_zone: Some("UTC".to_string()),
+ color: None,
+ access_role: Some("owner".to_string()),
+ is_primary: true,
+ is_selected: true,
+ default_reminders: Vec::new(),
+ };
+ verify_calendar_snapshot(&mut tx, account, calendar_id)
+ .await
+ .unwrap();
+ let (_, changed) =
+ upsert_calendar_tx(&mut tx, &mut log, link, account, calendar.clone(), false)
+ .await
+ .unwrap();
+ assert!(
+ !changed,
+ "an unchanged verified calendar leaves OOO rows intact"
+ );
+
+ calendar.is_primary = false;
+ let (_, changed) =
+ upsert_calendar_tx(&mut tx, &mut log, link, account, calendar.clone(), false)
+ .await
+ .unwrap();
+ assert!(changed, "OOO reads only primary calendars");
+
+ verify_calendar_snapshot(&mut tx, account, calendar_id)
+ .await
+ .unwrap();
+ calendar.access_role = Some("reader".to_string());
+ let (_, changed) = upsert_calendar_tx(&mut tx, &mut log, link, account, calendar, false)
+ .await
+ .unwrap();
+ assert!(changed, "provider ACL changes require immediate clearing");
+ tx.rollback().await.unwrap();
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn refresh_hint_preserves_unrelated_events_but_clears_old_and_new_ooo(pool: PgPool) {
+ let owner = "macro|[email protected]";
+ insert_user(&pool, owner).await;
+ let link = insert_link(&pool, owner).await;
+ let repo = PgCalendarRepository::new(pool);
+ let provider = provider_ids(&repo, link).await;
+ let mut upsert = timed_upsert(owner, link, provider, "[email protected]", "Meeting", 1);
+
+ let regular = repo
+ .upsert_event(CalendarEventWrite::Fixture(upsert.clone()))
+ .await
+ .unwrap();
+ assert!(!regular.team_ooo_changed);
+ upsert.event.sequence += 1;
+ upsert.event.title = "Renamed meeting".to_string();
+ let renamed = repo
+ .upsert_event(CalendarEventWrite::Fixture(upsert.clone()))
+ .await
+ .unwrap();
+ assert!(!renamed.team_ooo_changed);
+
+ upsert.event.sequence += 1;
+ upsert.event.event_type = EventType::OutOfOffice;
+ let ooo = repo
+ .upsert_event(CalendarEventWrite::Fixture(upsert.clone()))
+ .await
+ .unwrap();
+ assert!(ooo.team_ooo_changed);
+
+ let replay = repo
+ .upsert_event(CalendarEventWrite::Fixture(upsert.clone()))
+ .await
+ .unwrap();
+ assert!(
+ !replay.team_ooo_changed,
+ "identical OOO snapshots do not withdraw cached rows"
+ );
+
+ upsert.event.sequence += 1;
+ upsert.event.visibility = EventVisibility::Private;
+ let private = repo
+ .upsert_event(CalendarEventWrite::Fixture(upsert.clone()))
+ .await
+ .unwrap();
+ assert!(
+ private.team_ooo_changed,
+ "a private OOO withdraws even its status"
+ );
+
+ upsert.event.sequence += 1;
+ upsert.event.event_type = EventType::Default;
+ let former_ooo = repo
+ .upsert_event(CalendarEventWrite::Fixture(upsert.clone()))
+ .await
+ .unwrap();
+ assert!(
+ former_ooo.team_ooo_changed,
+ "the stored source was OOO before this write"
+ );
+
+ upsert.event.sequence += 1;
+ upsert.event.title = "Private meeting".to_string();
+ let unrelated = repo
+ .upsert_event(CalendarEventWrite::Fixture(upsert))
+ .await
+ .unwrap();
+ assert!(!unrelated.team_ooo_changed);
+}
diff --git a/docs/agent-guide/calendar.md b/docs/agent-guide/calendar.md
index 9f057ce8a6..59cbcab950 100644
--- a/docs/agent-guide/calendar.md
+++ b/docs/agent-guide/calendar.md
@@ -447,6 +447,11 @@ shows or hides the overlay (the list itself always shows); clicking a row naviga
to that date. Coverage depends on each teammate having connected their own calendar and using
Google's out-of-office event type.
+Routine sync notifications that explicitly exclude OOO changes refresh this list
+in the background without returning to its skeleton. OOO changes, sharing changes,
+and notifications without that guarantee still clear cached rows and close open
+OOO details immediately before refetching.
+
A calendar event mentioned in a channel message opens the calendar focused on the viewer's
own copy of the meeting. When a person holds the event on their own calendar and posts the
mention, it is shared read-only with the channel's current members: a member without a copy of
diff --git a/docs/design/calendar-team-sharing.md b/docs/design/calendar-team-sharing.md
index 7a94b125af..1e54f42a32 100644
--- a/docs/design/calendar-team-sharing.md
+++ b/docs/design/calendar-team-sharing.md
@@ -92,6 +92,15 @@ each one as a plain out-of-office block without its title; `all` adds the title;
`none` hides it. Gate-off deployment suppresses that overlay, and its absence is
not a claim that the person has no time off.
+Calendar refresh notifications carry `team_ooo_changed`. Only an explicit `false`
+lets the frontend retain OOO rows and open details while refetching. The server
+certifies this for unchanged sources and changes to sources that were and remain
+non-OOO, provided no calendar metadata, coverage failure, cancellation, or source
+retirement makes the result uncertain. OOO edits (including becoming private or
+ceasing to be OOO), sharing changes, and disconnects require immediate clearing.
+Missing or malformed hints from older servers also clear immediately. The
+60-second cache expiry and session-reset behavior remain in force.
+
Team projections and availability use server-confirmed source copies. An offline
edit can appear immediately in the editor's own calendar through the mutation
queue, but does not change what teammates see or their availability results until
diff --git a/packages/sdk/generated/calendar/types.gen.ts b/packages/sdk/generated/calendar/types.gen.ts
index 7a46cb419d..a0dc7963cf 100644
--- a/packages/sdk/generated/calendar/types.gen.ts
+++ b/packages/sdk/generated/calendar/types.gen.ts
@@ -519,8 +519,16 @@ export type RefreshCalendarEvent = {
* Connected inbox whose calendars changed.
*/
link_id: string;
+ /**
+ * False only when the run excludes changes to teammate OOO projections.
+ */
+ team_ooo_changed: boolean;
} | {
event: 'team_sharing_changed';
+ /**
+ * True for sharing changes and any possibly affected OOO projection.
+ */
+ team_ooo_changed: boolean;
};
/**
diff --git a/packages/sdk/specs/calendar.json b/packages/sdk/specs/calendar.json
index 7337bf77ce..8af17d5d41 100644
--- a/packages/sdk/specs/calendar.json
+++ b/packages/sdk/specs/calendar.json
@@ -1145,7 +1145,7 @@
{
"type": "object",
"description": "A sync run committed changes for `link_id`; viewers should refetch.",
- "required": ["link_id", "event"],
+ "required": ["link_id", "team_ooo_changed", "event"],
"properties": {
"event": {
"type": "string",
@@ -1155,17 +1155,25 @@
"type": "string",
"format": "uuid",
"description": "Connected inbox whose calendars changed."
+ },
+ "team_ooo_changed": {
+ "type": "boolean",
+ "description": "False only when the run excludes changes to teammate OOO projections."
}
}
},
{
"type": "object",
- "description": "A team entitlement changed; discard cached team projections before refetching.",
- "required": ["event"],
+ "description": "Team projections need refreshing after a sync or entitlement change.",
+ "required": ["team_ooo_changed", "event"],
"properties": {
"event": {
"type": "string",
"enum": ["team_sharing_changed"]
+ },
+ "team_ooo_changed": {
+ "type": "boolean",
+ "description": "True for sharing changes and any possibly affected OOO projection."
}
}
}
diff --git a/services/calendar_service/AGENTS.md b/services/calendar_service/AGENTS.md
index 9a3e95ed29..16a366fdd4 100644
--- a/services/calendar_service/AGENTS.md
+++ b/services/calendar_service/AGENTS.md
@@ -47,6 +47,8 @@ gateway `/calendar` prefix.
`src/api.rs`) because the gateway forwards the path unchanged.
- Reauth-required notifications ride the shared `LinkManagerQueue`, consumed by
`email_service`; don't add a second calendar-specific reconnect notification.
+- Forward `team_ooo_changed` to both inbox and teammate refresh notifications;
+ sharing changes and uncertain sync results require `true`.
## Related
diff --git a/services/calendar_service/src/calendar_backfill.rs b/services/calendar_service/src/calendar_backfill.rs
index bb9782b9e2..b3a902f2ed 100644
--- a/services/calendar_service/src/calendar_backfill.rs
+++ b/services/calendar_service/src/calendar_backfill.rs
@@ -323,6 +323,7 @@ async fn run_coordinator(
link.macro_id.as_ref(),
link.id,
ctx.team_sharing_enabled,
+ report.team_ooo_changed || run_result.is_err(),
)
.await;
}
diff --git a/services/calendar_service/src/calendar_refresh.rs b/services/calendar_service/src/calendar_refresh.rs
index fe25983b11..46bdb73018 100644
--- a/services/calendar_service/src/calendar_refresh.rs
+++ b/services/calendar_service/src/calendar_refresh.rs
@@ -2,6 +2,7 @@
use calendar_events::domain::ports::CalendarRefreshNotifier;
use connection_gateway_client::client::ConnectionGatewayClient;
+use tracing::Instrument;
use uuid::Uuid;
use crate::pubsub_util::cg_refresh_calendar;
@@ -33,7 +34,7 @@ impl ConnectionGatewayCalendarRefresh {
}
impl CalendarRefreshNotifier for ConnectionGatewayCalendarRefresh {
- async fn calendar_changed(&self, owner_id: &str, email_link_id: Uuid) {
+ async fn calendar_changed(&self, owner_id: &str, email_link_id: Uuid, team_ooo_changed: bool) {
// Spawned so the mutation response never waits on the gateway: the
// client has no request timeout and the fan-out posts serially per
// recipient, while the write this announces is already committed.
@@ -41,9 +42,20 @@ impl CalendarRefreshNotifier for ConnectionGatewayCalendarRefresh {
let db = self.db.clone();
let owner_id = owner_id.to_string();
let team_sharing_enabled = self.team_sharing_enabled;
- tokio::spawn(async move {
- cg_refresh_calendar(&client, &db, &owner_id, email_link_id, team_sharing_enabled).await;
- });
+ tokio::spawn(
+ async move {
+ cg_refresh_calendar(
+ &client,
+ &db,
+ &owner_id,
+ email_link_id,
+ team_sharing_enabled,
+ team_ooo_changed,
+ )
+ .await;
+ }
+ .in_current_span(),
+ );
}
}
@@ -52,8 +64,11 @@ impl calendar_events::domain::team::CalendarTeamNotifier for ConnectionGatewayCa
let client = self.client.clone();
let db = self.db.clone();
let user_id = user_id.to_owned();
- tokio::spawn(async move {
- crate::pubsub_util::cg_refresh_team_calendar(&client, &db, &[user_id]).await;
- });
+ tokio::spawn(
+ async move {
+ crate::pubsub_util::cg_refresh_team_calendar(&client, &db, &[user_id], true).await;
+ }
+ .in_current_span(),
+ );
}
}
diff --git a/services/calendar_service/src/pubsub_util.rs b/services/calendar_service/src/pubsub_util.rs
index 50a3e4922a..77882ac5fa 100644
--- a/services/calendar_service/src/pubsub_util.rs
+++ b/services/calendar_service/src/pubsub_util.rs
@@ -13,12 +13,16 @@ pub async fn cg_refresh_calendar(
owner_macro_id: &str,
link_id: uuid::Uuid,
team_sharing_enabled: bool,
+ team_ooo_changed: bool,
) {
if !cfg!(feature = "connection_gateway") {
return;
}
let payload = serde_json::to_value(
- calendar_events::domain::models::RefreshCalendarEvent::Synced { link_id },
+ calendar_events::domain::models::RefreshCalendarEvent::Synced {
+ link_id,
+ team_ooo_changed,
+ },
)
.unwrap_or_default();
let mut recipients = vec![owner_macro_id.to_string()];
@@ -37,7 +41,7 @@ pub async fn cg_refresh_calendar(
recipients.sort();
recipients.dedup();
if team_sharing_enabled {
- cg_refresh_team_calendar(client, db, &recipients).await;
+ cg_refresh_team_calendar(client, db, &recipients, team_ooo_changed).await;
}
for macro_id in recipients {
let _ = client
@@ -55,6 +59,7 @@ pub async fn cg_refresh_team_calendar(
client: &ConnectionGatewayClient,
db: &sqlx::PgPool,
shared_by: &[String],
+ team_ooo_changed: bool,
) {
if !cfg!(feature = "connection_gateway") || shared_by.is_empty() {
return;
@@ -79,7 +84,12 @@ pub async fn cg_refresh_team_calendar(
return;
}
};
- let payload = serde_json::json!({"event": "team_sharing_changed"});
+ let payload = serde_json::to_value(
+ calendar_events::domain::models::RefreshCalendarEvent::TeamSharingChanged {
+ team_ooo_changed,
+ },
+ )
+ .unwrap_or_default();
stream::iter(recipients.into_iter().flatten())
.for_each_concurrent(16, |user_id| {
let payload = payload.clone();
diff --git a/services/email_service/AGENTS.md b/services/email_service/AGENTS.md
index d3c3bb32af..7ddd76891e 100644
--- a/services/email_service/AGENTS.md
+++ b/services/email_service/AGENTS.md
@@ -50,6 +50,8 @@ the gateway `/email` prefix.
(#7039) — don't reintroduce a path that notifies on our own sends.
- Long attachment names are truncated to the DSS limit before upload (#7893);
don't remove that truncation when touching `util/upload_attachment.rs`.
+- Preserve the calendar domain's `team_ooo_changed` hint when forwarding a
+ calendar refresh so unrelated invitation updates retain teammates' OOO rows.
## Related
diff --git a/services/email_service/src/calendar_refresh.rs b/services/email_service/src/calendar_refresh.rs
index e7c0aa7907..74a471b274 100644
--- a/services/email_service/src/calendar_refresh.rs
+++ b/services/email_service/src/calendar_refresh.rs
@@ -2,6 +2,7 @@
use calendar_events::domain::ports::CalendarRefreshNotifier;
use connection_gateway_client::client::ConnectionGatewayClient;
+use tracing::Instrument;
use uuid::Uuid;
use crate::pubsub::util::cg_refresh_calendar;
@@ -24,15 +25,18 @@ impl ConnectionGatewayCalendarRefresh {
}
impl CalendarRefreshNotifier for ConnectionGatewayCalendarRefresh {
- async fn calendar_changed(&self, owner_id: &str, email_link_id: Uuid) {
+ async fn calendar_changed(&self, owner_id: &str, email_link_id: Uuid, team_ooo_changed: bool) {
// Spawned so the mutation response never waits on the gateway: the
// client has no request timeout and the fan-out posts serially per
// recipient, while the write this announces is already committed.
let client = self.client.clone();
let db = self.db.clone();
let owner_id = owner_id.to_string();
- tokio::spawn(async move {
- cg_refresh_calendar(&client, &db, &owner_id, email_link_id).await;
- });
+ tokio::spawn(
+ async move {
+ cg_refresh_calendar(&client, &db, &owner_id, email_link_id, team_ooo_changed).await;
+ }
+ .in_current_span(),
+ );
}
}
diff --git a/services/email_service/src/pubsub/util.rs b/services/email_service/src/pubsub/util.rs
index 23ac1c457b..814e42c51e 100644
--- a/services/email_service/src/pubsub/util.rs
+++ b/services/email_service/src/pubsub/util.rs
@@ -117,12 +117,16 @@ pub async fn cg_refresh_calendar(
db: &sqlx::PgPool,
owner_macro_id: &str,
link_id: uuid::Uuid,
+ team_ooo_changed: bool,
) {
if !cfg!(feature = "connection_gateway") {
return;
}
let payload = serde_json::to_value(
- calendar_events::domain::models::RefreshCalendarEvent::Synced { link_id },
+ calendar_events::domain::models::RefreshCalendarEvent::Synced {
+ link_id,
+ team_ooo_changed,
+ },
)
.unwrap_or_default();
let mut recipients = vec![owner_macro_id.to_string()];