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(teams): remind invitees of unanswered team invites (#8597)

Jacob Beckerman55c4170e3d92
diff --git a/.sqlx/query-24fac9cdfa3f780c4ca0454b7ac500ea58384a4e6fd0ae0ca389f61550d3aabb.json b/.sqlx/query-24fac9cdfa3f780c4ca0454b7ac500ea58384a4e6fd0ae0ca389f61550d3aabb.json
new file mode 100644
index 0000000000..739ea60507
--- /dev/null
+++ b/.sqlx/query-24fac9cdfa3f780c4ca0454b7ac500ea58384a4e6fd0ae0ca389f61550d3aabb.json
@@ -0,0 +1,70 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n WITH due AS (\n SELECT ti.id\n FROM team_invite ti\n JOIN team t ON t.id = ti.team_id\n WHERE ti.created_at > NOW() - INTERVAL '14 days'\n AND (\n (ti.reminders_sent = 0 AND ti.last_sent_at <= NOW() - INTERVAL '3 days')\n OR (ti.reminders_sent = 1 AND ti.last_sent_at <= NOW() - INTERVAL '4 days')\n )\n AND (t.enterprise OR t.paying OR t.subscription_id IS NULL)\n AND EXISTS (\n SELECT 1 FROM team_user tu\n WHERE tu.team_id = ti.team_id AND tu.user_id = ti.invited_by\n )\n AND NOT EXISTS (\n SELECT 1 FROM team_user tu\n WHERE tu.team_id = ti.team_id AND tu.user_id = 'macro|' || ti.email\n )\n ORDER BY ti.created_at\n LIMIT $1\n FOR UPDATE OF ti SKIP LOCKED\n )\n UPDATE team_invite ti\n SET reminders_sent = ti.reminders_sent + 1,\n last_sent_at = NOW()\n FROM due, team t\n WHERE ti.id = due.id AND t.id = ti.team_id\n RETURNING\n ti.id,\n ti.team_id,\n t.name AS team_name,\n ti.email,\n ti.invited_by,\n ti.reminders_sent,\n t.enterprise,\n t.paying,\n t.subscription_id IS NOT NULL AS \"has_subscription!\"\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 1,
+ "name": "team_id",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 2,
+ "name": "team_name",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 3,
+ "name": "email",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 4,
+ "name": "invited_by",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 5,
+ "name": "reminders_sent",
+ "type_info": "Int2"
+ },
+ {
+ "ordinal": 6,
+ "name": "enterprise",
+ "type_info": "Bool"
+ },
+ {
+ "ordinal": 7,
+ "name": "paying",
+ "type_info": "Bool"
+ },
+ {
+ "ordinal": 8,
+ "name": "has_subscription!",
+ "type_info": "Bool"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Int8"
+ ]
+ },
+ "nullable": [
+ false,
+ false,
+ false,
+ false,
+ false,
+ false,
+ false,
+ false,
+ null
+ ]
+ },
+ "hash": "24fac9cdfa3f780c4ca0454b7ac500ea58384a4e6fd0ae0ca389f61550d3aabb"
+}
diff --git a/apps/web/src/lib/service-clients/service-notification/generated/schemas/inviteToTeamMetadata.ts b/apps/web/src/lib/service-clients/service-notification/generated/schemas/inviteToTeamMetadata.ts
index aa82dff23b..5b1c0a73c3 100644
--- a/apps/web/src/lib/service-clients/service-notification/generated/schemas/inviteToTeamMetadata.ts
+++ b/apps/web/src/lib/service-clients/service-notification/generated/schemas/inviteToTeamMetadata.ts
@@ -16,6 +16,8 @@ export interface InviteToTeamMetadata {
invitedBy: string;
/** What the invitee gets by joining, as the team stood when the invite was sent. */
inviteePlan?: InviteePlan;
+ /** Whether this email reminds the invitee of an invite they have not answered. */
+ reminder?: boolean;
/** Role/permission level in the team */
role?: InviteToTeamMetadataRole;
/** The sender's profile picture URL, if available. */
diff --git a/apps/web/src/lib/service-clients/service-notification/generated/zod.ts b/apps/web/src/lib/service-clients/service-notification/generated/zod.ts
index 88b1fb0626..28877e4886 100644
--- a/apps/web/src/lib/service-clients/service-notification/generated/zod.ts
+++ b/apps/web/src/lib/service-clients/service-notification/generated/zod.ts
@@ -967,6 +967,12 @@ export const listTypedNotificationsResponse = zod
.enum(['free', 'premium'])
.optional()
.describe('What a team invitee gets by joining.'),
+ reminder: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Whether this email reminds the invitee of an invite they have not answered.'
+ ),
role: zod
.string()
.nullish()
@@ -2963,6 +2969,12 @@ export const bulkGetTypedNotificationsByEventItemIdsResponse = zod
.enum(['free', 'premium'])
.optional()
.describe('What a team invitee gets by joining.'),
+ reminder: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Whether this email reminds the invitee of an invite they have not answered.'
+ ),
role: zod
.string()
.nullish()
@@ -4953,6 +4965,12 @@ export const getTypedNotificationsByEventItemIdResponse = zod
.enum(['free', 'premium'])
.optional()
.describe('What a team invitee gets by joining.'),
+ reminder: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Whether this email reminds the invitee of an invite they have not answered.'
+ ),
role: zod
.string()
.nullish()
@@ -6882,6 +6900,12 @@ export const getTypedNotificationByIdResponse = zod
.enum(['free', 'premium'])
.optional()
.describe('What a team invitee gets by joining.'),
+ reminder: zod
+ .boolean()
+ .optional()
+ .describe(
+ 'Whether this email reminds the invitee of an invite they have not answered.'
+ ),
role: zod
.string()
.nullish()
diff --git a/apps/web/src/lib/service-clients/service-notification/openapi.json b/apps/web/src/lib/service-clients/service-notification/openapi.json
index 8499efa7db..e55047f29a 100644
--- a/apps/web/src/lib/service-clients/service-notification/openapi.json
+++ b/apps/web/src/lib/service-clients/service-notification/openapi.json
@@ -2291,6 +2291,10 @@
"$ref": "#/components/schemas/InviteePlan",
"description": "What the invitee gets by joining, as the team stood when the invite was sent."
},
+ "reminder": {
+ "type": "boolean",
+ "description": "Whether this email reminds the invitee of an invite they have not answered."
+ },
"role": {
"type": ["string", "null"],
"description": "Role/permission level in the team"
diff --git a/crates/agent_code_mode/src/domain/documentation.json b/crates/agent_code_mode/src/domain/documentation.json
index c8f7c240a5..a8b790472f 100644
--- a/crates/agent_code_mode/src/domain/documentation.json
+++ b/crates/agent_code_mode/src/domain/documentation.json
@@ -129,7 +129,7 @@
"name": "notifications",
"description": "Read and manage notifications.",
"overview": "<!-- src/entities/notifications/namespace/classes/NotificationNamespace.md -->\n# Class: NotificationNamespace\n\n## Constructors\n\n### Constructor\n\n> **new NotificationNamespace**(`client`): `NotificationNamespace`\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `client` | `MacroClient` |\n\n#### Returns\n\n`NotificationNamespace`\n\n## Methods\n\n### byId()\n\n> **byId**(`id`): [`Notification`](../../notification/classes/Notification.md)\n\nA handle to a notification by id.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `id` | `string` |\n\n#### Returns\n\n[`Notification`](../../notification/classes/Notification.md)\n\n***\n\n### delete()\n\n> **delete**(`ids`): `Promise`\\<`void`\\>\n\nDelete a batch of notifications.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `ids` | `string`[] |\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### disableType()\n\n> **disableType**(`type`): `Promise`\\<`void`\\>\n\nDisable delivery of a notification type.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `type` | `\"reminder\"` \\| `\"channel_mention\"` \\| `\"document_mention\"` \\| `\"mentioned_in_document_comment\"` \\| `\"replied_to_document_comment_thread\"` \\| `\"commented_on_document\"` \\| `\"entity_access_requested\"` \\| `\"entity_access_granted\"` \\| `\"initiative_discussion\"` \\| `\"crm_discussion\"` \\| `\"channel_invite\"` \\| `\"channel_message_send\"` \\| `\"channel_message_reply\"` \\| `\"call_started\"` \\| `\"new_email\"` \\| `\"inbox_reauth_required\"` \\| `\"invite_to_team\"` \\| `\"task_assigned\"` \\| `\"calendar_event_reminder\"` \\| `\"ai_response\"` \\| `\"github_pr_status_changed\"` \\| `\"github_pr_check_run\"` \\| `\"github_review_requested\"` \\| `\"github_pr_comment\"` \\| `\"github_pr_mention\"` \\| `\"github_pr_review\"` \\| `\"agent_session_settled\"` \\| `\"agent_session_waiting_for_input\"` \\| `\"agent_session_mentioned\"` \\| `\"channel_message_reaction\"` \\| `\"calendar_event_join_request\"` |\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### enableType()\n\n> **enableType**(`type`): `Promise`\\<`void`\\>\n\nRe-enable delivery of a notification type.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `type` | `\"reminder\"` \\| `\"channel_mention\"` \\| `\"document_mention\"` \\| `\"mentioned_in_document_comment\"` \\| `\"replied_to_document_comment_thread\"` \\| `\"commented_on_document\"` \\| `\"entity_access_requested\"` \\| `\"entity_access_granted\"` \\| `\"initiative_discussion\"` \\| `\"crm_discussion\"` \\| `\"channel_invite\"` \\| `\"channel_message_send\"` \\| `\"channel_message_reply\"` \\| `\"call_started\"` \\| `\"new_email\"` \\| `\"inbox_reauth_required\"` \\| `\"invite_to_team\"` \\| `\"task_assigned\"` \\| `\"calendar_event_reminder\"` \\| `\"ai_response\"` \\| `\"github_pr_status_changed\"` \\| `\"github_pr_check_run\"` \\| `\"github_review_requested\"` \\| `\"github_pr_comment\"` \\| `\"github_pr_mention\"` \\| `\"github_pr_review\"` \\| `\"agent_session_settled\"` \\| `\"agent_session_waiting_for_input\"` \\| `\"agent_session_mentioned\"` \\| `\"channel_message_reaction\"` \\| `\"calendar_event_join_request\"` |\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### list()\n\n> **list**(`opts?`): `AsyncGenerator`\\<[`Notification`](../../notification/classes/Notification.md)\\>\n\nThe viewer's notification feed, most recent first, auto-paginated.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `opts?` | \\{ `pageSize?`: `number`; \\} |\n| `opts.pageSize?` | `number` |\n\n#### Returns\n\n`AsyncGenerator`\\<[`Notification`](../../notification/classes/Notification.md)\\>\n\n***\n\n### markDone()\n\n> **markDone**(`ids`): `Promise`\\<`void`\\>\n\nMark a batch of notifications as done.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `ids` | `string`[] |\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### markSeen()\n\n> **markSeen**(`ids`): `Promise`\\<`void`\\>\n\nMark a batch of notifications as seen.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `ids` | `string`[] |\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### preferences()\n\n> **preferences**(): `Promise`\\<[`GetNotificationTypePreferencesResponse`](../../../../../generated/notification/types.gen/type-aliases/GetNotificationTypePreferencesResponse.md)\\>\n\nThe viewer's notification type preferences (disabled types).\n\n#### Returns\n\n`Promise`\\<[`GetNotificationTypePreferencesResponse`](../../../../../generated/notification/types.gen/type-aliases/GetNotificationTypePreferencesResponse.md)\\>\n\n\n<!-- src/entities/notifications/namespace/type-aliases/NotificationType.md -->\n# Type Alias: NotificationType\n\n> **NotificationType** = [`NotifEvent`](../../../../../generated/notification/types.gen/type-aliases/NotifEvent.md)\\[`\"tag\"`\\]\n\nA notification event type name, e.g. `channel_mention`.\n",
- "documentation": "# Macro SDK: notifications\n\nGenerated by TypeDoc. Paths below refer to the canonical Markdown hierarchy. Other entity handles are documented in their named section; request core for shared SDK helpers.\n\n<!-- generated/notification/types.gen/type-aliases/AgentSessionMentionedMetadata.md -->\n# Type Alias: AgentSessionMentionedMetadata\n\n> **AgentSessionMentionedMetadata** = [`AgentSessionNotificationRef`](AgentSessionNotificationRef.md) & \\{ `actionId`: `string`; `mentionedBy?`: `string` \\| `null`; \\}\n\nSomeone named the recipient in a prompt to an agent session.\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `actionId` | `string` | The action carrying the prompt. |\n| `mentionedBy?` | `string` \\| `null` | Who wrote the prompt, absent when a bot acted on nobody's behalf. |\n\n\n<!-- generated/notification/types.gen/type-aliases/AgentSessionNotificationRef.md -->\n# Type Alias: AgentSessionNotificationRef\n\n> **AgentSessionNotificationRef** = \\{ `announcementMessageId?`: `string` \\| `null`; `botId`: `string`; `botName`: `string`; `channelId?`: `string` \\| `null`; `parent?`: `null` \\| [`AgentSessionOriginParent`](AgentSessionOriginParent.md); `sessionId`: `string`; `sessionName`: `string`; `threadId?`: `string` \\| `null`; \\}\n\nFlattened into each agent-session kind so the wire keeps these keys at the\ntop level of the metadata, the way [`CommonChannelMetadata`] does.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-announcementmessageid\"></a> `announcementMessageId?` | `string` \\| `null` | The magic-chip message for the turn in question, when one was posted. |\n| <a id=\"property-botid\"></a> `botId` | `string` | The bot the session runs for. A string on the wire: system bots have fixed ids like `00000000-0000-0000-0000-00000000a2a2`, which are not RFC 4122 uuids and fail a `format: uuid` check on the client. |\n| <a id=\"property-botname\"></a> `botName` | `string` | The bot's display name; agent notifications have no user sender, so this is who they read as being from. |\n| <a id=\"property-channelid\"></a> `channelId?` | `string` \\| `null` | The channel the session was opened from, when it was opened from a channel thread. |\n| <a id=\"property-parent\"></a> `parent?` | `null` \\| [`AgentSessionOriginParent`](AgentSessionOriginParent.md) | - |\n| <a id=\"property-sessionid\"></a> `sessionId` | `string` | The session; what a click opens. |\n| <a id=\"property-sessionname\"></a> `sessionName` | `string` | The session's name at the time of the event. |\n| <a id=\"property-threadid\"></a> `threadId?` | `string` \\| `null` | The thread the session was opened from, when it was. |\n\n\n<!-- generated/notification/types.gen/type-aliases/AgentSessionOriginParent.md -->\n# Type Alias: AgentSessionOriginParent\n\n> **AgentSessionOriginParent** = \\{ `id`: `string`; `type`: `string`; \\}\n\nThe session an agent-session notification is about, and where its magic\nchip lives when it was opened from a thread.\n\nThe conversation an agent session was opened from: a channel, document,\nor initiative. Spelled like the message API's parent for client routing.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-id\"></a> `id` | `string` | The parent entity id. |\n| <a id=\"property-type\"></a> `type` | `string` | `channel`, `document`, or `initiative`. |\n\n\n<!-- generated/notification/types.gen/type-aliases/AgentSessionSettledMetadata.md -->\n# Type Alias: AgentSessionSettledMetadata\n\n> **AgentSessionSettledMetadata** = [`AgentSessionNotificationRef`](AgentSessionNotificationRef.md) & \\{ `actor?`: `string` \\| `null`; `excerpt?`: `string` \\| `null`; `stopReason`: `string`; `turn`: `number`; \\}\n\nAn agent finished a turn with nothing queued behind it.\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `actor?` | `string` \\| `null` | Who prompted the turn, absent when a bot acted on nobody's behalf. |\n| `excerpt?` | `string` \\| `null` | The agent's last prose in the turn, whole; `None` when it wrote none. |\n| `stopReason` | `string` | The ACP stop reason, or `error`. |\n| `turn` | `number` | The turn that ended. |\n\n\n<!-- generated/notification/types.gen/type-aliases/AgentSessionWaitingForInputMetadata.md -->\n# Type Alias: AgentSessionWaitingForInputMetadata\n\n> **AgentSessionWaitingForInputMetadata** = [`AgentSessionNotificationRef`](AgentSessionNotificationRef.md) & \\{ `question`: `string`; `turn`: `number`; \\}\n\nAn agent is blocked on a question only the session's owner can answer.\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `question` | `string` | The question, as the agent phrased it. |\n| `turn` | `number` | The turn asking. |\n\n\n<!-- generated/notification/types.gen/type-aliases/AiResponseMetadata.md -->\n# Type Alias: AiResponseMetadata\n\n> **AiResponseMetadata** = \\{ `messageId`: `string`; `summary`: `string`; \\}\n\n## Properties\n\n| Property | Type |\n| ------ | ------ |\n| <a id=\"property-messageid\"></a> `messageId` | `string` |\n| <a id=\"property-summary\"></a> `summary` | `string` |\n\n\n<!-- generated/notification/types.gen/type-aliases/ApiUserNotification.md -->\n# Type Alias: ApiUserNotification\n\n> **ApiUserNotification** = [`Entity`](Entity.md) & \\{ `created_at`: `string`; `deleted_at?`: `string` \\| `null`; `id`: `string`; `notification_event_type`: `string`; `notification_metadata`: [`NotifEvent`](NotifEvent.md); `owner_id`: `string`; `sender_id?`: `string` \\| `null`; `sent`: `boolean`; `state`: [`NotificationState`](NotificationState.md); `updated_at`: `string`; `viewed_at?`: `string` \\| `null`; \\}\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `created_at` | `string` | When the notification was created. |\n| `deleted_at?` | `string` \\| `null` | When the notification was deleted. |\n| `id` | `string` | The notification ID. |\n| `notification_event_type` | `string` | The notification event type string (e.g. \"channel_mention\"). TODO make this a new type |\n| `notification_metadata` | [`NotifEvent`](NotifEvent.md) | Deserialized notification metadata. |\n| `owner_id` | `string` | The user who owns this notification. |\n| `sender_id?` | `string` \\| `null` | The user who triggered the notification. |\n| `sent` | `boolean` | Whether the notification has been sent. |\n| `state` | [`NotificationState`](NotificationState.md) | The authoritative notification lifecycle state. |\n| `updated_at` | `string` | When the notification was last updated. |\n| `viewed_at?` | `string` \\| `null` | When the notification was viewed/seen. |\n\n\n<!-- generated/notification/types.gen/type-aliases/CalendarEventJoinRequestMetadata.md -->\n# Type Alias: CalendarEventJoinRequestMetadata\n\n> **CalendarEventJoinRequestMetadata** = \\{ `eventId`: `string`; `requestId`: `string`; `title`: `string`; \\}\n\nA channel member who sees a calendar event only through a channel share\nasked the person who shared it to add them as a guest. Sent to the sharer,\nwith the requester as sender.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-eventid\"></a> `eventId` | `string` | The shared calendar event entity the request is for. |\n| <a id=\"property-requestid\"></a> `requestId` | `string` | Stable request identity, answered from the event's details. |\n| <a id=\"property-title\"></a> `title` | `string` | Event title when the request was made. |\n\n\n<!-- generated/notification/types.gen/type-aliases/CalendarEventReminderMetadata.md -->\n# Type Alias: CalendarEventReminderMetadata\n\n> **CalendarEventReminderMetadata** = \\{ `endsAt?`: `string` \\| `null`; `eventId`: `string`; `minutesBefore`: `number`; `occurrenceKey`: `string`; `startDate?`: `string` \\| `null`; `startsAt?`: `string` \\| `null`; `timeZone?`: `string` \\| `null`; `title`: `string`; \\}\n\nA calendar event alarm came due. Like [`ReminderMetadata`], these are\nself-notifications: `sender_id` must stay `None` or the only recipient is\nfiltered out. Everything the alert renders rides in here so the\ndispatcher never has to resolve the event again at display time.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-endsat\"></a> `endsAt?` | `string` \\| `null` | Instance end, for timed events. |\n| <a id=\"property-eventid\"></a> `eventId` | `string` | The calendar event entity the alarm belongs to. |\n| <a id=\"property-minutesbefore\"></a> `minutesBefore` | `number` | Minutes before the start the alarm was configured to fire. |\n| <a id=\"property-occurrencekey\"></a> `occurrenceKey` | `string` | Stable occurrence key of the instance that is starting. |\n| <a id=\"property-startdate\"></a> `startDate?` | `string` \\| `null` | Instance start date, for all-day events. |\n| <a id=\"property-startsat\"></a> `startsAt?` | `string` \\| `null` | Instance start, for timed events. |\n| <a id=\"property-timezone\"></a> `timeZone?` | `string` \\| `null` | IANA zone for rendering local clock times, when known. |\n| <a id=\"property-title\"></a> `title` | `string` | Event display title at dispatch time. |\n\n\n<!-- generated/notification/types.gen/type-aliases/CallStartedMetadata.md -->\n# Type Alias: CallStartedMetadata\n\n> **CallStartedMetadata** = \\{ `channel_name?`: `string` \\| `null`; `sender_profile_picture_url?`: `string` \\| `null`; \\}\n\nMetadata for a notification that a call has started in a channel.\n\nMirrors the producer-side `CallStartedNotification` in the `call` crate:\nboth serialize the same wire shape (snake_case fields) under the same\n`call_started` [`Notification::TYPE_NAME`]. This type is the read-side\nmodel used by [`crate::NotifEvent`]; the producer keeps its own type\nbecause it additionally builds the incoming-call APNS/VoIP push.\n\nRows persisted before the type name was normalized used the kebab-case\n`call-started`; the [`crate::NotifEvent::CallStarted`] variant carries a\n`#[serde(alias = \"call-started\")]` so those rows still deserialize.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-channel_name\"></a> `channel_name?` | `string` \\| `null` | The name of the channel the call started in, when available. |\n| <a id=\"property-sender_profile_picture_url\"></a> `sender_profile_picture_url?` | `string` \\| `null` | Profile picture URL of the user who started the call, when available. |\n\n\n<!-- generated/notification/types.gen/type-aliases/ChannelInviteMetadata.md -->\n# Type Alias: ChannelInviteMetadata\n\n> **ChannelInviteMetadata** = \\{ `channelName?`: `string`; `invitedBy`: `string`; `isDirectMessage?`: `boolean`; `messageContent?`: `string` \\| `null`; `senderProfilePictureUrl?`: `string` \\| `null`; \\}\n\nMetadata for when a user is invited to a channel.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-channelname\"></a> `channelName?` | `string` | The name of the channel |\n| <a id=\"property-invitedby\"></a> `invitedBy` | `string` | The user who sent the invitation |\n| <a id=\"property-isdirectmessage\"></a> `isDirectMessage?` | `boolean` | Whether this is a direct message rather than a channel invitation. Older notification payloads retain channel-invitation wording. |\n| <a id=\"property-messagecontent\"></a> `messageContent?` | `string` \\| `null` | Message content to show in the invite email, when the invite was triggered by a message. |\n| <a id=\"property-senderprofilepictureurl\"></a> `senderProfilePictureUrl?` | `string` \\| `null` | The sender's profile picture URL, if available. |\n\n\n<!-- generated/notification/types.gen/type-aliases/ChannelMentionMetadata.md -->\n# Type Alias: ChannelMentionMetadata\n\n> **ChannelMentionMetadata** = [`CommonChannelMetadata`](CommonChannelMetadata.md) & \\{ `messageContent`: `string`; `messageId`: `string`; `senderDisplayName?`: `string` \\| `null`; `senderProfilePictureUrl?`: `string` \\| `null`; `threadId?`: `string` \\| `null`; \\}\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `messageContent` | `string` | The message content |\n| `messageId` | `string` | The message you were mentioned in |\n| `senderDisplayName?` | `string` \\| `null` | Display name for non-user senders such as bots |\n| `senderProfilePictureUrl?` | `string` \\| `null` | - |\n| `threadId?` | `string` \\| `null` | the id of the thread |\n\n\n<!-- generated/notification/types.gen/type-aliases/ChannelMessageReactionMetadata.md -->\n# Type Alias: ChannelMessageReactionMetadata\n\n> **ChannelMessageReactionMetadata** = [`CommonChannelMetadata`](CommonChannelMetadata.md) & \\{ `emoji`: `string`; `messageContent`: `string`; `messageId`: `string`; `senderProfilePictureUrl?`: `string` \\| `null`; `threadId?`: `string` \\| `null`; \\}\n\nMetadata for a reaction added to one of the recipient's channel messages.\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `emoji` | `string` | The emoji added by the reactor. |\n| `messageContent` | `string` | The reacted-to message content. |\n| `messageId` | `string` | The reacted-to message id. |\n| `senderProfilePictureUrl?` | `string` \\| `null` | Optional reactor profile picture URL. |\n| `threadId?` | `string` \\| `null` | The thread root id when the reacted-to message is a reply. |\n\n\n<!-- generated/notification/types.gen/type-aliases/ChannelMessageSendMetadata.md -->\n# Type Alias: ChannelMessageSendMetadata\n\n> **ChannelMessageSendMetadata** = [`CommonChannelMetadata`](CommonChannelMetadata.md) & \\{ `messageContent?`: `string`; `messageId`: `string`; `sender?`: `string` \\| `null`; `senderDisplayName?`: `string` \\| `null`; `senderProfilePictureUrl?`: `string` \\| `null`; \\}\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `messageContent?` | `string` | The content of the message |\n| `messageId` | `string` | The message id |\n| `sender?` | `string` \\| `null` | The user who sent the message, when sent by a user |\n| `senderDisplayName?` | `string` \\| `null` | Display name for non-user senders such as bots |\n| `senderProfilePictureUrl?` | `string` \\| `null` | - |\n\n\n<!-- generated/notification/types.gen/type-aliases/ChannelReplyMetadata.md -->\n# Type Alias: ChannelReplyMetadata\n\n> **ChannelReplyMetadata** = [`CommonChannelMetadata`](CommonChannelMetadata.md) & \\{ `messageContent`: `string`; `messageId`: `string`; `senderDisplayName?`: `string` \\| `null`; `senderProfilePictureUrl?`: `string` \\| `null`; `threadId`: `string`; `threadParentSenderId?`: `string` \\| `null`; `userId?`: `string` \\| `null`; \\}\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `messageContent` | `string` | The message content |\n| `messageId` | `string` | The id of the new message |\n| `senderDisplayName?` | `string` \\| `null` | Display name for non-user senders such as bots |\n| `senderProfilePictureUrl?` | `string` \\| `null` | - |\n| `threadId` | `string` | The id of the thread that has the reply |\n| `threadParentSenderId?` | `string` \\| `null` | The user who sent the root message of the thread |\n| `userId?` | `string` \\| `null` | The sender id of the reply, when sent by a user |\n\n\n<!-- generated/notification/types.gen/type-aliases/ChannelType.md -->\n# Type Alias: ChannelType\n\n> **ChannelType** = `\"public\"` \\| `\"private\"` \\| `\"directMessage\"` \\| `\"team\"`\n\n\n<!-- generated/notification/types.gen/type-aliases/CommentRef.md -->\n# Type Alias: CommentRef\n\n> **CommentRef** = `number` \\| `string`\n\nIdentity of a document comment or its thread. Comments written before the\nshared message store carry the legacy numeric ids; comments in the shared\nstore carry the message and root UUIDs.\n\n\n<!-- generated/notification/types.gen/type-aliases/CommentedOnDocumentMetadata.md -->\n# Type Alias: CommentedOnDocumentMetadata\n\n> **CommentedOnDocumentMetadata** = \\{ `commentId`: [`CommentRef`](CommentRef.md); `documentName`: `string`; `fileType?`: `string` \\| `null`; `owner`: `string`; `senderDisplayName?`: `string` \\| `null`; `senderProfilePictureUrl?`: `string` \\| `null`; `subType?`: `null` \\| [`NotificationDocumentSubType`](NotificationDocumentSubType.md); `text`: `string`; `threadId`: [`CommentRef`](CommentRef.md); \\}\n\nNotification sent when someone comments on a document the user owns.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-commentid\"></a> `commentId` | [`CommentRef`](CommentRef.md) | the comment id |\n| <a id=\"property-documentname\"></a> `documentName` | `string` | The name of the document. |\n| <a id=\"property-filetype\"></a> `fileType?` | `string` \\| `null` | The file type of the document. |\n| <a id=\"property-owner\"></a> `owner` | `string` | The owner of the document. |\n| <a id=\"property-senderdisplayname\"></a> `senderDisplayName?` | `string` \\| `null` | Public bot name when the author is an agent rather than a Macro user. |\n| <a id=\"property-senderprofilepictureurl\"></a> `senderProfilePictureUrl?` | `string` \\| `null` | - |\n| <a id=\"property-subtype\"></a> `subType?` | `null` \\| [`NotificationDocumentSubType`](NotificationDocumentSubType.md) | - |\n| <a id=\"property-text\"></a> `text` | `string` | the text of the comment |\n| <a id=\"property-threadid\"></a> `threadId` | [`CommentRef`](CommentRef.md) | the thread id |\n\n\n<!-- generated/notification/types.gen/type-aliases/CommonChannelMetadata.md -->\n# Type Alias: CommonChannelMetadata\n\n> **CommonChannelMetadata** = \\{ `channelName?`: `string`; `channelType`: [`ChannelType`](ChannelType.md); \\}\n\nCommon metadata for notifications on channels\n\n## Properties\n\n| Property | Type |\n| ------ | ------ |\n| <a id=\"property-channelname\"></a> `channelName?` | `string` |\n| <a id=\"property-channeltype\"></a> `channelType` | [`ChannelType`](ChannelType.md) |\n\n\n<!-- generated/notification/types.gen/type-aliases/CrmDiscussionMetadata.md -->\n# Type Alias: CrmDiscussionMetadata\n\n> **CrmDiscussionMetadata** = \\{ `messageId`: `string`; `reason`: [`CrmDiscussionReason`](CrmDiscussionReason.md); `recordName`: `string`; `senderDisplayName?`: `string` \\| `null`; `senderProfilePictureUrl?`: `string` \\| `null`; `text`: `string`; `threadId`: `string`; \\}\n\nCRM discussion metadata. The notification entity identifies the company or\ncontact; message and thread UUIDs select the discussion inside it.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-messageid\"></a> `messageId` | `string` | Canonical shared message UUID. |\n| <a id=\"property-reason\"></a> `reason` | [`CrmDiscussionReason`](CrmDiscussionReason.md) | Semantic reason selected by the message delivery domain. |\n| <a id=\"property-recordname\"></a> `recordName` | `string` | Company or contact display name. |\n| <a id=\"property-senderdisplayname\"></a> `senderDisplayName?` | `string` \\| `null` | Public display name for a bot author. |\n| <a id=\"property-senderprofilepictureurl\"></a> `senderProfilePictureUrl?` | `string` \\| `null` | Optional avatar for push notification attachments. |\n| <a id=\"property-text\"></a> `text` | `string` | Posted Markdown content. |\n| <a id=\"property-threadid\"></a> `threadId` | `string` | Canonical discussion root UUID. |\n\n\n<!-- generated/notification/types.gen/type-aliases/CrmDiscussionReason.md -->\n# Type Alias: CrmDiscussionReason\n\n> **CrmDiscussionReason** = `\"mention\"` \\| `\"reply\"` \\| `\"owner\"`\n\nWhy a CRM discussion notification was delivered.\n\n\n<!-- generated/notification/types.gen/type-aliases/DocumentMentionMetadata.md -->\n# Type Alias: DocumentMentionMetadata\n\n> **DocumentMentionMetadata** = [`ChannelMentionMetadata`](ChannelMentionMetadata.md) & \\{ `documentName`: `string`; `fileType?`: `string` \\| `null`; `owner`: `string`; `subType?`: `null` \\| [`NotificationDocumentSubType`](NotificationDocumentSubType.md); \\}\n\nSomeone mentioned a document in a channel\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `documentName` | `string` | The name of the document |\n| `fileType?` | `string` \\| `null` | The file type of the document |\n| `owner` | `string` | The owner of the document |\n| `subType?` | `null` \\| [`NotificationDocumentSubType`](NotificationDocumentSubType.md) | - |\n\n\n<!-- generated/notification/types.gen/type-aliases/Entity.md -->\n# Type Alias: Entity\n\n> **Entity** = \\{ `entity_id`: `string`; `entity_type`: [`EntityType`](EntityType.md); \\}\n\nThe Entity describes the minimum amount of information required to describe a unique thing in Macro\nThis contains the type of the entity [EntityType] and the string id of that entity\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-entity_id\"></a> `entity_id` | `string` | The id of that entity |\n| <a id=\"property-entity_type\"></a> `entity_type` | [`EntityType`](EntityType.md) | The type of entity we are describing |\n\n\n<!-- generated/notification/types.gen/type-aliases/EntityAccessGrantedMetadata.md -->\n# Type Alias: EntityAccessGrantedMetadata\n\n> **EntityAccessGrantedMetadata** = \\{ `accessLevel`: [`RequestedAccessLevel`](RequestedAccessLevel.md); `entityName`: `string`; `fileType?`: `string` \\| `null`; `requestId`: `string`; `revision`: `number`; \\}\n\nA person granted you access to a shared entity.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-accesslevel\"></a> `accessLevel` | [`RequestedAccessLevel`](RequestedAccessLevel.md) | Requested or granted permission. |\n| <a id=\"property-entityname\"></a> `entityName` | `string` | Shared item's name. |\n| <a id=\"property-filetype\"></a> `fileType?` | `string` \\| `null` | Document file type for routing. |\n| <a id=\"property-requestid\"></a> `requestId` | `string` | Stable request identity. |\n| <a id=\"property-revision\"></a> `revision` | `number` | Revision that generated this notification. |\n\n\n<!-- generated/notification/types.gen/type-aliases/EntityAccessRequestedMetadata.md -->\n# Type Alias: EntityAccessRequestedMetadata\n\n> **EntityAccessRequestedMetadata** = \\{ `accessLevel`: [`RequestedAccessLevel`](RequestedAccessLevel.md); `entityName`: `string`; `fileType?`: `string` \\| `null`; `requestId`: `string`; `revision`: `number`; \\}\n\nA person requested access to a shared entity.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-accesslevel\"></a> `accessLevel` | [`RequestedAccessLevel`](RequestedAccessLevel.md) | Requested or granted permission. |\n| <a id=\"property-entityname\"></a> `entityName` | `string` | Shared item's name. |\n| <a id=\"property-filetype\"></a> `fileType?` | `string` \\| `null` | Document file type for routing. |\n| <a id=\"property-requestid\"></a> `requestId` | `string` | Stable request identity. |\n| <a id=\"property-revision\"></a> `revision` | `number` | Revision that generated this notification. |\n\n\n<!-- generated/notification/types.gen/type-aliases/EntityType.md -->\n# Type Alias: EntityType\n\n> **EntityType** = `\"user\"` \\| `\"chat\"` \\| `\"channel\"` \\| `\"channel_message\"` \\| `\"document\"` \\| `\"project\"` \\| `\"email_thread\"` \\| `\"calendar_event\"` \\| `\"team\"` \\| `\"call\"` \\| `\"foreign_entity\"` \\| `\"static_file\"` \\| `\"crm_company\"` \\| `\"crm_contact\"` \\| `\"crm_pipeline\"` \\| `\"reminder\"` \\| `\"skill\"` \\| `\"agent_session\"` \\| `\"scheduled_action\"` \\| `\"initiative\"` \\| `\"database\"` \\| `\"database_row\"` \\| `\"form\"`\n\nThe type of an entity in Macro\n\n\n<!-- generated/notification/types.gen/type-aliases/GetNotificationTypePreferencesResponse.md -->\n# Type Alias: GetNotificationTypePreferencesResponse\n\n> **GetNotificationTypePreferencesResponse** = \\{ `disabled_types`: `string`[]; \\}\n\nResponse for listing disabled notification types.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-disabled_types\"></a> `disabled_types` | `string`[] | The notification types that the user has disabled. |\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrCheckRun.md -->\n# Type Alias: GithubPrCheckRun\n\n> **GithubPrCheckRun** = [`GithubPrNotificationCommon`](GithubPrNotificationCommon.md) & \\{ `checkName`: `string`; `checkRunGithubId`: `number`; `checkStatus`: `string`; `checkUrl`: `string`; `completedAt`: `string`; `conclusion`: `string`; `state`: [`GithubPrCheckRunState`](GithubPrCheckRunState.md); \\}\n\nMetadata for a notification that a GitHub pull request check run completed.\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `checkName` | `string` | The display name GitHub reported for the check run. |\n| `checkRunGithubId` | `number` | The GitHub numeric id of the check run. |\n| `checkStatus` | `string` | The raw GitHub check run status. |\n| `checkUrl` | `string` | The public GitHub URL for the check run. |\n| `completedAt` | `string` | When GitHub marked the check run as complete. |\n| `conclusion` | `string` | The raw GitHub check run conclusion. |\n| `state` | [`GithubPrCheckRunState`](GithubPrCheckRunState.md) | The normalized notification state for this check run. |\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrCheckRunState.md -->\n# Type Alias: GithubPrCheckRunState\n\n> **GithubPrCheckRunState** = `\"completed\"` \\| `\"failed\"`\n\nThe normalized result state for a GitHub pull request check-run notification.\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrComment.md -->\n# Type Alias: GithubPrComment\n\n> **GithubPrComment** = [`GithubPrNotificationCommon`](GithubPrNotificationCommon.md) & \\{ `commentGithubId?`: `number` \\| `null`; `commentKind`: [`GithubPrCommentKind`](GithubPrCommentKind.md); `commentSnippet`: `string`; `commentUrl?`: `string` \\| `null`; \\}\n\nMetadata for a notification that a GitHub pull request was commented on.\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `commentGithubId?` | `number` \\| `null` | The GitHub numeric id of the comment, when available. |\n| `commentKind` | [`GithubPrCommentKind`](GithubPrCommentKind.md) | The kind of comment that was posted. |\n| `commentSnippet` | `string` | A truncated excerpt of the comment body. |\n| `commentUrl?` | `string` \\| `null` | The public GitHub URL for the comment, when available. |\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrCommentKind.md -->\n# Type Alias: GithubPrCommentKind\n\n> **GithubPrCommentKind** = `\"issue\"` \\| `\"review_comment\"`\n\nThe kind of GitHub comment that triggered a [`GithubPrComment`] notification.\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrEventAction.md -->\n# Type Alias: GithubPrEventAction\n\n> **GithubPrEventAction** = `\"opened\"` \\| `\"reopened\"` \\| `\"closed\"`\n\nThe GitHub pull request webhook action that triggered the notification.\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrEventStatus.md -->\n# Type Alias: GithubPrEventStatus\n\n> **GithubPrEventStatus** = `\"open\"` \\| `\"closed\"` \\| `\"merged\"`\n\nThe normalized lifecycle status for a GitHub pull request notification.\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrMention.md -->\n# Type Alias: GithubPrMention\n\n> **GithubPrMention** = [`GithubPrNotificationCommon`](GithubPrNotificationCommon.md) & \\{ `commentGithubId?`: `number` \\| `null`; `commentUrl?`: `string` \\| `null`; `location`: [`GithubPrMentionLocation`](GithubPrMentionLocation.md); `textSnippet`: `string`; \\}\n\nMetadata for a notification that the user was mentioned on a GitHub pull request.\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `commentGithubId?` | `number` \\| `null` | The GitHub numeric id of the comment or review containing the mention, when available. |\n| `commentUrl?` | `string` \\| `null` | The public GitHub URL for the text containing the mention, when available. |\n| `location` | [`GithubPrMentionLocation`](GithubPrMentionLocation.md) | Where the mention appeared. |\n| `textSnippet` | `string` | A truncated excerpt of the text containing the mention. |\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrMentionLocation.md -->\n# Type Alias: GithubPrMentionLocation\n\n> **GithubPrMentionLocation** = `\"pr_body\"` \\| `\"comment\"` \\| `\"review\"` \\| `\"review_comment\"`\n\nWhere in a GitHub pull request the user was mentioned.\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrNotificationCommon.md -->\n# Type Alias: GithubPrNotificationCommon\n\n> **GithubPrNotificationCommon** = \\{ `displayName`: `string`; `foreignEntityId`: `string`; `githubKey`: `string`; `number`: `number`; `owner`: `string`; `repo`: `string`; `senderGithubAvatarUrl?`: `string` \\| `null`; `senderGithubLogin?`: `string` \\| `null`; `senderGithubUserId?`: `string` \\| `null`; `title`: `string`; `url`: `string`; \\}\n\nFields shared by every GitHub pull request notification type.\n\nEmbedded with `#[serde(flatten)]` so the wire shape keeps these keys at the\ntop level of the metadata object.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-displayname\"></a> `displayName` | `string` | A compact label suitable for display in the UI. |\n| <a id=\"property-foreignentityid\"></a> `foreignEntityId` | `string` | The source-specific internal foreign entity row id for this pull request. |\n| <a id=\"property-githubkey\"></a> `githubKey` | `string` | The external GitHub key, in `owner/repo/pull/number` format. |\n| <a id=\"property-number\"></a> `number` | `number` | The GitHub pull request number. |\n| <a id=\"property-owner\"></a> `owner` | `string` | The GitHub repository owner or organization. |\n| <a id=\"property-repo\"></a> `repo` | `string` | The GitHub repository name. |\n| <a id=\"property-sendergithubavatarurl\"></a> `senderGithubAvatarUrl?` | `string` \\| `null` | The GitHub avatar URL for the sender, when available. |\n| <a id=\"property-sendergithublogin\"></a> `senderGithubLogin?` | `string` \\| `null` | The GitHub login for the sender, when available. |\n| <a id=\"property-sendergithubuserid\"></a> `senderGithubUserId?` | `string` \\| `null` | The stable GitHub numeric user id for the sender, serialized as a string. |\n| <a id=\"property-title\"></a> `title` | `string` | The GitHub pull request title. Falls back to `display_name` when GitHub has no title. |\n| <a id=\"property-url\"></a> `url` | `string` | The public GitHub URL for the pull request. |\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrReview.md -->\n# Type Alias: GithubPrReview\n\n> **GithubPrReview** = [`GithubPrNotificationCommon`](GithubPrNotificationCommon.md) & \\{ `reviewGithubId?`: `number` \\| `null`; `reviewSnippet?`: `string` \\| `null`; `reviewUrl?`: `string` \\| `null`; `state`: [`GithubPrReviewState`](GithubPrReviewState.md); \\}\n\nMetadata for a notification that a review was submitted on the user's GitHub pull request.\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `reviewGithubId?` | `number` \\| `null` | The GitHub numeric id of the review, when available. |\n| `reviewSnippet?` | `string` \\| `null` | A truncated excerpt of the review body, when any was written. |\n| `reviewUrl?` | `string` \\| `null` | The public GitHub URL for the review, when available. |\n| `state` | [`GithubPrReviewState`](GithubPrReviewState.md) | The review decision state. |\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrReviewState.md -->\n# Type Alias: GithubPrReviewState\n\n> **GithubPrReviewState** = `\"approved\"` \\| `\"changes_requested\"` \\| `\"commented\"`\n\nThe state of a submitted GitHub pull request review.\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrStatusChanged.md -->\n# Type Alias: GithubPrStatusChanged\n\n> **GithubPrStatusChanged** = [`GithubPrNotificationCommon`](GithubPrNotificationCommon.md) & \\{ `action`: [`GithubPrEventAction`](GithubPrEventAction.md); `baseBranch?`: `string` \\| `null`; `headBranch?`: `string` \\| `null`; `mergedAt?`: `string` \\| `null`; `previousStatus?`: `null` \\| [`GithubPrEventStatus`](GithubPrEventStatus.md); `status`: [`GithubPrEventStatus`](GithubPrEventStatus.md); \\}\n\nMetadata for a GitHub pull request lifecycle notification.\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `action` | [`GithubPrEventAction`](GithubPrEventAction.md) | The webhook action that triggered this notification. |\n| `baseBranch?` | `string` \\| `null` | The pull request base branch, when available. |\n| `headBranch?` | `string` \\| `null` | The pull request head branch, when available. |\n| `mergedAt?` | `string` \\| `null` | When the pull request was merged, when available. |\n| `previousStatus?` | `null` \\| [`GithubPrEventStatus`](GithubPrEventStatus.md) | - |\n| `status` | [`GithubPrEventStatus`](GithubPrEventStatus.md) | The current normalized pull request status. |\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubReviewRequested.md -->\n# Type Alias: GithubReviewRequested\n\n> **GithubReviewRequested** = [`GithubPrNotificationCommon`](GithubPrNotificationCommon.md) & \\{ `requestedReviewerGithubLogin?`: `string` \\| `null`; `requestedReviewerGithubUserId?`: `string` \\| `null`; \\}\n\nMetadata for a notification that the user's review was requested on a GitHub pull request.\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `requestedReviewerGithubLogin?` | `string` \\| `null` | The GitHub login of the requested reviewer, when available. |\n| `requestedReviewerGithubUserId?` | `string` \\| `null` | The stable GitHub numeric user id of the requested reviewer, serialized as a string. |\n\n\n<!-- generated/notification/types.gen/type-aliases/InboxReauthRequiredMetadata.md -->\n# Type Alias: InboxReauthRequiredMetadata\n\n> **InboxReauthRequiredMetadata** = \\{ `emailAddress`: `string`; \\}\n\nMetadata for a notification that a linked inbox's grant has died and the\ninbox must be reconnected. Fanned out to the inbox owner and every delegate,\nsince any of them holding the Google grant can restore sync.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-emailaddress\"></a> `emailAddress` | `string` | The address of the inbox that needs to be reconnected. |\n\n\n<!-- generated/notification/types.gen/type-aliases/InitiativeDiscussionMetadata.md -->\n# Type Alias: InitiativeDiscussionMetadata\n\n> **InitiativeDiscussionMetadata** = \\{ `messageId`: `string`; `owner`: `string`; `projectName`: `string`; `reason`: [`InitiativeDiscussionReason`](InitiativeDiscussionReason.md); `senderDisplayName?`: `string` \\| `null`; `senderProfilePictureUrl?`: `string` \\| `null`; `text`: `string`; `threadId`: `string`; \\}\n\nProject discussion metadata. The notification entity identifies the initiative;\nmessage and thread UUIDs select the discussion inside that project.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-messageid\"></a> `messageId` | `string` | Canonical shared message UUID. |\n| <a id=\"property-owner\"></a> `owner` | `string` | Authenticated project owner. |\n| <a id=\"property-projectname\"></a> `projectName` | `string` | Name displayed in the project header. |\n| <a id=\"property-reason\"></a> `reason` | [`InitiativeDiscussionReason`](InitiativeDiscussionReason.md) | Semantic reason selected by the message delivery domain. |\n| <a id=\"property-senderdisplayname\"></a> `senderDisplayName?` | `string` \\| `null` | Public display name for a bot author. |\n| <a id=\"property-senderprofilepictureurl\"></a> `senderProfilePictureUrl?` | `string` \\| `null` | Optional avatar for push notification attachments. |\n| <a id=\"property-text\"></a> `text` | `string` | Posted Markdown content. |\n| <a id=\"property-threadid\"></a> `threadId` | `string` | Canonical discussion root UUID. |\n\n\n<!-- generated/notification/types.gen/type-aliases/InitiativeDiscussionReason.md -->\n# Type Alias: InitiativeDiscussionReason\n\n> **InitiativeDiscussionReason** = `\"mention\"` \\| `\"reply\"` \\| `\"assignee\"` \\| `\"owner\"`\n\nWhy a project discussion notification was delivered.\n\n\n<!-- generated/notification/types.gen/type-aliases/InviteToTeamMetadata.md -->\n# Type Alias: InviteToTeamMetadata\n\n> **InviteToTeamMetadata** = \\{ `invitedBy`: `string`; `inviteePlan?`: [`InviteePlan`](InviteePlan.md); `role?`: `string` \\| `null`; `senderProfilePictureUrl?`: `string` \\| `null`; `teamId`: `string`; `teamInviteId`: `string`; `teamName`: `string`; \\}\n\nMetadata for when a user is invited to a team.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-invitedby\"></a> `invitedBy` | `string` | The user who sent the invitation |\n| <a id=\"property-inviteeplan\"></a> `inviteePlan?` | [`InviteePlan`](InviteePlan.md) | What the invitee gets by joining, as the team stood when the invite was sent. |\n| <a id=\"property-role\"></a> `role?` | `string` \\| `null` | Role/permission level in the team |\n| <a id=\"property-senderprofilepictureurl\"></a> `senderProfilePictureUrl?` | `string` \\| `null` | The sender's profile picture URL, if available. |\n| <a id=\"property-teamid\"></a> `teamId` | `string` | The unique identifier of the team |\n| <a id=\"property-teaminviteid\"></a> `teamInviteId` | `string` | The unique identifier of the team invite |\n| <a id=\"property-teamname\"></a> `teamName` | `string` | The name of the team being invited to |\n\n\n<!-- generated/notification/types.gen/type-aliases/InviteePlan.md -->\n# Type Alias: InviteePlan\n\n> **InviteePlan** = `\"free\"` \\| `\"premium\"`\n\nWhat a team invitee gets by joining.\n\n\n<!-- generated/notification/types.gen/type-aliases/MentionedInDocumentCommentMetadata.md -->\n# Type Alias: MentionedInDocumentCommentMetadata\n\n> **MentionedInDocumentCommentMetadata** = \\{ `commentId`: [`CommentRef`](CommentRef.md); `documentName`: `string`; `fileType?`: `string` \\| `null`; `mentionId`: `string`; `owner`: `string`; `senderDisplayName?`: `string` \\| `null`; `senderProfilePictureUrl?`: `string` \\| `null`; `subType?`: `null` \\| [`NotificationDocumentSubType`](NotificationDocumentSubType.md); `text`: `string`; `threadId`: [`CommentRef`](CommentRef.md); \\}\n\nNotification sent when a user is mentioned in a document comment.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-commentid\"></a> `commentId` | [`CommentRef`](CommentRef.md) | the comment id |\n| <a id=\"property-documentname\"></a> `documentName` | `string` | The name of the document. |\n| <a id=\"property-filetype\"></a> `fileType?` | `string` \\| `null` | The file type of the document. |\n| <a id=\"property-mentionid\"></a> `mentionId` | `string` | The mention ID. |\n| <a id=\"property-owner\"></a> `owner` | `string` | The owner of the document. |\n| <a id=\"property-senderdisplayname\"></a> `senderDisplayName?` | `string` \\| `null` | Public bot name when the author is an agent rather than a Macro user. |\n| <a id=\"property-senderprofilepictureurl\"></a> `senderProfilePictureUrl?` | `string` \\| `null` | - |\n| <a id=\"property-subtype\"></a> `subType?` | `null` \\| [`NotificationDocumentSubType`](NotificationDocumentSubType.md) | - |\n| <a id=\"property-text\"></a> `text` | `string` | the text of the comment |\n| <a id=\"property-threadid\"></a> `threadId` | [`CommentRef`](CommentRef.md) | the thread id |\n\n\n<!-- generated/notification/types.gen/type-aliases/NewEmailMetadata.md -->\n# Type Alias: NewEmailMetadata\n\n> **NewEmailMetadata** = \\{ `sender?`: `string` \\| `null`; `snippet`: `string`; `subject`: `string`; `threadId`: `string`; `toEmail`: `string`; \\}\n\n## Properties\n\n| Property | Type |\n| ------ | ------ |\n| <a id=\"property-sender\"></a> `sender?` | `string` \\| `null` |\n| <a id=\"property-snippet\"></a> `snippet` | `string` |\n| <a id=\"property-subject\"></a> `subject` | `string` |\n| <a id=\"property-threadid\"></a> `threadId` | `string` |\n| <a id=\"property-toemail\"></a> `toEmail` | `string` |\n\n\n<!-- generated/notification/types.gen/type-aliases/NotifEvent.md -->\n# Type Alias: NotifEvent\n\n> **NotifEvent** = \\{ `content`: [`ChannelMentionMetadata`](ChannelMentionMetadata.md); `tag`: `\"channel_mention\"`; \\} \\| \\{ `content`: [`DocumentMentionMetadata`](DocumentMentionMetadata.md); `tag`: `\"document_mention\"`; \\} \\| \\{ `content`: [`MentionedInDocumentCommentMetadata`](MentionedInDocumentCommentMetadata.md); `tag`: `\"mentioned_in_document_comment\"`; \\} \\| \\{ `content`: [`RepliedToDocumentCommentThreadMetadata`](RepliedToDocumentCommentThreadMetadata.md); `tag`: `\"replied_to_document_comment_thread\"`; \\} \\| \\{ `content`: [`CommentedOnDocumentMetadata`](CommentedOnDocumentMetadata.md); `tag`: `\"commented_on_document\"`; \\} \\| \\{ `content`: [`EntityAccessRequestedMetadata`](EntityAccessRequestedMetadata.md); `tag`: `\"entity_access_requested\"`; \\} \\| \\{ `content`: [`EntityAccessGrantedMetadata`](EntityAccessGrantedMetadata.md); `tag`: `\"entity_access_granted\"`; \\} \\| \\{ `content`: [`InitiativeDiscussionMetadata`](InitiativeDiscussionMetadata.md); `tag`: `\"initiative_discussion\"`; \\} \\| \\{ `content`: [`CrmDiscussionMetadata`](CrmDiscussionMetadata.md); `tag`: `\"crm_discussion\"`; \\} \\| \\{ `content`: [`ChannelInviteMetadata`](ChannelInviteMetadata.md); `tag`: `\"channel_invite\"`; \\} \\| \\{ `content`: [`ChannelMessageSendMetadata`](ChannelMessageSendMetadata.md); `tag`: `\"channel_message_send\"`; \\} \\| \\{ `content`: [`ChannelReplyMetadata`](ChannelReplyMetadata.md); `tag`: `\"channel_message_reply\"`; \\} \\| \\{ `content`: [`CallStartedMetadata`](CallStartedMetadata.md); `tag`: `\"call_started\"`; \\} \\| \\{ `content`: [`NewEmailMetadata`](NewEmailMetadata.md); `tag`: `\"new_email\"`; \\} \\| \\{ `content`: [`InboxReauthRequiredMetadata`](InboxReauthRequiredMetadata.md); `tag`: `\"inbox_reauth_required\"`; \\} \\| \\{ `content`: [`InviteToTeamMetadata`](InviteToTeamMetadata.md); `tag`: `\"invite_to_team\"`; \\} \\| \\{ `content`: [`TaskAssignedMetadata`](TaskAssignedMetadata.md); `tag`: `\"task_assigned\"`; \\} \\| \\{ `content`: [`ReminderMetadata`](ReminderMetadata.md); `tag`: `\"reminder\"`; \\} \\| \\{ `content`: [`CalendarEventReminderMetadata`](CalendarEventReminderMetadata.md); `tag`: `\"calendar_event_reminder\"`; \\} \\| \\{ `content`: [`AiResponseMetadata`](AiResponseMetadata.md); `tag`: `\"ai_response\"`; \\} \\| \\{ `content`: [`GithubPrStatusChanged`](GithubPrStatusChanged.md); `tag`: `\"github_pr_status_changed\"`; \\} \\| \\{ `content`: [`GithubPrCheckRun`](GithubPrCheckRun.md); `tag`: `\"github_pr_check_run\"`; \\} \\| \\{ `content`: [`GithubReviewRequested`](GithubReviewRequested.md); `tag`: `\"github_review_requested\"`; \\} \\| \\{ `content`: [`GithubPrComment`](GithubPrComment.md); `tag`: `\"github_pr_comment\"`; \\} \\| \\{ `content`: [`GithubPrMention`](GithubPrMention.md); `tag`: `\"github_pr_mention\"`; \\} \\| \\{ `content`: [`GithubPrReview`](GithubPrReview.md); `tag`: `\"github_pr_review\"`; \\} \\| \\{ `content`: [`AgentSessionSettledMetadata`](AgentSessionSettledMetadata.md); `tag`: `\"agent_session_settled\"`; \\} \\| \\{ `content`: [`AgentSessionWaitingForInputMetadata`](AgentSessionWaitingForInputMetadata.md); `tag`: `\"agent_session_waiting_for_input\"`; \\} \\| \\{ `content`: [`AgentSessionMentionedMetadata`](AgentSessionMentionedMetadata.md); `tag`: `\"agent_session_mentioned\"`; \\} \\| \\{ `content`: [`ChannelMessageReactionMetadata`](ChannelMessageReactionMetadata.md); `tag`: `\"channel_message_reaction\"`; \\} \\| \\{ `content`: [`CalendarEventJoinRequestMetadata`](CalendarEventJoinRequestMetadata.md); `tag`: `\"calendar_event_join_request\"`; \\}\n\nMirrors [`model_notifications::NotificationEvent`] but uses `tag` / `content`\nas the serde adjacently-tagged field names so it can be deserialized from the\nshape produced by [`UserNotificationRow::into_tagged`] +\n[`UserNotificationRow::into_json`].\n\nOnly includes variants whose metadata types implement the `Notification` trait.\n\n## Union Members\n\n### Type Literal\n\n\\{ `content`: [`ChannelMentionMetadata`](ChannelMentionMetadata.md); `tag`: `\"channel_mention\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`ChannelMentionMetadata`](ChannelMentionMetadata.md) | Someone mentioned you in a channel. |\n| `tag` | `\"channel_mention\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`DocumentMentionMetadata`](DocumentMentionMetadata.md); `tag`: `\"document_mention\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`DocumentMentionMetadata`](DocumentMentionMetadata.md) | Someone mentioned a document in a channel. |\n| `tag` | `\"document_mention\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`MentionedInDocumentCommentMetadata`](MentionedInDocumentCommentMetadata.md); `tag`: `\"mentioned_in_document_comment\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`MentionedInDocumentCommentMetadata`](MentionedInDocumentCommentMetadata.md) | User was mentioned in a comment in a document |\n| `tag` | `\"mentioned_in_document_comment\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`RepliedToDocumentCommentThreadMetadata`](RepliedToDocumentCommentThreadMetadata.md); `tag`: `\"replied_to_document_comment_thread\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`RepliedToDocumentCommentThreadMetadata`](RepliedToDocumentCommentThreadMetadata.md) | Someone replied to a document comment thread the user participated in. |\n| `tag` | `\"replied_to_document_comment_thread\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`CommentedOnDocumentMetadata`](CommentedOnDocumentMetadata.md); `tag`: `\"commented_on_document\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`CommentedOnDocumentMetadata`](CommentedOnDocumentMetadata.md) | Someone commented on a document the user owns. |\n| `tag` | `\"commented_on_document\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`EntityAccessRequestedMetadata`](EntityAccessRequestedMetadata.md); `tag`: `\"entity_access_requested\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`EntityAccessRequestedMetadata`](EntityAccessRequestedMetadata.md) | Someone requested more access to a shared entity. |\n| `tag` | `\"entity_access_requested\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`EntityAccessGrantedMetadata`](EntityAccessGrantedMetadata.md); `tag`: `\"entity_access_granted\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`EntityAccessGrantedMetadata`](EntityAccessGrantedMetadata.md) | An owner granted requested access. |\n| `tag` | `\"entity_access_granted\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`InitiativeDiscussionMetadata`](InitiativeDiscussionMetadata.md); `tag`: `\"initiative_discussion\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`InitiativeDiscussionMetadata`](InitiativeDiscussionMetadata.md) | Someone commented, replied, or mentioned the recipient on a project. |\n| `tag` | `\"initiative_discussion\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`CrmDiscussionMetadata`](CrmDiscussionMetadata.md); `tag`: `\"crm_discussion\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`CrmDiscussionMetadata`](CrmDiscussionMetadata.md) | Someone commented, replied, or mentioned the recipient on a CRM company or contact. |\n| `tag` | `\"crm_discussion\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`ChannelInviteMetadata`](ChannelInviteMetadata.md); `tag`: `\"channel_invite\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`ChannelInviteMetadata`](ChannelInviteMetadata.md) | The user was invited to a channel. |\n| `tag` | `\"channel_invite\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`ChannelMessageSendMetadata`](ChannelMessageSendMetadata.md); `tag`: `\"channel_message_send\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`ChannelMessageSendMetadata`](ChannelMessageSendMetadata.md) | A user sent a message in a channel. |\n| `tag` | `\"channel_message_send\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`ChannelReplyMetadata`](ChannelReplyMetadata.md); `tag`: `\"channel_message_reply\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`ChannelReplyMetadata`](ChannelReplyMetadata.md) | Someone replied to a thread in a channel that the user is part of. |\n| `tag` | `\"channel_message_reply\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`CallStartedMetadata`](CallStartedMetadata.md); `tag`: `\"call_started\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`CallStartedMetadata`](CallStartedMetadata.md) | A call has started in a channel the user is a member of. The `call-started` alias keeps rows persisted before the type name was normalized to snake_case (`call_started`) deserializable. |\n| `tag` | `\"call_started\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`NewEmailMetadata`](NewEmailMetadata.md); `tag`: `\"new_email\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`NewEmailMetadata`](NewEmailMetadata.md) | A new email has been sent to the user. |\n| `tag` | `\"new_email\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`InboxReauthRequiredMetadata`](InboxReauthRequiredMetadata.md); `tag`: `\"inbox_reauth_required\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`InboxReauthRequiredMetadata`](InboxReauthRequiredMetadata.md) | A linked inbox's grant died and must be reconnected. |\n| `tag` | `\"inbox_reauth_required\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`InviteToTeamMetadata`](InviteToTeamMetadata.md); `tag`: `\"invite_to_team\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`InviteToTeamMetadata`](InviteToTeamMetadata.md) | A user was invited to a team. |\n| `tag` | `\"invite_to_team\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`TaskAssignedMetadata`](TaskAssignedMetadata.md); `tag`: `\"task_assigned\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`TaskAssignedMetadata`](TaskAssignedMetadata.md) | A user was assigned to a task. |\n| `tag` | `\"task_assigned\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`ReminderMetadata`](ReminderMetadata.md); `tag`: `\"reminder\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`ReminderMetadata`](ReminderMetadata.md) | A reminder the user set for themselves came due. |\n| `tag` | `\"reminder\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`CalendarEventReminderMetadata`](CalendarEventReminderMetadata.md); `tag`: `\"calendar_event_reminder\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`CalendarEventReminderMetadata`](CalendarEventReminderMetadata.md) | A calendar event alarm came due. |\n| `tag` | `\"calendar_event_reminder\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`AiResponseMetadata`](AiResponseMetadata.md); `tag`: `\"ai_response\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`AiResponseMetadata`](AiResponseMetadata.md) | An AI assistant responded to a chat. |\n| `tag` | `\"ai_response\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`GithubPrStatusChanged`](GithubPrStatusChanged.md); `tag`: `\"github_pr_status_changed\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`GithubPrStatusChanged`](GithubPrStatusChanged.md) | A GitHub pull request changed lifecycle state. The `github_pr_event` alias keeps rows and queue messages persisted before the rename deserializable. |\n| `tag` | `\"github_pr_status_changed\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`GithubPrCheckRun`](GithubPrCheckRun.md); `tag`: `\"github_pr_check_run\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`GithubPrCheckRun`](GithubPrCheckRun.md) | A GitHub pull request check run completed. |\n| `tag` | `\"github_pr_check_run\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`GithubReviewRequested`](GithubReviewRequested.md); `tag`: `\"github_review_requested\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`GithubReviewRequested`](GithubReviewRequested.md) | The user's review was requested on a GitHub pull request. |\n| `tag` | `\"github_review_requested\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`GithubPrComment`](GithubPrComment.md); `tag`: `\"github_pr_comment\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`GithubPrComment`](GithubPrComment.md) | A GitHub pull request was commented on. |\n| `tag` | `\"github_pr_comment\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`GithubPrMention`](GithubPrMention.md); `tag`: `\"github_pr_mention\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`GithubPrMention`](GithubPrMention.md) | The user was mentioned on a GitHub pull request. |\n| `tag` | `\"github_pr_mention\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`GithubPrReview`](GithubPrReview.md); `tag`: `\"github_pr_review\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`GithubPrReview`](GithubPrReview.md) | A review was submitted on the user's GitHub pull request. |\n| `tag` | `\"github_pr_review\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`AgentSessionSettledMetadata`](AgentSessionSettledMetadata.md); `tag`: `\"agent_session_settled\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`AgentSessionSettledMetadata`](AgentSessionSettledMetadata.md) | An agent finished a turn with nothing queued behind it. |\n| `tag` | `\"agent_session_settled\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`AgentSessionWaitingForInputMetadata`](AgentSessionWaitingForInputMetadata.md); `tag`: `\"agent_session_waiting_for_input\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`AgentSessionWaitingForInputMetadata`](AgentSessionWaitingForInputMetadata.md) | An agent is blocked on a question for the session's owner. |\n| `tag` | `\"agent_session_waiting_for_input\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`AgentSessionMentionedMetadata`](AgentSessionMentionedMetadata.md); `tag`: `\"agent_session_mentioned\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`AgentSessionMentionedMetadata`](AgentSessionMentionedMetadata.md) | The user was named in a prompt to an agent session. |\n| `tag` | `\"agent_session_mentioned\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`ChannelMessageReactionMetadata`](ChannelMessageReactionMetadata.md); `tag`: `\"channel_message_reaction\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`ChannelMessageReactionMetadata`](ChannelMessageReactionMetadata.md) | Someone reacted to one of the user's channel messages. |\n| `tag` | `\"channel_message_reaction\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`CalendarEventJoinRequestMetadata`](CalendarEventJoinRequestMetadata.md); `tag`: `\"calendar_event_join_request\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`CalendarEventJoinRequestMetadata`](CalendarEventJoinRequestMetadata.md) | A channel member asked to be added as a guest of an event the user shared with the channel. |\n| `tag` | `\"calendar_event_join_request\"` | - |\n\n\n<!-- generated/notification/types.gen/type-aliases/NotificationDocumentSubType.md -->\n# Type Alias: NotificationDocumentSubType\n\n> **NotificationDocumentSubType** = \\{ `type`: `\"task\"`; \\} \\| \\{ `type`: `\"snippet\"`; \\} \\| \\{ `type`: `\"skill\"`; \\} \\| \\{ `type`: `\"initiative_description\"`; \\}\n\nThe sub type of a document in a notification.\nSerializes as `{ \"type\": \"task\" }` matching the storage service pattern.\n\n\n<!-- generated/notification/types.gen/type-aliases/NotificationState.md -->\n# Type Alias: NotificationState\n\n> **NotificationState** = `\"unseen\"` \\| `\"seen\"` \\| `\"done\"`\n\nThe mutually exclusive lifecycle states of a user's notification.\n\n\n<!-- generated/notification/types.gen/type-aliases/ReminderMetadata.md -->\n# Type Alias: ReminderMetadata\n\n> **ReminderMetadata** = \\{ `description`: `string`; `reminderId`: `string`; `scheduledFor?`: `string` \\| `null`; \\}\n\nMetadata for a reminder the user set for themselves coming due.\n\nThere is no sender: a reminder is self-set, so the dispatcher sends it with\n`sender_id: None` (a recipient who is also the sender is filtered out of\ntheir own notification). Every formatter here must therefore work without\none.\n\nThe associated entity, when there is one, lives on the notification row\nrather than in here, and clients resolve its name from that — so the\ndispatcher does not have to look up a name across five entity types.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-description\"></a> `description` | `string` | What the user asked to be reminded about. |\n| <a id=\"property-reminderid\"></a> `reminderId` | `string` | The reminder that fired. |\n| <a id=\"property-scheduledfor\"></a> `scheduledFor?` | `string` \\| `null` | Which firing this is — the occurrence the reminder came due for. What distinguishes two firings of the same recurring reminder, which are otherwise identical: same id, same description. The collapse key is built from it, so without it Tuesday's alert would replace Monday's unread one on the lock screen. Optional because notifications written before recurring dispatch existed have no such field, and they still have to read back. |\n\n\n<!-- generated/notification/types.gen/type-aliases/RepliedToDocumentCommentThreadMetadata.md -->\n# Type Alias: RepliedToDocumentCommentThreadMetadata\n\n> **RepliedToDocumentCommentThreadMetadata** = \\{ `commentId`: [`CommentRef`](CommentRef.md); `documentName`: `string`; `fileType?`: `string` \\| `null`; `owner`: `string`; `senderDisplayName?`: `string` \\| `null`; `senderProfilePictureUrl?`: `string` \\| `null`; `subType?`: `null` \\| [`NotificationDocumentSubType`](NotificationDocumentSubType.md); `text`: `string`; `threadId`: [`CommentRef`](CommentRef.md); \\}\n\nNotification sent when someone replies to a document comment thread.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-commentid\"></a> `commentId` | [`CommentRef`](CommentRef.md) | the comment id |\n| <a id=\"property-documentname\"></a> `documentName` | `string` | The name of the document. |\n| <a id=\"property-filetype\"></a> `fileType?` | `string` \\| `null` | The file type of the document. |\n| <a id=\"property-owner\"></a> `owner` | `string` | The owner of the document. |\n| <a id=\"property-senderdisplayname\"></a> `senderDisplayName?` | `string` \\| `null` | Public bot name when the author is an agent rather than a Macro user. |\n| <a id=\"property-senderprofilepictureurl\"></a> `senderProfilePictureUrl?` | `string` \\| `null` | - |\n| <a id=\"property-subtype\"></a> `subType?` | `null` \\| [`NotificationDocumentSubType`](NotificationDocumentSubType.md) | - |\n| <a id=\"property-text\"></a> `text` | `string` | the text of the comment |\n| <a id=\"property-threadid\"></a> `threadId` | [`CommentRef`](CommentRef.md) | the thread id |\n\n\n<!-- generated/notification/types.gen/type-aliases/RequestedAccessLevel.md -->\n# Type Alias: RequestedAccessLevel\n\n> **RequestedAccessLevel** = `\"view\"` \\| `\"comment\"` \\| `\"edit\"`\n\nPermission level used by an access request, excluding ownership.\n\n\n<!-- generated/notification/types.gen/type-aliases/TaskAssignedMetadata.md -->\n# Type Alias: TaskAssignedMetadata\n\n> **TaskAssignedMetadata** = \\{ `assignedBy`: `string`; `senderProfilePictureUrl?`: `string` \\| `null`; `subType?`: `null` \\| [`NotificationDocumentSubType`](NotificationDocumentSubType.md); `taskId`: `string`; `taskName?`: `string` \\| `null`; \\}\n\nMetadata for when a user is assigned to a task\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-assignedby\"></a> `assignedBy` | `string` | The user who assigned the task |\n| <a id=\"property-senderprofilepictureurl\"></a> `senderProfilePictureUrl?` | `string` \\| `null` | - |\n| <a id=\"property-subtype\"></a> `subType?` | `null` \\| [`NotificationDocumentSubType`](NotificationDocumentSubType.md) | - |\n| <a id=\"property-taskid\"></a> `taskId` | `string` | The unique identifier of the task |\n| <a id=\"property-taskname\"></a> `taskName?` | `string` \\| `null` | The name of the task (optional) |\n\n\n<!-- src/entities/notifications/namespace/classes/NotificationNamespace.md -->\n# Class: NotificationNamespace\n\n## Constructors\n\n### Constructor\n\n> **new NotificationNamespace**(`client`): `NotificationNamespace`\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `client` | `MacroClient` |\n\n#### Returns\n\n`NotificationNamespace`\n\n## Methods\n\n### byId()\n\n> **byId**(`id`): [`Notification`](../../notification/classes/Notification.md)\n\nA handle to a notification by id.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `id` | `string` |\n\n#### Returns\n\n[`Notification`](../../notification/classes/Notification.md)\n\n***\n\n### delete()\n\n> **delete**(`ids`): `Promise`\\<`void`\\>\n\nDelete a batch of notifications.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `ids` | `string`[] |\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### disableType()\n\n> **disableType**(`type`): `Promise`\\<`void`\\>\n\nDisable delivery of a notification type.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `type` | `\"reminder\"` \\| `\"channel_mention\"` \\| `\"document_mention\"` \\| `\"mentioned_in_document_comment\"` \\| `\"replied_to_document_comment_thread\"` \\| `\"commented_on_document\"` \\| `\"entity_access_requested\"` \\| `\"entity_access_granted\"` \\| `\"initiative_discussion\"` \\| `\"crm_discussion\"` \\| `\"channel_invite\"` \\| `\"channel_message_send\"` \\| `\"channel_message_reply\"` \\| `\"call_started\"` \\| `\"new_email\"` \\| `\"inbox_reauth_required\"` \\| `\"invite_to_team\"` \\| `\"task_assigned\"` \\| `\"calendar_event_reminder\"` \\| `\"ai_response\"` \\| `\"github_pr_status_changed\"` \\| `\"github_pr_check_run\"` \\| `\"github_review_requested\"` \\| `\"github_pr_comment\"` \\| `\"github_pr_mention\"` \\| `\"github_pr_review\"` \\| `\"agent_session_settled\"` \\| `\"agent_session_waiting_for_input\"` \\| `\"agent_session_mentioned\"` \\| `\"channel_message_reaction\"` \\| `\"calendar_event_join_request\"` |\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### enableType()\n\n> **enableType**(`type`): `Promise`\\<`void`\\>\n\nRe-enable delivery of a notification type.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `type` | `\"reminder\"` \\| `\"channel_mention\"` \\| `\"document_mention\"` \\| `\"mentioned_in_document_comment\"` \\| `\"replied_to_document_comment_thread\"` \\| `\"commented_on_document\"` \\| `\"entity_access_requested\"` \\| `\"entity_access_granted\"` \\| `\"initiative_discussion\"` \\| `\"crm_discussion\"` \\| `\"channel_invite\"` \\| `\"channel_message_send\"` \\| `\"channel_message_reply\"` \\| `\"call_started\"` \\| `\"new_email\"` \\| `\"inbox_reauth_required\"` \\| `\"invite_to_team\"` \\| `\"task_assigned\"` \\| `\"calendar_event_reminder\"` \\| `\"ai_response\"` \\| `\"github_pr_status_changed\"` \\| `\"github_pr_check_run\"` \\| `\"github_review_requested\"` \\| `\"github_pr_comment\"` \\| `\"github_pr_mention\"` \\| `\"github_pr_review\"` \\| `\"agent_session_settled\"` \\| `\"agent_session_waiting_for_input\"` \\| `\"agent_session_mentioned\"` \\| `\"channel_message_reaction\"` \\| `\"calendar_event_join_request\"` |\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### list()\n\n> **list**(`opts?`): `AsyncGenerator`\\<[`Notification`](../../notification/classes/Notification.md)\\>\n\nThe viewer's notification feed, most recent first, auto-paginated.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `opts?` | \\{ `pageSize?`: `number`; \\} |\n| `opts.pageSize?` | `number` |\n\n#### Returns\n\n`AsyncGenerator`\\<[`Notification`](../../notification/classes/Notification.md)\\>\n\n***\n\n### markDone()\n\n> **markDone**(`ids`): `Promise`\\<`void`\\>\n\nMark a batch of notifications as done.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `ids` | `string`[] |\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### markSeen()\n\n> **markSeen**(`ids`): `Promise`\\<`void`\\>\n\nMark a batch of notifications as seen.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `ids` | `string`[] |\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### preferences()\n\n> **preferences**(): `Promise`\\<[`GetNotificationTypePreferencesResponse`](../../../../../generated/notification/types.gen/type-aliases/GetNotificationTypePreferencesResponse.md)\\>\n\nThe viewer's notification type preferences (disabled types).\n\n#### Returns\n\n`Promise`\\<[`GetNotificationTypePreferencesResponse`](../../../../../generated/notification/types.gen/type-aliases/GetNotificationTypePreferencesResponse.md)\\>\n\n\n<!-- src/entities/notifications/namespace/type-aliases/NotificationType.md -->\n# Type Alias: NotificationType\n\n> **NotificationType** = [`NotifEvent`](../../../../../generated/notification/types.gen/type-aliases/NotifEvent.md)\\[`\"tag\"`\\]\n\nA notification event type name, e.g. `channel_mention`.\n\n\n<!-- src/entities/notifications/notification/classes/Notification.md -->\n# Class: Notification\n\nA notification in the viewer's feed.\n\n## Extends\n\n- [`MacroEntity`](../../../entity/classes/MacroEntity.md)\\<`NotificationDetail`\\>\n\n## Properties\n\n| Property | Modifier | Type | Description | Inherited from |\n| ------ | ------ | ------ | ------ | ------ |\n| <a id=\"property-createdat\"></a> `createdAt` | `readonly` | () => `Promise`\\<`string`\\> | When the notification was created. | - |\n| <a id=\"property-deletedat\"></a> `deletedAt` | `readonly` | () => `Promise`\\<`string` \\| `undefined`\\> | When the notification was deleted, if it has been. | - |\n| <a id=\"property-done\"></a> `done` | `readonly` | () => `Promise`\\<`boolean`\\> | Whether the notification is completed. | - |\n| <a id=\"property-id\"></a> `id` | `public readonly` | `string` | - | [`MacroEntity`](../../../entity/classes/MacroEntity.md).[`id`](../../../entity/classes/MacroEntity.md#property-id) |\n| <a id=\"property-metadata\"></a> `metadata` | `readonly` | () => `Promise`\\<[`NotifEvent`](../../../../../generated/notification/types.gen/type-aliases/NotifEvent.md)\\> | The typed notification payload (tagged by event type). | - |\n| <a id=\"property-owner\"></a> `owner` | `readonly` | () => `Promise`\\<[`User`](../../../users/user/classes/User.md)\\> | The user who owns (receives) this notification. | - |\n| <a id=\"property-sender\"></a> `sender` | `readonly` | () => `Promise`\\<[`User`](../../../users/user/classes/User.md) \\| `undefined`\\> | The user who triggered the notification, if any. | - |\n| <a id=\"property-sent\"></a> `sent` | `readonly` | () => `Promise`\\<`boolean`\\> | Whether the notification has been sent (delivered out of band). | - |\n| <a id=\"property-state\"></a> `state` | `readonly` | () => `Promise`\\<[`NotificationState`](../../../../../generated/notification/types.gen/type-aliases/NotificationState.md)\\> | The authoritative lifecycle state, independent of viewing timestamps. | - |\n| <a id=\"property-type\"></a> `type` | `readonly` | () => `Promise`\\<`string`\\> | The notification event type (e.g. `channel_mention`). | - |\n| <a id=\"property-updatedat\"></a> `updatedAt` | `readonly` | () => `Promise`\\<`string`\\> | When the notification was last updated. | - |\n| <a id=\"property-viewedat\"></a> `viewedAt` | `readonly` | () => `Promise`\\<`string` \\| `undefined`\\> | When the notification was viewed, if it has been seen. | - |\n\n## Methods\n\n### delete()\n\n> **delete**(): `Promise`\\<`void`\\>\n\nDelete the notification.\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### markDone()\n\n> **markDone**(): `Promise`\\<`void`\\>\n\nMark the notification as done.\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### markSeen()\n\n> **markSeen**(): `Promise`\\<`void`\\>\n\nMark the notification as seen.\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### markUndone()\n\n> **markUndone**(): `Promise`\\<`void`\\>\n\nMove the notification back to not-done.\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### seen()\n\n> **seen**(): `Promise`\\<`boolean`\\>\n\nWhether the notification is acknowledged (seen or done).\n\n#### Returns\n\n`Promise`\\<`boolean`\\>\n\n***\n\n### toJSON()\n\n> **toJSON**(): \\{ `detail?`: [`ApiUserNotification`](../../../../../generated/notification/types.gen/type-aliases/ApiUserNotification.md); `id`: `string`; \\}\n\n#### Returns\n\n\\{ `detail?`: [`ApiUserNotification`](../../../../../generated/notification/types.gen/type-aliases/ApiUserNotification.md); `id`: `string`; \\}\n\n| Name | Type |\n| ------ | ------ |\n| `detail?` | [`ApiUserNotification`](../../../../../generated/notification/types.gen/type-aliases/ApiUserNotification.md) |\n| `id` | `string` |\n\n#### Inherited from\n\n[`MacroEntity`](../../../entity/classes/MacroEntity.md).[`toJSON`](../../../entity/classes/MacroEntity.md#tojson)\n\n***\n\n### byId()\n\n> `static` **byId**(`client`, `id`): `Notification`\n\nA handle to a notification by id. Details load on first access.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `client` | `MacroClient` |\n| `id` | `string` |\n\n#### Returns\n\n`Notification`\n\n***\n\n### from()\n\n> `static` **from**(`client`, `data`): `Notification`\n\nBuild a notification from a list-endpoint record (pre-seeded, no fetch).\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `client` | `MacroClient` |\n| `data` | [`ApiUserNotification`](../../../../../generated/notification/types.gen/type-aliases/ApiUserNotification.md) |\n\n#### Returns\n\n`Notification`\n\n***\n\n### list()\n\n> `static` **list**(`client`, `opts?`): `AsyncGenerator`\\<`Notification`\\>\n\nThe viewer's notification feed, most recent first, auto-paginated.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `client` | `MacroClient` |\n| `opts?` | \\{ `pageSize?`: `number`; `states?`: [`NotificationState`](../../../../../generated/notification/types.gen/type-aliases/NotificationState.md)[]; \\} |\n| `opts.pageSize?` | `number` |\n| `opts.states?` | [`NotificationState`](../../../../../generated/notification/types.gen/type-aliases/NotificationState.md)[] |\n\n#### Returns\n\n`AsyncGenerator`\\<`Notification`\\>\n"
+ "documentation": "# Macro SDK: notifications\n\nGenerated by TypeDoc. Paths below refer to the canonical Markdown hierarchy. Other entity handles are documented in their named section; request core for shared SDK helpers.\n\n<!-- generated/notification/types.gen/type-aliases/AgentSessionMentionedMetadata.md -->\n# Type Alias: AgentSessionMentionedMetadata\n\n> **AgentSessionMentionedMetadata** = [`AgentSessionNotificationRef`](AgentSessionNotificationRef.md) & \\{ `actionId`: `string`; `mentionedBy?`: `string` \\| `null`; \\}\n\nSomeone named the recipient in a prompt to an agent session.\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `actionId` | `string` | The action carrying the prompt. |\n| `mentionedBy?` | `string` \\| `null` | Who wrote the prompt, absent when a bot acted on nobody's behalf. |\n\n\n<!-- generated/notification/types.gen/type-aliases/AgentSessionNotificationRef.md -->\n# Type Alias: AgentSessionNotificationRef\n\n> **AgentSessionNotificationRef** = \\{ `announcementMessageId?`: `string` \\| `null`; `botId`: `string`; `botName`: `string`; `channelId?`: `string` \\| `null`; `parent?`: `null` \\| [`AgentSessionOriginParent`](AgentSessionOriginParent.md); `sessionId`: `string`; `sessionName`: `string`; `threadId?`: `string` \\| `null`; \\}\n\nFlattened into each agent-session kind so the wire keeps these keys at the\ntop level of the metadata, the way [`CommonChannelMetadata`] does.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-announcementmessageid\"></a> `announcementMessageId?` | `string` \\| `null` | The magic-chip message for the turn in question, when one was posted. |\n| <a id=\"property-botid\"></a> `botId` | `string` | The bot the session runs for. A string on the wire: system bots have fixed ids like `00000000-0000-0000-0000-00000000a2a2`, which are not RFC 4122 uuids and fail a `format: uuid` check on the client. |\n| <a id=\"property-botname\"></a> `botName` | `string` | The bot's display name; agent notifications have no user sender, so this is who they read as being from. |\n| <a id=\"property-channelid\"></a> `channelId?` | `string` \\| `null` | The channel the session was opened from, when it was opened from a channel thread. |\n| <a id=\"property-parent\"></a> `parent?` | `null` \\| [`AgentSessionOriginParent`](AgentSessionOriginParent.md) | - |\n| <a id=\"property-sessionid\"></a> `sessionId` | `string` | The session; what a click opens. |\n| <a id=\"property-sessionname\"></a> `sessionName` | `string` | The session's name at the time of the event. |\n| <a id=\"property-threadid\"></a> `threadId?` | `string` \\| `null` | The thread the session was opened from, when it was. |\n\n\n<!-- generated/notification/types.gen/type-aliases/AgentSessionOriginParent.md -->\n# Type Alias: AgentSessionOriginParent\n\n> **AgentSessionOriginParent** = \\{ `id`: `string`; `type`: `string`; \\}\n\nThe session an agent-session notification is about, and where its magic\nchip lives when it was opened from a thread.\n\nThe conversation an agent session was opened from: a channel, document,\nor initiative. Spelled like the message API's parent for client routing.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-id\"></a> `id` | `string` | The parent entity id. |\n| <a id=\"property-type\"></a> `type` | `string` | `channel`, `document`, or `initiative`. |\n\n\n<!-- generated/notification/types.gen/type-aliases/AgentSessionSettledMetadata.md -->\n# Type Alias: AgentSessionSettledMetadata\n\n> **AgentSessionSettledMetadata** = [`AgentSessionNotificationRef`](AgentSessionNotificationRef.md) & \\{ `actor?`: `string` \\| `null`; `excerpt?`: `string` \\| `null`; `stopReason`: `string`; `turn`: `number`; \\}\n\nAn agent finished a turn with nothing queued behind it.\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `actor?` | `string` \\| `null` | Who prompted the turn, absent when a bot acted on nobody's behalf. |\n| `excerpt?` | `string` \\| `null` | The agent's last prose in the turn, whole; `None` when it wrote none. |\n| `stopReason` | `string` | The ACP stop reason, or `error`. |\n| `turn` | `number` | The turn that ended. |\n\n\n<!-- generated/notification/types.gen/type-aliases/AgentSessionWaitingForInputMetadata.md -->\n# Type Alias: AgentSessionWaitingForInputMetadata\n\n> **AgentSessionWaitingForInputMetadata** = [`AgentSessionNotificationRef`](AgentSessionNotificationRef.md) & \\{ `question`: `string`; `turn`: `number`; \\}\n\nAn agent is blocked on a question only the session's owner can answer.\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `question` | `string` | The question, as the agent phrased it. |\n| `turn` | `number` | The turn asking. |\n\n\n<!-- generated/notification/types.gen/type-aliases/AiResponseMetadata.md -->\n# Type Alias: AiResponseMetadata\n\n> **AiResponseMetadata** = \\{ `messageId`: `string`; `summary`: `string`; \\}\n\n## Properties\n\n| Property | Type |\n| ------ | ------ |\n| <a id=\"property-messageid\"></a> `messageId` | `string` |\n| <a id=\"property-summary\"></a> `summary` | `string` |\n\n\n<!-- generated/notification/types.gen/type-aliases/ApiUserNotification.md -->\n# Type Alias: ApiUserNotification\n\n> **ApiUserNotification** = [`Entity`](Entity.md) & \\{ `created_at`: `string`; `deleted_at?`: `string` \\| `null`; `id`: `string`; `notification_event_type`: `string`; `notification_metadata`: [`NotifEvent`](NotifEvent.md); `owner_id`: `string`; `sender_id?`: `string` \\| `null`; `sent`: `boolean`; `state`: [`NotificationState`](NotificationState.md); `updated_at`: `string`; `viewed_at?`: `string` \\| `null`; \\}\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `created_at` | `string` | When the notification was created. |\n| `deleted_at?` | `string` \\| `null` | When the notification was deleted. |\n| `id` | `string` | The notification ID. |\n| `notification_event_type` | `string` | The notification event type string (e.g. \"channel_mention\"). TODO make this a new type |\n| `notification_metadata` | [`NotifEvent`](NotifEvent.md) | Deserialized notification metadata. |\n| `owner_id` | `string` | The user who owns this notification. |\n| `sender_id?` | `string` \\| `null` | The user who triggered the notification. |\n| `sent` | `boolean` | Whether the notification has been sent. |\n| `state` | [`NotificationState`](NotificationState.md) | The authoritative notification lifecycle state. |\n| `updated_at` | `string` | When the notification was last updated. |\n| `viewed_at?` | `string` \\| `null` | When the notification was viewed/seen. |\n\n\n<!-- generated/notification/types.gen/type-aliases/CalendarEventJoinRequestMetadata.md -->\n# Type Alias: CalendarEventJoinRequestMetadata\n\n> **CalendarEventJoinRequestMetadata** = \\{ `eventId`: `string`; `requestId`: `string`; `title`: `string`; \\}\n\nA channel member who sees a calendar event only through a channel share\nasked the person who shared it to add them as a guest. Sent to the sharer,\nwith the requester as sender.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-eventid\"></a> `eventId` | `string` | The shared calendar event entity the request is for. |\n| <a id=\"property-requestid\"></a> `requestId` | `string` | Stable request identity, answered from the event's details. |\n| <a id=\"property-title\"></a> `title` | `string` | Event title when the request was made. |\n\n\n<!-- generated/notification/types.gen/type-aliases/CalendarEventReminderMetadata.md -->\n# Type Alias: CalendarEventReminderMetadata\n\n> **CalendarEventReminderMetadata** = \\{ `endsAt?`: `string` \\| `null`; `eventId`: `string`; `minutesBefore`: `number`; `occurrenceKey`: `string`; `startDate?`: `string` \\| `null`; `startsAt?`: `string` \\| `null`; `timeZone?`: `string` \\| `null`; `title`: `string`; \\}\n\nA calendar event alarm came due. Like [`ReminderMetadata`], these are\nself-notifications: `sender_id` must stay `None` or the only recipient is\nfiltered out. Everything the alert renders rides in here so the\ndispatcher never has to resolve the event again at display time.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-endsat\"></a> `endsAt?` | `string` \\| `null` | Instance end, for timed events. |\n| <a id=\"property-eventid\"></a> `eventId` | `string` | The calendar event entity the alarm belongs to. |\n| <a id=\"property-minutesbefore\"></a> `minutesBefore` | `number` | Minutes before the start the alarm was configured to fire. |\n| <a id=\"property-occurrencekey\"></a> `occurrenceKey` | `string` | Stable occurrence key of the instance that is starting. |\n| <a id=\"property-startdate\"></a> `startDate?` | `string` \\| `null` | Instance start date, for all-day events. |\n| <a id=\"property-startsat\"></a> `startsAt?` | `string` \\| `null` | Instance start, for timed events. |\n| <a id=\"property-timezone\"></a> `timeZone?` | `string` \\| `null` | IANA zone for rendering local clock times, when known. |\n| <a id=\"property-title\"></a> `title` | `string` | Event display title at dispatch time. |\n\n\n<!-- generated/notification/types.gen/type-aliases/CallStartedMetadata.md -->\n# Type Alias: CallStartedMetadata\n\n> **CallStartedMetadata** = \\{ `channel_name?`: `string` \\| `null`; `sender_profile_picture_url?`: `string` \\| `null`; \\}\n\nMetadata for a notification that a call has started in a channel.\n\nMirrors the producer-side `CallStartedNotification` in the `call` crate:\nboth serialize the same wire shape (snake_case fields) under the same\n`call_started` [`Notification::TYPE_NAME`]. This type is the read-side\nmodel used by [`crate::NotifEvent`]; the producer keeps its own type\nbecause it additionally builds the incoming-call APNS/VoIP push.\n\nRows persisted before the type name was normalized used the kebab-case\n`call-started`; the [`crate::NotifEvent::CallStarted`] variant carries a\n`#[serde(alias = \"call-started\")]` so those rows still deserialize.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-channel_name\"></a> `channel_name?` | `string` \\| `null` | The name of the channel the call started in, when available. |\n| <a id=\"property-sender_profile_picture_url\"></a> `sender_profile_picture_url?` | `string` \\| `null` | Profile picture URL of the user who started the call, when available. |\n\n\n<!-- generated/notification/types.gen/type-aliases/ChannelInviteMetadata.md -->\n# Type Alias: ChannelInviteMetadata\n\n> **ChannelInviteMetadata** = \\{ `channelName?`: `string`; `invitedBy`: `string`; `isDirectMessage?`: `boolean`; `messageContent?`: `string` \\| `null`; `senderProfilePictureUrl?`: `string` \\| `null`; \\}\n\nMetadata for when a user is invited to a channel.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-channelname\"></a> `channelName?` | `string` | The name of the channel |\n| <a id=\"property-invitedby\"></a> `invitedBy` | `string` | The user who sent the invitation |\n| <a id=\"property-isdirectmessage\"></a> `isDirectMessage?` | `boolean` | Whether this is a direct message rather than a channel invitation. Older notification payloads retain channel-invitation wording. |\n| <a id=\"property-messagecontent\"></a> `messageContent?` | `string` \\| `null` | Message content to show in the invite email, when the invite was triggered by a message. |\n| <a id=\"property-senderprofilepictureurl\"></a> `senderProfilePictureUrl?` | `string` \\| `null` | The sender's profile picture URL, if available. |\n\n\n<!-- generated/notification/types.gen/type-aliases/ChannelMentionMetadata.md -->\n# Type Alias: ChannelMentionMetadata\n\n> **ChannelMentionMetadata** = [`CommonChannelMetadata`](CommonChannelMetadata.md) & \\{ `messageContent`: `string`; `messageId`: `string`; `senderDisplayName?`: `string` \\| `null`; `senderProfilePictureUrl?`: `string` \\| `null`; `threadId?`: `string` \\| `null`; \\}\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `messageContent` | `string` | The message content |\n| `messageId` | `string` | The message you were mentioned in |\n| `senderDisplayName?` | `string` \\| `null` | Display name for non-user senders such as bots |\n| `senderProfilePictureUrl?` | `string` \\| `null` | - |\n| `threadId?` | `string` \\| `null` | the id of the thread |\n\n\n<!-- generated/notification/types.gen/type-aliases/ChannelMessageReactionMetadata.md -->\n# Type Alias: ChannelMessageReactionMetadata\n\n> **ChannelMessageReactionMetadata** = [`CommonChannelMetadata`](CommonChannelMetadata.md) & \\{ `emoji`: `string`; `messageContent`: `string`; `messageId`: `string`; `senderProfilePictureUrl?`: `string` \\| `null`; `threadId?`: `string` \\| `null`; \\}\n\nMetadata for a reaction added to one of the recipient's channel messages.\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `emoji` | `string` | The emoji added by the reactor. |\n| `messageContent` | `string` | The reacted-to message content. |\n| `messageId` | `string` | The reacted-to message id. |\n| `senderProfilePictureUrl?` | `string` \\| `null` | Optional reactor profile picture URL. |\n| `threadId?` | `string` \\| `null` | The thread root id when the reacted-to message is a reply. |\n\n\n<!-- generated/notification/types.gen/type-aliases/ChannelMessageSendMetadata.md -->\n# Type Alias: ChannelMessageSendMetadata\n\n> **ChannelMessageSendMetadata** = [`CommonChannelMetadata`](CommonChannelMetadata.md) & \\{ `messageContent?`: `string`; `messageId`: `string`; `sender?`: `string` \\| `null`; `senderDisplayName?`: `string` \\| `null`; `senderProfilePictureUrl?`: `string` \\| `null`; \\}\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `messageContent?` | `string` | The content of the message |\n| `messageId` | `string` | The message id |\n| `sender?` | `string` \\| `null` | The user who sent the message, when sent by a user |\n| `senderDisplayName?` | `string` \\| `null` | Display name for non-user senders such as bots |\n| `senderProfilePictureUrl?` | `string` \\| `null` | - |\n\n\n<!-- generated/notification/types.gen/type-aliases/ChannelReplyMetadata.md -->\n# Type Alias: ChannelReplyMetadata\n\n> **ChannelReplyMetadata** = [`CommonChannelMetadata`](CommonChannelMetadata.md) & \\{ `messageContent`: `string`; `messageId`: `string`; `senderDisplayName?`: `string` \\| `null`; `senderProfilePictureUrl?`: `string` \\| `null`; `threadId`: `string`; `threadParentSenderId?`: `string` \\| `null`; `userId?`: `string` \\| `null`; \\}\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `messageContent` | `string` | The message content |\n| `messageId` | `string` | The id of the new message |\n| `senderDisplayName?` | `string` \\| `null` | Display name for non-user senders such as bots |\n| `senderProfilePictureUrl?` | `string` \\| `null` | - |\n| `threadId` | `string` | The id of the thread that has the reply |\n| `threadParentSenderId?` | `string` \\| `null` | The user who sent the root message of the thread |\n| `userId?` | `string` \\| `null` | The sender id of the reply, when sent by a user |\n\n\n<!-- generated/notification/types.gen/type-aliases/ChannelType.md -->\n# Type Alias: ChannelType\n\n> **ChannelType** = `\"public\"` \\| `\"private\"` \\| `\"directMessage\"` \\| `\"team\"`\n\n\n<!-- generated/notification/types.gen/type-aliases/CommentRef.md -->\n# Type Alias: CommentRef\n\n> **CommentRef** = `number` \\| `string`\n\nIdentity of a document comment or its thread. Comments written before the\nshared message store carry the legacy numeric ids; comments in the shared\nstore carry the message and root UUIDs.\n\n\n<!-- generated/notification/types.gen/type-aliases/CommentedOnDocumentMetadata.md -->\n# Type Alias: CommentedOnDocumentMetadata\n\n> **CommentedOnDocumentMetadata** = \\{ `commentId`: [`CommentRef`](CommentRef.md); `documentName`: `string`; `fileType?`: `string` \\| `null`; `owner`: `string`; `senderDisplayName?`: `string` \\| `null`; `senderProfilePictureUrl?`: `string` \\| `null`; `subType?`: `null` \\| [`NotificationDocumentSubType`](NotificationDocumentSubType.md); `text`: `string`; `threadId`: [`CommentRef`](CommentRef.md); \\}\n\nNotification sent when someone comments on a document the user owns.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-commentid\"></a> `commentId` | [`CommentRef`](CommentRef.md) | the comment id |\n| <a id=\"property-documentname\"></a> `documentName` | `string` | The name of the document. |\n| <a id=\"property-filetype\"></a> `fileType?` | `string` \\| `null` | The file type of the document. |\n| <a id=\"property-owner\"></a> `owner` | `string` | The owner of the document. |\n| <a id=\"property-senderdisplayname\"></a> `senderDisplayName?` | `string` \\| `null` | Public bot name when the author is an agent rather than a Macro user. |\n| <a id=\"property-senderprofilepictureurl\"></a> `senderProfilePictureUrl?` | `string` \\| `null` | - |\n| <a id=\"property-subtype\"></a> `subType?` | `null` \\| [`NotificationDocumentSubType`](NotificationDocumentSubType.md) | - |\n| <a id=\"property-text\"></a> `text` | `string` | the text of the comment |\n| <a id=\"property-threadid\"></a> `threadId` | [`CommentRef`](CommentRef.md) | the thread id |\n\n\n<!-- generated/notification/types.gen/type-aliases/CommonChannelMetadata.md -->\n# Type Alias: CommonChannelMetadata\n\n> **CommonChannelMetadata** = \\{ `channelName?`: `string`; `channelType`: [`ChannelType`](ChannelType.md); \\}\n\nCommon metadata for notifications on channels\n\n## Properties\n\n| Property | Type |\n| ------ | ------ |\n| <a id=\"property-channelname\"></a> `channelName?` | `string` |\n| <a id=\"property-channeltype\"></a> `channelType` | [`ChannelType`](ChannelType.md) |\n\n\n<!-- generated/notification/types.gen/type-aliases/CrmDiscussionMetadata.md -->\n# Type Alias: CrmDiscussionMetadata\n\n> **CrmDiscussionMetadata** = \\{ `messageId`: `string`; `reason`: [`CrmDiscussionReason`](CrmDiscussionReason.md); `recordName`: `string`; `senderDisplayName?`: `string` \\| `null`; `senderProfilePictureUrl?`: `string` \\| `null`; `text`: `string`; `threadId`: `string`; \\}\n\nCRM discussion metadata. The notification entity identifies the company or\ncontact; message and thread UUIDs select the discussion inside it.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-messageid\"></a> `messageId` | `string` | Canonical shared message UUID. |\n| <a id=\"property-reason\"></a> `reason` | [`CrmDiscussionReason`](CrmDiscussionReason.md) | Semantic reason selected by the message delivery domain. |\n| <a id=\"property-recordname\"></a> `recordName` | `string` | Company or contact display name. |\n| <a id=\"property-senderdisplayname\"></a> `senderDisplayName?` | `string` \\| `null` | Public display name for a bot author. |\n| <a id=\"property-senderprofilepictureurl\"></a> `senderProfilePictureUrl?` | `string` \\| `null` | Optional avatar for push notification attachments. |\n| <a id=\"property-text\"></a> `text` | `string` | Posted Markdown content. |\n| <a id=\"property-threadid\"></a> `threadId` | `string` | Canonical discussion root UUID. |\n\n\n<!-- generated/notification/types.gen/type-aliases/CrmDiscussionReason.md -->\n# Type Alias: CrmDiscussionReason\n\n> **CrmDiscussionReason** = `\"mention\"` \\| `\"reply\"` \\| `\"owner\"`\n\nWhy a CRM discussion notification was delivered.\n\n\n<!-- generated/notification/types.gen/type-aliases/DocumentMentionMetadata.md -->\n# Type Alias: DocumentMentionMetadata\n\n> **DocumentMentionMetadata** = [`ChannelMentionMetadata`](ChannelMentionMetadata.md) & \\{ `documentName`: `string`; `fileType?`: `string` \\| `null`; `owner`: `string`; `subType?`: `null` \\| [`NotificationDocumentSubType`](NotificationDocumentSubType.md); \\}\n\nSomeone mentioned a document in a channel\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `documentName` | `string` | The name of the document |\n| `fileType?` | `string` \\| `null` | The file type of the document |\n| `owner` | `string` | The owner of the document |\n| `subType?` | `null` \\| [`NotificationDocumentSubType`](NotificationDocumentSubType.md) | - |\n\n\n<!-- generated/notification/types.gen/type-aliases/Entity.md -->\n# Type Alias: Entity\n\n> **Entity** = \\{ `entity_id`: `string`; `entity_type`: [`EntityType`](EntityType.md); \\}\n\nThe Entity describes the minimum amount of information required to describe a unique thing in Macro\nThis contains the type of the entity [EntityType] and the string id of that entity\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-entity_id\"></a> `entity_id` | `string` | The id of that entity |\n| <a id=\"property-entity_type\"></a> `entity_type` | [`EntityType`](EntityType.md) | The type of entity we are describing |\n\n\n<!-- generated/notification/types.gen/type-aliases/EntityAccessGrantedMetadata.md -->\n# Type Alias: EntityAccessGrantedMetadata\n\n> **EntityAccessGrantedMetadata** = \\{ `accessLevel`: [`RequestedAccessLevel`](RequestedAccessLevel.md); `entityName`: `string`; `fileType?`: `string` \\| `null`; `requestId`: `string`; `revision`: `number`; \\}\n\nA person granted you access to a shared entity.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-accesslevel\"></a> `accessLevel` | [`RequestedAccessLevel`](RequestedAccessLevel.md) | Requested or granted permission. |\n| <a id=\"property-entityname\"></a> `entityName` | `string` | Shared item's name. |\n| <a id=\"property-filetype\"></a> `fileType?` | `string` \\| `null` | Document file type for routing. |\n| <a id=\"property-requestid\"></a> `requestId` | `string` | Stable request identity. |\n| <a id=\"property-revision\"></a> `revision` | `number` | Revision that generated this notification. |\n\n\n<!-- generated/notification/types.gen/type-aliases/EntityAccessRequestedMetadata.md -->\n# Type Alias: EntityAccessRequestedMetadata\n\n> **EntityAccessRequestedMetadata** = \\{ `accessLevel`: [`RequestedAccessLevel`](RequestedAccessLevel.md); `entityName`: `string`; `fileType?`: `string` \\| `null`; `requestId`: `string`; `revision`: `number`; \\}\n\nA person requested access to a shared entity.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-accesslevel\"></a> `accessLevel` | [`RequestedAccessLevel`](RequestedAccessLevel.md) | Requested or granted permission. |\n| <a id=\"property-entityname\"></a> `entityName` | `string` | Shared item's name. |\n| <a id=\"property-filetype\"></a> `fileType?` | `string` \\| `null` | Document file type for routing. |\n| <a id=\"property-requestid\"></a> `requestId` | `string` | Stable request identity. |\n| <a id=\"property-revision\"></a> `revision` | `number` | Revision that generated this notification. |\n\n\n<!-- generated/notification/types.gen/type-aliases/EntityType.md -->\n# Type Alias: EntityType\n\n> **EntityType** = `\"user\"` \\| `\"chat\"` \\| `\"channel\"` \\| `\"channel_message\"` \\| `\"document\"` \\| `\"project\"` \\| `\"email_thread\"` \\| `\"calendar_event\"` \\| `\"team\"` \\| `\"call\"` \\| `\"foreign_entity\"` \\| `\"static_file\"` \\| `\"crm_company\"` \\| `\"crm_contact\"` \\| `\"crm_pipeline\"` \\| `\"reminder\"` \\| `\"skill\"` \\| `\"agent_session\"` \\| `\"scheduled_action\"` \\| `\"initiative\"` \\| `\"database\"` \\| `\"database_row\"` \\| `\"form\"`\n\nThe type of an entity in Macro\n\n\n<!-- generated/notification/types.gen/type-aliases/GetNotificationTypePreferencesResponse.md -->\n# Type Alias: GetNotificationTypePreferencesResponse\n\n> **GetNotificationTypePreferencesResponse** = \\{ `disabled_types`: `string`[]; \\}\n\nResponse for listing disabled notification types.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-disabled_types\"></a> `disabled_types` | `string`[] | The notification types that the user has disabled. |\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrCheckRun.md -->\n# Type Alias: GithubPrCheckRun\n\n> **GithubPrCheckRun** = [`GithubPrNotificationCommon`](GithubPrNotificationCommon.md) & \\{ `checkName`: `string`; `checkRunGithubId`: `number`; `checkStatus`: `string`; `checkUrl`: `string`; `completedAt`: `string`; `conclusion`: `string`; `state`: [`GithubPrCheckRunState`](GithubPrCheckRunState.md); \\}\n\nMetadata for a notification that a GitHub pull request check run completed.\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `checkName` | `string` | The display name GitHub reported for the check run. |\n| `checkRunGithubId` | `number` | The GitHub numeric id of the check run. |\n| `checkStatus` | `string` | The raw GitHub check run status. |\n| `checkUrl` | `string` | The public GitHub URL for the check run. |\n| `completedAt` | `string` | When GitHub marked the check run as complete. |\n| `conclusion` | `string` | The raw GitHub check run conclusion. |\n| `state` | [`GithubPrCheckRunState`](GithubPrCheckRunState.md) | The normalized notification state for this check run. |\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrCheckRunState.md -->\n# Type Alias: GithubPrCheckRunState\n\n> **GithubPrCheckRunState** = `\"completed\"` \\| `\"failed\"`\n\nThe normalized result state for a GitHub pull request check-run notification.\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrComment.md -->\n# Type Alias: GithubPrComment\n\n> **GithubPrComment** = [`GithubPrNotificationCommon`](GithubPrNotificationCommon.md) & \\{ `commentGithubId?`: `number` \\| `null`; `commentKind`: [`GithubPrCommentKind`](GithubPrCommentKind.md); `commentSnippet`: `string`; `commentUrl?`: `string` \\| `null`; \\}\n\nMetadata for a notification that a GitHub pull request was commented on.\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `commentGithubId?` | `number` \\| `null` | The GitHub numeric id of the comment, when available. |\n| `commentKind` | [`GithubPrCommentKind`](GithubPrCommentKind.md) | The kind of comment that was posted. |\n| `commentSnippet` | `string` | A truncated excerpt of the comment body. |\n| `commentUrl?` | `string` \\| `null` | The public GitHub URL for the comment, when available. |\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrCommentKind.md -->\n# Type Alias: GithubPrCommentKind\n\n> **GithubPrCommentKind** = `\"issue\"` \\| `\"review_comment\"`\n\nThe kind of GitHub comment that triggered a [`GithubPrComment`] notification.\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrEventAction.md -->\n# Type Alias: GithubPrEventAction\n\n> **GithubPrEventAction** = `\"opened\"` \\| `\"reopened\"` \\| `\"closed\"`\n\nThe GitHub pull request webhook action that triggered the notification.\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrEventStatus.md -->\n# Type Alias: GithubPrEventStatus\n\n> **GithubPrEventStatus** = `\"open\"` \\| `\"closed\"` \\| `\"merged\"`\n\nThe normalized lifecycle status for a GitHub pull request notification.\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrMention.md -->\n# Type Alias: GithubPrMention\n\n> **GithubPrMention** = [`GithubPrNotificationCommon`](GithubPrNotificationCommon.md) & \\{ `commentGithubId?`: `number` \\| `null`; `commentUrl?`: `string` \\| `null`; `location`: [`GithubPrMentionLocation`](GithubPrMentionLocation.md); `textSnippet`: `string`; \\}\n\nMetadata for a notification that the user was mentioned on a GitHub pull request.\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `commentGithubId?` | `number` \\| `null` | The GitHub numeric id of the comment or review containing the mention, when available. |\n| `commentUrl?` | `string` \\| `null` | The public GitHub URL for the text containing the mention, when available. |\n| `location` | [`GithubPrMentionLocation`](GithubPrMentionLocation.md) | Where the mention appeared. |\n| `textSnippet` | `string` | A truncated excerpt of the text containing the mention. |\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrMentionLocation.md -->\n# Type Alias: GithubPrMentionLocation\n\n> **GithubPrMentionLocation** = `\"pr_body\"` \\| `\"comment\"` \\| `\"review\"` \\| `\"review_comment\"`\n\nWhere in a GitHub pull request the user was mentioned.\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrNotificationCommon.md -->\n# Type Alias: GithubPrNotificationCommon\n\n> **GithubPrNotificationCommon** = \\{ `displayName`: `string`; `foreignEntityId`: `string`; `githubKey`: `string`; `number`: `number`; `owner`: `string`; `repo`: `string`; `senderGithubAvatarUrl?`: `string` \\| `null`; `senderGithubLogin?`: `string` \\| `null`; `senderGithubUserId?`: `string` \\| `null`; `title`: `string`; `url`: `string`; \\}\n\nFields shared by every GitHub pull request notification type.\n\nEmbedded with `#[serde(flatten)]` so the wire shape keeps these keys at the\ntop level of the metadata object.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-displayname\"></a> `displayName` | `string` | A compact label suitable for display in the UI. |\n| <a id=\"property-foreignentityid\"></a> `foreignEntityId` | `string` | The source-specific internal foreign entity row id for this pull request. |\n| <a id=\"property-githubkey\"></a> `githubKey` | `string` | The external GitHub key, in `owner/repo/pull/number` format. |\n| <a id=\"property-number\"></a> `number` | `number` | The GitHub pull request number. |\n| <a id=\"property-owner\"></a> `owner` | `string` | The GitHub repository owner or organization. |\n| <a id=\"property-repo\"></a> `repo` | `string` | The GitHub repository name. |\n| <a id=\"property-sendergithubavatarurl\"></a> `senderGithubAvatarUrl?` | `string` \\| `null` | The GitHub avatar URL for the sender, when available. |\n| <a id=\"property-sendergithublogin\"></a> `senderGithubLogin?` | `string` \\| `null` | The GitHub login for the sender, when available. |\n| <a id=\"property-sendergithubuserid\"></a> `senderGithubUserId?` | `string` \\| `null` | The stable GitHub numeric user id for the sender, serialized as a string. |\n| <a id=\"property-title\"></a> `title` | `string` | The GitHub pull request title. Falls back to `display_name` when GitHub has no title. |\n| <a id=\"property-url\"></a> `url` | `string` | The public GitHub URL for the pull request. |\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrReview.md -->\n# Type Alias: GithubPrReview\n\n> **GithubPrReview** = [`GithubPrNotificationCommon`](GithubPrNotificationCommon.md) & \\{ `reviewGithubId?`: `number` \\| `null`; `reviewSnippet?`: `string` \\| `null`; `reviewUrl?`: `string` \\| `null`; `state`: [`GithubPrReviewState`](GithubPrReviewState.md); \\}\n\nMetadata for a notification that a review was submitted on the user's GitHub pull request.\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `reviewGithubId?` | `number` \\| `null` | The GitHub numeric id of the review, when available. |\n| `reviewSnippet?` | `string` \\| `null` | A truncated excerpt of the review body, when any was written. |\n| `reviewUrl?` | `string` \\| `null` | The public GitHub URL for the review, when available. |\n| `state` | [`GithubPrReviewState`](GithubPrReviewState.md) | The review decision state. |\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrReviewState.md -->\n# Type Alias: GithubPrReviewState\n\n> **GithubPrReviewState** = `\"approved\"` \\| `\"changes_requested\"` \\| `\"commented\"`\n\nThe state of a submitted GitHub pull request review.\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubPrStatusChanged.md -->\n# Type Alias: GithubPrStatusChanged\n\n> **GithubPrStatusChanged** = [`GithubPrNotificationCommon`](GithubPrNotificationCommon.md) & \\{ `action`: [`GithubPrEventAction`](GithubPrEventAction.md); `baseBranch?`: `string` \\| `null`; `headBranch?`: `string` \\| `null`; `mergedAt?`: `string` \\| `null`; `previousStatus?`: `null` \\| [`GithubPrEventStatus`](GithubPrEventStatus.md); `status`: [`GithubPrEventStatus`](GithubPrEventStatus.md); \\}\n\nMetadata for a GitHub pull request lifecycle notification.\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `action` | [`GithubPrEventAction`](GithubPrEventAction.md) | The webhook action that triggered this notification. |\n| `baseBranch?` | `string` \\| `null` | The pull request base branch, when available. |\n| `headBranch?` | `string` \\| `null` | The pull request head branch, when available. |\n| `mergedAt?` | `string` \\| `null` | When the pull request was merged, when available. |\n| `previousStatus?` | `null` \\| [`GithubPrEventStatus`](GithubPrEventStatus.md) | - |\n| `status` | [`GithubPrEventStatus`](GithubPrEventStatus.md) | The current normalized pull request status. |\n\n\n<!-- generated/notification/types.gen/type-aliases/GithubReviewRequested.md -->\n# Type Alias: GithubReviewRequested\n\n> **GithubReviewRequested** = [`GithubPrNotificationCommon`](GithubPrNotificationCommon.md) & \\{ `requestedReviewerGithubLogin?`: `string` \\| `null`; `requestedReviewerGithubUserId?`: `string` \\| `null`; \\}\n\nMetadata for a notification that the user's review was requested on a GitHub pull request.\n\n## Type Declaration\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `requestedReviewerGithubLogin?` | `string` \\| `null` | The GitHub login of the requested reviewer, when available. |\n| `requestedReviewerGithubUserId?` | `string` \\| `null` | The stable GitHub numeric user id of the requested reviewer, serialized as a string. |\n\n\n<!-- generated/notification/types.gen/type-aliases/InboxReauthRequiredMetadata.md -->\n# Type Alias: InboxReauthRequiredMetadata\n\n> **InboxReauthRequiredMetadata** = \\{ `emailAddress`: `string`; \\}\n\nMetadata for a notification that a linked inbox's grant has died and the\ninbox must be reconnected. Fanned out to the inbox owner and every delegate,\nsince any of them holding the Google grant can restore sync.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-emailaddress\"></a> `emailAddress` | `string` | The address of the inbox that needs to be reconnected. |\n\n\n<!-- generated/notification/types.gen/type-aliases/InitiativeDiscussionMetadata.md -->\n# Type Alias: InitiativeDiscussionMetadata\n\n> **InitiativeDiscussionMetadata** = \\{ `messageId`: `string`; `owner`: `string`; `projectName`: `string`; `reason`: [`InitiativeDiscussionReason`](InitiativeDiscussionReason.md); `senderDisplayName?`: `string` \\| `null`; `senderProfilePictureUrl?`: `string` \\| `null`; `text`: `string`; `threadId`: `string`; \\}\n\nProject discussion metadata. The notification entity identifies the initiative;\nmessage and thread UUIDs select the discussion inside that project.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-messageid\"></a> `messageId` | `string` | Canonical shared message UUID. |\n| <a id=\"property-owner\"></a> `owner` | `string` | Authenticated project owner. |\n| <a id=\"property-projectname\"></a> `projectName` | `string` | Name displayed in the project header. |\n| <a id=\"property-reason\"></a> `reason` | [`InitiativeDiscussionReason`](InitiativeDiscussionReason.md) | Semantic reason selected by the message delivery domain. |\n| <a id=\"property-senderdisplayname\"></a> `senderDisplayName?` | `string` \\| `null` | Public display name for a bot author. |\n| <a id=\"property-senderprofilepictureurl\"></a> `senderProfilePictureUrl?` | `string` \\| `null` | Optional avatar for push notification attachments. |\n| <a id=\"property-text\"></a> `text` | `string` | Posted Markdown content. |\n| <a id=\"property-threadid\"></a> `threadId` | `string` | Canonical discussion root UUID. |\n\n\n<!-- generated/notification/types.gen/type-aliases/InitiativeDiscussionReason.md -->\n# Type Alias: InitiativeDiscussionReason\n\n> **InitiativeDiscussionReason** = `\"mention\"` \\| `\"reply\"` \\| `\"assignee\"` \\| `\"owner\"`\n\nWhy a project discussion notification was delivered.\n\n\n<!-- generated/notification/types.gen/type-aliases/InviteToTeamMetadata.md -->\n# Type Alias: InviteToTeamMetadata\n\n> **InviteToTeamMetadata** = \\{ `invitedBy`: `string`; `inviteePlan?`: [`InviteePlan`](InviteePlan.md); `reminder?`: `boolean`; `role?`: `string` \\| `null`; `senderProfilePictureUrl?`: `string` \\| `null`; `teamId`: `string`; `teamInviteId`: `string`; `teamName`: `string`; \\}\n\nMetadata for when a user is invited to a team.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-invitedby\"></a> `invitedBy` | `string` | The user who sent the invitation |\n| <a id=\"property-inviteeplan\"></a> `inviteePlan?` | [`InviteePlan`](InviteePlan.md) | What the invitee gets by joining, as the team stood when the invite was sent. |\n| <a id=\"property-reminder\"></a> `reminder?` | `boolean` | Whether this email reminds the invitee of an invite they have not answered. |\n| <a id=\"property-role\"></a> `role?` | `string` \\| `null` | Role/permission level in the team |\n| <a id=\"property-senderprofilepictureurl\"></a> `senderProfilePictureUrl?` | `string` \\| `null` | The sender's profile picture URL, if available. |\n| <a id=\"property-teamid\"></a> `teamId` | `string` | The unique identifier of the team |\n| <a id=\"property-teaminviteid\"></a> `teamInviteId` | `string` | The unique identifier of the team invite |\n| <a id=\"property-teamname\"></a> `teamName` | `string` | The name of the team being invited to |\n\n\n<!-- generated/notification/types.gen/type-aliases/InviteePlan.md -->\n# Type Alias: InviteePlan\n\n> **InviteePlan** = `\"free\"` \\| `\"premium\"`\n\nWhat a team invitee gets by joining.\n\n\n<!-- generated/notification/types.gen/type-aliases/MentionedInDocumentCommentMetadata.md -->\n# Type Alias: MentionedInDocumentCommentMetadata\n\n> **MentionedInDocumentCommentMetadata** = \\{ `commentId`: [`CommentRef`](CommentRef.md); `documentName`: `string`; `fileType?`: `string` \\| `null`; `mentionId`: `string`; `owner`: `string`; `senderDisplayName?`: `string` \\| `null`; `senderProfilePictureUrl?`: `string` \\| `null`; `subType?`: `null` \\| [`NotificationDocumentSubType`](NotificationDocumentSubType.md); `text`: `string`; `threadId`: [`CommentRef`](CommentRef.md); \\}\n\nNotification sent when a user is mentioned in a document comment.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-commentid\"></a> `commentId` | [`CommentRef`](CommentRef.md) | the comment id |\n| <a id=\"property-documentname\"></a> `documentName` | `string` | The name of the document. |\n| <a id=\"property-filetype\"></a> `fileType?` | `string` \\| `null` | The file type of the document. |\n| <a id=\"property-mentionid\"></a> `mentionId` | `string` | The mention ID. |\n| <a id=\"property-owner\"></a> `owner` | `string` | The owner of the document. |\n| <a id=\"property-senderdisplayname\"></a> `senderDisplayName?` | `string` \\| `null` | Public bot name when the author is an agent rather than a Macro user. |\n| <a id=\"property-senderprofilepictureurl\"></a> `senderProfilePictureUrl?` | `string` \\| `null` | - |\n| <a id=\"property-subtype\"></a> `subType?` | `null` \\| [`NotificationDocumentSubType`](NotificationDocumentSubType.md) | - |\n| <a id=\"property-text\"></a> `text` | `string` | the text of the comment |\n| <a id=\"property-threadid\"></a> `threadId` | [`CommentRef`](CommentRef.md) | the thread id |\n\n\n<!-- generated/notification/types.gen/type-aliases/NewEmailMetadata.md -->\n# Type Alias: NewEmailMetadata\n\n> **NewEmailMetadata** = \\{ `sender?`: `string` \\| `null`; `snippet`: `string`; `subject`: `string`; `threadId`: `string`; `toEmail`: `string`; \\}\n\n## Properties\n\n| Property | Type |\n| ------ | ------ |\n| <a id=\"property-sender\"></a> `sender?` | `string` \\| `null` |\n| <a id=\"property-snippet\"></a> `snippet` | `string` |\n| <a id=\"property-subject\"></a> `subject` | `string` |\n| <a id=\"property-threadid\"></a> `threadId` | `string` |\n| <a id=\"property-toemail\"></a> `toEmail` | `string` |\n\n\n<!-- generated/notification/types.gen/type-aliases/NotifEvent.md -->\n# Type Alias: NotifEvent\n\n> **NotifEvent** = \\{ `content`: [`ChannelMentionMetadata`](ChannelMentionMetadata.md); `tag`: `\"channel_mention\"`; \\} \\| \\{ `content`: [`DocumentMentionMetadata`](DocumentMentionMetadata.md); `tag`: `\"document_mention\"`; \\} \\| \\{ `content`: [`MentionedInDocumentCommentMetadata`](MentionedInDocumentCommentMetadata.md); `tag`: `\"mentioned_in_document_comment\"`; \\} \\| \\{ `content`: [`RepliedToDocumentCommentThreadMetadata`](RepliedToDocumentCommentThreadMetadata.md); `tag`: `\"replied_to_document_comment_thread\"`; \\} \\| \\{ `content`: [`CommentedOnDocumentMetadata`](CommentedOnDocumentMetadata.md); `tag`: `\"commented_on_document\"`; \\} \\| \\{ `content`: [`EntityAccessRequestedMetadata`](EntityAccessRequestedMetadata.md); `tag`: `\"entity_access_requested\"`; \\} \\| \\{ `content`: [`EntityAccessGrantedMetadata`](EntityAccessGrantedMetadata.md); `tag`: `\"entity_access_granted\"`; \\} \\| \\{ `content`: [`InitiativeDiscussionMetadata`](InitiativeDiscussionMetadata.md); `tag`: `\"initiative_discussion\"`; \\} \\| \\{ `content`: [`CrmDiscussionMetadata`](CrmDiscussionMetadata.md); `tag`: `\"crm_discussion\"`; \\} \\| \\{ `content`: [`ChannelInviteMetadata`](ChannelInviteMetadata.md); `tag`: `\"channel_invite\"`; \\} \\| \\{ `content`: [`ChannelMessageSendMetadata`](ChannelMessageSendMetadata.md); `tag`: `\"channel_message_send\"`; \\} \\| \\{ `content`: [`ChannelReplyMetadata`](ChannelReplyMetadata.md); `tag`: `\"channel_message_reply\"`; \\} \\| \\{ `content`: [`CallStartedMetadata`](CallStartedMetadata.md); `tag`: `\"call_started\"`; \\} \\| \\{ `content`: [`NewEmailMetadata`](NewEmailMetadata.md); `tag`: `\"new_email\"`; \\} \\| \\{ `content`: [`InboxReauthRequiredMetadata`](InboxReauthRequiredMetadata.md); `tag`: `\"inbox_reauth_required\"`; \\} \\| \\{ `content`: [`InviteToTeamMetadata`](InviteToTeamMetadata.md); `tag`: `\"invite_to_team\"`; \\} \\| \\{ `content`: [`TaskAssignedMetadata`](TaskAssignedMetadata.md); `tag`: `\"task_assigned\"`; \\} \\| \\{ `content`: [`ReminderMetadata`](ReminderMetadata.md); `tag`: `\"reminder\"`; \\} \\| \\{ `content`: [`CalendarEventReminderMetadata`](CalendarEventReminderMetadata.md); `tag`: `\"calendar_event_reminder\"`; \\} \\| \\{ `content`: [`AiResponseMetadata`](AiResponseMetadata.md); `tag`: `\"ai_response\"`; \\} \\| \\{ `content`: [`GithubPrStatusChanged`](GithubPrStatusChanged.md); `tag`: `\"github_pr_status_changed\"`; \\} \\| \\{ `content`: [`GithubPrCheckRun`](GithubPrCheckRun.md); `tag`: `\"github_pr_check_run\"`; \\} \\| \\{ `content`: [`GithubReviewRequested`](GithubReviewRequested.md); `tag`: `\"github_review_requested\"`; \\} \\| \\{ `content`: [`GithubPrComment`](GithubPrComment.md); `tag`: `\"github_pr_comment\"`; \\} \\| \\{ `content`: [`GithubPrMention`](GithubPrMention.md); `tag`: `\"github_pr_mention\"`; \\} \\| \\{ `content`: [`GithubPrReview`](GithubPrReview.md); `tag`: `\"github_pr_review\"`; \\} \\| \\{ `content`: [`AgentSessionSettledMetadata`](AgentSessionSettledMetadata.md); `tag`: `\"agent_session_settled\"`; \\} \\| \\{ `content`: [`AgentSessionWaitingForInputMetadata`](AgentSessionWaitingForInputMetadata.md); `tag`: `\"agent_session_waiting_for_input\"`; \\} \\| \\{ `content`: [`AgentSessionMentionedMetadata`](AgentSessionMentionedMetadata.md); `tag`: `\"agent_session_mentioned\"`; \\} \\| \\{ `content`: [`ChannelMessageReactionMetadata`](ChannelMessageReactionMetadata.md); `tag`: `\"channel_message_reaction\"`; \\} \\| \\{ `content`: [`CalendarEventJoinRequestMetadata`](CalendarEventJoinRequestMetadata.md); `tag`: `\"calendar_event_join_request\"`; \\}\n\nMirrors [`model_notifications::NotificationEvent`] but uses `tag` / `content`\nas the serde adjacently-tagged field names so it can be deserialized from the\nshape produced by [`UserNotificationRow::into_tagged`] +\n[`UserNotificationRow::into_json`].\n\nOnly includes variants whose metadata types implement the `Notification` trait.\n\n## Union Members\n\n### Type Literal\n\n\\{ `content`: [`ChannelMentionMetadata`](ChannelMentionMetadata.md); `tag`: `\"channel_mention\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`ChannelMentionMetadata`](ChannelMentionMetadata.md) | Someone mentioned you in a channel. |\n| `tag` | `\"channel_mention\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`DocumentMentionMetadata`](DocumentMentionMetadata.md); `tag`: `\"document_mention\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`DocumentMentionMetadata`](DocumentMentionMetadata.md) | Someone mentioned a document in a channel. |\n| `tag` | `\"document_mention\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`MentionedInDocumentCommentMetadata`](MentionedInDocumentCommentMetadata.md); `tag`: `\"mentioned_in_document_comment\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`MentionedInDocumentCommentMetadata`](MentionedInDocumentCommentMetadata.md) | User was mentioned in a comment in a document |\n| `tag` | `\"mentioned_in_document_comment\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`RepliedToDocumentCommentThreadMetadata`](RepliedToDocumentCommentThreadMetadata.md); `tag`: `\"replied_to_document_comment_thread\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`RepliedToDocumentCommentThreadMetadata`](RepliedToDocumentCommentThreadMetadata.md) | Someone replied to a document comment thread the user participated in. |\n| `tag` | `\"replied_to_document_comment_thread\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`CommentedOnDocumentMetadata`](CommentedOnDocumentMetadata.md); `tag`: `\"commented_on_document\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`CommentedOnDocumentMetadata`](CommentedOnDocumentMetadata.md) | Someone commented on a document the user owns. |\n| `tag` | `\"commented_on_document\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`EntityAccessRequestedMetadata`](EntityAccessRequestedMetadata.md); `tag`: `\"entity_access_requested\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`EntityAccessRequestedMetadata`](EntityAccessRequestedMetadata.md) | Someone requested more access to a shared entity. |\n| `tag` | `\"entity_access_requested\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`EntityAccessGrantedMetadata`](EntityAccessGrantedMetadata.md); `tag`: `\"entity_access_granted\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`EntityAccessGrantedMetadata`](EntityAccessGrantedMetadata.md) | An owner granted requested access. |\n| `tag` | `\"entity_access_granted\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`InitiativeDiscussionMetadata`](InitiativeDiscussionMetadata.md); `tag`: `\"initiative_discussion\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`InitiativeDiscussionMetadata`](InitiativeDiscussionMetadata.md) | Someone commented, replied, or mentioned the recipient on a project. |\n| `tag` | `\"initiative_discussion\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`CrmDiscussionMetadata`](CrmDiscussionMetadata.md); `tag`: `\"crm_discussion\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`CrmDiscussionMetadata`](CrmDiscussionMetadata.md) | Someone commented, replied, or mentioned the recipient on a CRM company or contact. |\n| `tag` | `\"crm_discussion\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`ChannelInviteMetadata`](ChannelInviteMetadata.md); `tag`: `\"channel_invite\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`ChannelInviteMetadata`](ChannelInviteMetadata.md) | The user was invited to a channel. |\n| `tag` | `\"channel_invite\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`ChannelMessageSendMetadata`](ChannelMessageSendMetadata.md); `tag`: `\"channel_message_send\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`ChannelMessageSendMetadata`](ChannelMessageSendMetadata.md) | A user sent a message in a channel. |\n| `tag` | `\"channel_message_send\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`ChannelReplyMetadata`](ChannelReplyMetadata.md); `tag`: `\"channel_message_reply\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`ChannelReplyMetadata`](ChannelReplyMetadata.md) | Someone replied to a thread in a channel that the user is part of. |\n| `tag` | `\"channel_message_reply\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`CallStartedMetadata`](CallStartedMetadata.md); `tag`: `\"call_started\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`CallStartedMetadata`](CallStartedMetadata.md) | A call has started in a channel the user is a member of. The `call-started` alias keeps rows persisted before the type name was normalized to snake_case (`call_started`) deserializable. |\n| `tag` | `\"call_started\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`NewEmailMetadata`](NewEmailMetadata.md); `tag`: `\"new_email\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`NewEmailMetadata`](NewEmailMetadata.md) | A new email has been sent to the user. |\n| `tag` | `\"new_email\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`InboxReauthRequiredMetadata`](InboxReauthRequiredMetadata.md); `tag`: `\"inbox_reauth_required\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`InboxReauthRequiredMetadata`](InboxReauthRequiredMetadata.md) | A linked inbox's grant died and must be reconnected. |\n| `tag` | `\"inbox_reauth_required\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`InviteToTeamMetadata`](InviteToTeamMetadata.md); `tag`: `\"invite_to_team\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`InviteToTeamMetadata`](InviteToTeamMetadata.md) | A user was invited to a team. |\n| `tag` | `\"invite_to_team\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`TaskAssignedMetadata`](TaskAssignedMetadata.md); `tag`: `\"task_assigned\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`TaskAssignedMetadata`](TaskAssignedMetadata.md) | A user was assigned to a task. |\n| `tag` | `\"task_assigned\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`ReminderMetadata`](ReminderMetadata.md); `tag`: `\"reminder\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`ReminderMetadata`](ReminderMetadata.md) | A reminder the user set for themselves came due. |\n| `tag` | `\"reminder\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`CalendarEventReminderMetadata`](CalendarEventReminderMetadata.md); `tag`: `\"calendar_event_reminder\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`CalendarEventReminderMetadata`](CalendarEventReminderMetadata.md) | A calendar event alarm came due. |\n| `tag` | `\"calendar_event_reminder\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`AiResponseMetadata`](AiResponseMetadata.md); `tag`: `\"ai_response\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`AiResponseMetadata`](AiResponseMetadata.md) | An AI assistant responded to a chat. |\n| `tag` | `\"ai_response\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`GithubPrStatusChanged`](GithubPrStatusChanged.md); `tag`: `\"github_pr_status_changed\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`GithubPrStatusChanged`](GithubPrStatusChanged.md) | A GitHub pull request changed lifecycle state. The `github_pr_event` alias keeps rows and queue messages persisted before the rename deserializable. |\n| `tag` | `\"github_pr_status_changed\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`GithubPrCheckRun`](GithubPrCheckRun.md); `tag`: `\"github_pr_check_run\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`GithubPrCheckRun`](GithubPrCheckRun.md) | A GitHub pull request check run completed. |\n| `tag` | `\"github_pr_check_run\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`GithubReviewRequested`](GithubReviewRequested.md); `tag`: `\"github_review_requested\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`GithubReviewRequested`](GithubReviewRequested.md) | The user's review was requested on a GitHub pull request. |\n| `tag` | `\"github_review_requested\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`GithubPrComment`](GithubPrComment.md); `tag`: `\"github_pr_comment\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`GithubPrComment`](GithubPrComment.md) | A GitHub pull request was commented on. |\n| `tag` | `\"github_pr_comment\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`GithubPrMention`](GithubPrMention.md); `tag`: `\"github_pr_mention\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`GithubPrMention`](GithubPrMention.md) | The user was mentioned on a GitHub pull request. |\n| `tag` | `\"github_pr_mention\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`GithubPrReview`](GithubPrReview.md); `tag`: `\"github_pr_review\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`GithubPrReview`](GithubPrReview.md) | A review was submitted on the user's GitHub pull request. |\n| `tag` | `\"github_pr_review\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`AgentSessionSettledMetadata`](AgentSessionSettledMetadata.md); `tag`: `\"agent_session_settled\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`AgentSessionSettledMetadata`](AgentSessionSettledMetadata.md) | An agent finished a turn with nothing queued behind it. |\n| `tag` | `\"agent_session_settled\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`AgentSessionWaitingForInputMetadata`](AgentSessionWaitingForInputMetadata.md); `tag`: `\"agent_session_waiting_for_input\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`AgentSessionWaitingForInputMetadata`](AgentSessionWaitingForInputMetadata.md) | An agent is blocked on a question for the session's owner. |\n| `tag` | `\"agent_session_waiting_for_input\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`AgentSessionMentionedMetadata`](AgentSessionMentionedMetadata.md); `tag`: `\"agent_session_mentioned\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`AgentSessionMentionedMetadata`](AgentSessionMentionedMetadata.md) | The user was named in a prompt to an agent session. |\n| `tag` | `\"agent_session_mentioned\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`ChannelMessageReactionMetadata`](ChannelMessageReactionMetadata.md); `tag`: `\"channel_message_reaction\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`ChannelMessageReactionMetadata`](ChannelMessageReactionMetadata.md) | Someone reacted to one of the user's channel messages. |\n| `tag` | `\"channel_message_reaction\"` | - |\n\n***\n\n### Type Literal\n\n\\{ `content`: [`CalendarEventJoinRequestMetadata`](CalendarEventJoinRequestMetadata.md); `tag`: `\"calendar_event_join_request\"`; \\}\n\n| Name | Type | Description |\n| ------ | ------ | ------ |\n| `content` | [`CalendarEventJoinRequestMetadata`](CalendarEventJoinRequestMetadata.md) | A channel member asked to be added as a guest of an event the user shared with the channel. |\n| `tag` | `\"calendar_event_join_request\"` | - |\n\n\n<!-- generated/notification/types.gen/type-aliases/NotificationDocumentSubType.md -->\n# Type Alias: NotificationDocumentSubType\n\n> **NotificationDocumentSubType** = \\{ `type`: `\"task\"`; \\} \\| \\{ `type`: `\"snippet\"`; \\} \\| \\{ `type`: `\"skill\"`; \\} \\| \\{ `type`: `\"initiative_description\"`; \\}\n\nThe sub type of a document in a notification.\nSerializes as `{ \"type\": \"task\" }` matching the storage service pattern.\n\n\n<!-- generated/notification/types.gen/type-aliases/NotificationState.md -->\n# Type Alias: NotificationState\n\n> **NotificationState** = `\"unseen\"` \\| `\"seen\"` \\| `\"done\"`\n\nThe mutually exclusive lifecycle states of a user's notification.\n\n\n<!-- generated/notification/types.gen/type-aliases/ReminderMetadata.md -->\n# Type Alias: ReminderMetadata\n\n> **ReminderMetadata** = \\{ `description`: `string`; `reminderId`: `string`; `scheduledFor?`: `string` \\| `null`; \\}\n\nMetadata for a reminder the user set for themselves coming due.\n\nThere is no sender: a reminder is self-set, so the dispatcher sends it with\n`sender_id: None` (a recipient who is also the sender is filtered out of\ntheir own notification). Every formatter here must therefore work without\none.\n\nThe associated entity, when there is one, lives on the notification row\nrather than in here, and clients resolve its name from that — so the\ndispatcher does not have to look up a name across five entity types.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-description\"></a> `description` | `string` | What the user asked to be reminded about. |\n| <a id=\"property-reminderid\"></a> `reminderId` | `string` | The reminder that fired. |\n| <a id=\"property-scheduledfor\"></a> `scheduledFor?` | `string` \\| `null` | Which firing this is — the occurrence the reminder came due for. What distinguishes two firings of the same recurring reminder, which are otherwise identical: same id, same description. The collapse key is built from it, so without it Tuesday's alert would replace Monday's unread one on the lock screen. Optional because notifications written before recurring dispatch existed have no such field, and they still have to read back. |\n\n\n<!-- generated/notification/types.gen/type-aliases/RepliedToDocumentCommentThreadMetadata.md -->\n# Type Alias: RepliedToDocumentCommentThreadMetadata\n\n> **RepliedToDocumentCommentThreadMetadata** = \\{ `commentId`: [`CommentRef`](CommentRef.md); `documentName`: `string`; `fileType?`: `string` \\| `null`; `owner`: `string`; `senderDisplayName?`: `string` \\| `null`; `senderProfilePictureUrl?`: `string` \\| `null`; `subType?`: `null` \\| [`NotificationDocumentSubType`](NotificationDocumentSubType.md); `text`: `string`; `threadId`: [`CommentRef`](CommentRef.md); \\}\n\nNotification sent when someone replies to a document comment thread.\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-commentid\"></a> `commentId` | [`CommentRef`](CommentRef.md) | the comment id |\n| <a id=\"property-documentname\"></a> `documentName` | `string` | The name of the document. |\n| <a id=\"property-filetype\"></a> `fileType?` | `string` \\| `null` | The file type of the document. |\n| <a id=\"property-owner\"></a> `owner` | `string` | The owner of the document. |\n| <a id=\"property-senderdisplayname\"></a> `senderDisplayName?` | `string` \\| `null` | Public bot name when the author is an agent rather than a Macro user. |\n| <a id=\"property-senderprofilepictureurl\"></a> `senderProfilePictureUrl?` | `string` \\| `null` | - |\n| <a id=\"property-subtype\"></a> `subType?` | `null` \\| [`NotificationDocumentSubType`](NotificationDocumentSubType.md) | - |\n| <a id=\"property-text\"></a> `text` | `string` | the text of the comment |\n| <a id=\"property-threadid\"></a> `threadId` | [`CommentRef`](CommentRef.md) | the thread id |\n\n\n<!-- generated/notification/types.gen/type-aliases/RequestedAccessLevel.md -->\n# Type Alias: RequestedAccessLevel\n\n> **RequestedAccessLevel** = `\"view\"` \\| `\"comment\"` \\| `\"edit\"`\n\nPermission level used by an access request, excluding ownership.\n\n\n<!-- generated/notification/types.gen/type-aliases/TaskAssignedMetadata.md -->\n# Type Alias: TaskAssignedMetadata\n\n> **TaskAssignedMetadata** = \\{ `assignedBy`: `string`; `senderProfilePictureUrl?`: `string` \\| `null`; `subType?`: `null` \\| [`NotificationDocumentSubType`](NotificationDocumentSubType.md); `taskId`: `string`; `taskName?`: `string` \\| `null`; \\}\n\nMetadata for when a user is assigned to a task\n\n## Properties\n\n| Property | Type | Description |\n| ------ | ------ | ------ |\n| <a id=\"property-assignedby\"></a> `assignedBy` | `string` | The user who assigned the task |\n| <a id=\"property-senderprofilepictureurl\"></a> `senderProfilePictureUrl?` | `string` \\| `null` | - |\n| <a id=\"property-subtype\"></a> `subType?` | `null` \\| [`NotificationDocumentSubType`](NotificationDocumentSubType.md) | - |\n| <a id=\"property-taskid\"></a> `taskId` | `string` | The unique identifier of the task |\n| <a id=\"property-taskname\"></a> `taskName?` | `string` \\| `null` | The name of the task (optional) |\n\n\n<!-- src/entities/notifications/namespace/classes/NotificationNamespace.md -->\n# Class: NotificationNamespace\n\n## Constructors\n\n### Constructor\n\n> **new NotificationNamespace**(`client`): `NotificationNamespace`\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `client` | `MacroClient` |\n\n#### Returns\n\n`NotificationNamespace`\n\n## Methods\n\n### byId()\n\n> **byId**(`id`): [`Notification`](../../notification/classes/Notification.md)\n\nA handle to a notification by id.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `id` | `string` |\n\n#### Returns\n\n[`Notification`](../../notification/classes/Notification.md)\n\n***\n\n### delete()\n\n> **delete**(`ids`): `Promise`\\<`void`\\>\n\nDelete a batch of notifications.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `ids` | `string`[] |\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### disableType()\n\n> **disableType**(`type`): `Promise`\\<`void`\\>\n\nDisable delivery of a notification type.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `type` | `\"reminder\"` \\| `\"channel_mention\"` \\| `\"document_mention\"` \\| `\"mentioned_in_document_comment\"` \\| `\"replied_to_document_comment_thread\"` \\| `\"commented_on_document\"` \\| `\"entity_access_requested\"` \\| `\"entity_access_granted\"` \\| `\"initiative_discussion\"` \\| `\"crm_discussion\"` \\| `\"channel_invite\"` \\| `\"channel_message_send\"` \\| `\"channel_message_reply\"` \\| `\"call_started\"` \\| `\"new_email\"` \\| `\"inbox_reauth_required\"` \\| `\"invite_to_team\"` \\| `\"task_assigned\"` \\| `\"calendar_event_reminder\"` \\| `\"ai_response\"` \\| `\"github_pr_status_changed\"` \\| `\"github_pr_check_run\"` \\| `\"github_review_requested\"` \\| `\"github_pr_comment\"` \\| `\"github_pr_mention\"` \\| `\"github_pr_review\"` \\| `\"agent_session_settled\"` \\| `\"agent_session_waiting_for_input\"` \\| `\"agent_session_mentioned\"` \\| `\"channel_message_reaction\"` \\| `\"calendar_event_join_request\"` |\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### enableType()\n\n> **enableType**(`type`): `Promise`\\<`void`\\>\n\nRe-enable delivery of a notification type.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `type` | `\"reminder\"` \\| `\"channel_mention\"` \\| `\"document_mention\"` \\| `\"mentioned_in_document_comment\"` \\| `\"replied_to_document_comment_thread\"` \\| `\"commented_on_document\"` \\| `\"entity_access_requested\"` \\| `\"entity_access_granted\"` \\| `\"initiative_discussion\"` \\| `\"crm_discussion\"` \\| `\"channel_invite\"` \\| `\"channel_message_send\"` \\| `\"channel_message_reply\"` \\| `\"call_started\"` \\| `\"new_email\"` \\| `\"inbox_reauth_required\"` \\| `\"invite_to_team\"` \\| `\"task_assigned\"` \\| `\"calendar_event_reminder\"` \\| `\"ai_response\"` \\| `\"github_pr_status_changed\"` \\| `\"github_pr_check_run\"` \\| `\"github_review_requested\"` \\| `\"github_pr_comment\"` \\| `\"github_pr_mention\"` \\| `\"github_pr_review\"` \\| `\"agent_session_settled\"` \\| `\"agent_session_waiting_for_input\"` \\| `\"agent_session_mentioned\"` \\| `\"channel_message_reaction\"` \\| `\"calendar_event_join_request\"` |\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### list()\n\n> **list**(`opts?`): `AsyncGenerator`\\<[`Notification`](../../notification/classes/Notification.md)\\>\n\nThe viewer's notification feed, most recent first, auto-paginated.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `opts?` | \\{ `pageSize?`: `number`; \\} |\n| `opts.pageSize?` | `number` |\n\n#### Returns\n\n`AsyncGenerator`\\<[`Notification`](../../notification/classes/Notification.md)\\>\n\n***\n\n### markDone()\n\n> **markDone**(`ids`): `Promise`\\<`void`\\>\n\nMark a batch of notifications as done.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `ids` | `string`[] |\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### markSeen()\n\n> **markSeen**(`ids`): `Promise`\\<`void`\\>\n\nMark a batch of notifications as seen.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `ids` | `string`[] |\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### preferences()\n\n> **preferences**(): `Promise`\\<[`GetNotificationTypePreferencesResponse`](../../../../../generated/notification/types.gen/type-aliases/GetNotificationTypePreferencesResponse.md)\\>\n\nThe viewer's notification type preferences (disabled types).\n\n#### Returns\n\n`Promise`\\<[`GetNotificationTypePreferencesResponse`](../../../../../generated/notification/types.gen/type-aliases/GetNotificationTypePreferencesResponse.md)\\>\n\n\n<!-- src/entities/notifications/namespace/type-aliases/NotificationType.md -->\n# Type Alias: NotificationType\n\n> **NotificationType** = [`NotifEvent`](../../../../../generated/notification/types.gen/type-aliases/NotifEvent.md)\\[`\"tag\"`\\]\n\nA notification event type name, e.g. `channel_mention`.\n\n\n<!-- src/entities/notifications/notification/classes/Notification.md -->\n# Class: Notification\n\nA notification in the viewer's feed.\n\n## Extends\n\n- [`MacroEntity`](../../../entity/classes/MacroEntity.md)\\<`NotificationDetail`\\>\n\n## Properties\n\n| Property | Modifier | Type | Description | Inherited from |\n| ------ | ------ | ------ | ------ | ------ |\n| <a id=\"property-createdat\"></a> `createdAt` | `readonly` | () => `Promise`\\<`string`\\> | When the notification was created. | - |\n| <a id=\"property-deletedat\"></a> `deletedAt` | `readonly` | () => `Promise`\\<`string` \\| `undefined`\\> | When the notification was deleted, if it has been. | - |\n| <a id=\"property-done\"></a> `done` | `readonly` | () => `Promise`\\<`boolean`\\> | Whether the notification is completed. | - |\n| <a id=\"property-id\"></a> `id` | `public readonly` | `string` | - | [`MacroEntity`](../../../entity/classes/MacroEntity.md).[`id`](../../../entity/classes/MacroEntity.md#property-id) |\n| <a id=\"property-metadata\"></a> `metadata` | `readonly` | () => `Promise`\\<[`NotifEvent`](../../../../../generated/notification/types.gen/type-aliases/NotifEvent.md)\\> | The typed notification payload (tagged by event type). | - |\n| <a id=\"property-owner\"></a> `owner` | `readonly` | () => `Promise`\\<[`User`](../../../users/user/classes/User.md)\\> | The user who owns (receives) this notification. | - |\n| <a id=\"property-sender\"></a> `sender` | `readonly` | () => `Promise`\\<[`User`](../../../users/user/classes/User.md) \\| `undefined`\\> | The user who triggered the notification, if any. | - |\n| <a id=\"property-sent\"></a> `sent` | `readonly` | () => `Promise`\\<`boolean`\\> | Whether the notification has been sent (delivered out of band). | - |\n| <a id=\"property-state\"></a> `state` | `readonly` | () => `Promise`\\<[`NotificationState`](../../../../../generated/notification/types.gen/type-aliases/NotificationState.md)\\> | The authoritative lifecycle state, independent of viewing timestamps. | - |\n| <a id=\"property-type\"></a> `type` | `readonly` | () => `Promise`\\<`string`\\> | The notification event type (e.g. `channel_mention`). | - |\n| <a id=\"property-updatedat\"></a> `updatedAt` | `readonly` | () => `Promise`\\<`string`\\> | When the notification was last updated. | - |\n| <a id=\"property-viewedat\"></a> `viewedAt` | `readonly` | () => `Promise`\\<`string` \\| `undefined`\\> | When the notification was viewed, if it has been seen. | - |\n\n## Methods\n\n### delete()\n\n> **delete**(): `Promise`\\<`void`\\>\n\nDelete the notification.\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### markDone()\n\n> **markDone**(): `Promise`\\<`void`\\>\n\nMark the notification as done.\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### markSeen()\n\n> **markSeen**(): `Promise`\\<`void`\\>\n\nMark the notification as seen.\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### markUndone()\n\n> **markUndone**(): `Promise`\\<`void`\\>\n\nMove the notification back to not-done.\n\n#### Returns\n\n`Promise`\\<`void`\\>\n\n***\n\n### seen()\n\n> **seen**(): `Promise`\\<`boolean`\\>\n\nWhether the notification is acknowledged (seen or done).\n\n#### Returns\n\n`Promise`\\<`boolean`\\>\n\n***\n\n### toJSON()\n\n> **toJSON**(): \\{ `detail?`: [`ApiUserNotification`](../../../../../generated/notification/types.gen/type-aliases/ApiUserNotification.md); `id`: `string`; \\}\n\n#### Returns\n\n\\{ `detail?`: [`ApiUserNotification`](../../../../../generated/notification/types.gen/type-aliases/ApiUserNotification.md); `id`: `string`; \\}\n\n| Name | Type |\n| ------ | ------ |\n| `detail?` | [`ApiUserNotification`](../../../../../generated/notification/types.gen/type-aliases/ApiUserNotification.md) |\n| `id` | `string` |\n\n#### Inherited from\n\n[`MacroEntity`](../../../entity/classes/MacroEntity.md).[`toJSON`](../../../entity/classes/MacroEntity.md#tojson)\n\n***\n\n### byId()\n\n> `static` **byId**(`client`, `id`): `Notification`\n\nA handle to a notification by id. Details load on first access.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `client` | `MacroClient` |\n| `id` | `string` |\n\n#### Returns\n\n`Notification`\n\n***\n\n### from()\n\n> `static` **from**(`client`, `data`): `Notification`\n\nBuild a notification from a list-endpoint record (pre-seeded, no fetch).\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `client` | `MacroClient` |\n| `data` | [`ApiUserNotification`](../../../../../generated/notification/types.gen/type-aliases/ApiUserNotification.md) |\n\n#### Returns\n\n`Notification`\n\n***\n\n### list()\n\n> `static` **list**(`client`, `opts?`): `AsyncGenerator`\\<`Notification`\\>\n\nThe viewer's notification feed, most recent first, auto-paginated.\n\n#### Parameters\n\n| Parameter | Type |\n| ------ | ------ |\n| `client` | `MacroClient` |\n| `opts?` | \\{ `pageSize?`: `number`; `states?`: [`NotificationState`](../../../../../generated/notification/types.gen/type-aliases/NotificationState.md)[]; \\} |\n| `opts.pageSize?` | `number` |\n| `opts.states?` | [`NotificationState`](../../../../../generated/notification/types.gen/type-aliases/NotificationState.md)[] |\n\n#### Returns\n\n`AsyncGenerator`\\<`Notification`\\>\n"
},
{
"name": "pins",
diff --git a/crates/invite_email/AGENTS.md b/crates/invite_email/AGENTS.md
index 653560d966..7b3065dc3f 100644
--- a/crates/invite_email/AGENTS.md
+++ b/crates/invite_email/AGENTS.md
@@ -50,6 +50,10 @@ invites, and the colleague-joined email.
sender, `teams`' `invite_users_to_team`, derives it the way `join_team`
grants entitlements: Pro only from an enterprise team or one with a
subscription. Never let the copy promise more than the join grants.
+- `InviteToTeamMetadata.reminder` marks the reminder emails `teams` sends for
+ unanswered invites; it only prefixes the subject with "Reminder:". A
+ reminder shares the invite's rate-limit bucket (one email per invite per
+ 2 days), so reminders must stay more than 2 days apart.
- Metadata is queued and stored as JSON, and the notification service
publishes it in its OpenAPI spec. A new field needs `#[serde(default)]` so
payloads queued before a deploy still deserialize, and a regenerated web
diff --git a/crates/invite_email/src/lib.rs b/crates/invite_email/src/lib.rs
index 93f8cb5906..79947a7f31 100644
--- a/crates/invite_email/src/lib.rs
+++ b/crates/invite_email/src/lib.rs
@@ -293,6 +293,10 @@ pub struct InviteToTeamMetadata {
/// What the invitee gets by joining, as the team stood when the invite was sent.
#[serde(default, alias = "invitee_plan")]
pub invitee_plan: InviteePlan,
+
+ /// Whether this email reminds the invitee of an invite they have not answered.
+ #[serde(default)]
+ pub reminder: bool,
}
/// What a team invitee gets by joining.
@@ -345,7 +349,8 @@ impl NotificationExtEmail for InviteToTeamMetadata {
fn format_email(&self) -> EmailContent {
EmailContent {
subject: format!(
- "{} invited you to join {} on Macro",
+ "{}{} invited you to join {} on Macro",
+ if self.reminder { "Reminder: " } else { "" },
self.inviter(),
self.team_name
),
diff --git a/crates/invite_email/src/test.rs b/crates/invite_email/src/test.rs
index 324239ed3d..a89db5a0b4 100644
--- a/crates/invite_email/src/test.rs
+++ b/crates/invite_email/src/test.rs
@@ -119,6 +119,7 @@ fn team_invite_rate_limit_key_is_per_invite() {
role: None,
sender_profile_picture_url: None,
invitee_plan: InviteePlan::Free,
+ reminder: false,
};
let to_carol = InviteToTeamMetadata {
team_invite_id: Uuid::from_u128(11),
@@ -304,6 +305,7 @@ fn invitation_logos_keep_the_png_aspect_ratio() {
role: None,
sender_profile_picture_url: None,
invitee_plan: InviteePlan::Free,
+ reminder: false,
};
for email in [
make_invite().format_email(),
@@ -419,6 +421,7 @@ fn make_team_invite(invitee_plan: InviteePlan) -> InviteToTeamMetadata {
role: None,
sender_profile_picture_url: None,
invitee_plan,
+ reminder: false,
}
}
@@ -524,3 +527,27 @@ fn team_invite_sent_before_plans_were_recorded_reads_as_free() {
let read: InviteToTeamMetadata = serde_json::from_value(wire).unwrap();
assert_eq!(read.invitee_plan, InviteePlan::Free);
}
+
+#[test]
+fn team_invite_reminder_says_so_in_the_subject() {
+ let reminder = InviteToTeamMetadata {
+ reminder: true,
+ ..make_team_invite(InviteePlan::Free)
+ };
+ assert_eq!(
+ reminder.format_email().subject,
+ "Reminder: [email protected] invited you to join Acme on Macro"
+ );
+ assert_eq!(
+ make_team_invite(InviteePlan::Free).format_email().subject,
+ "[email protected] invited you to join Acme on Macro"
+ );
+}
+
+#[test]
+fn team_invites_queued_before_reminders_read_as_first_sends() {
+ let mut wire = serde_json::to_value(make_team_invite(InviteePlan::Free)).unwrap();
+ wire.as_object_mut().unwrap().remove("reminder");
+ let parsed: InviteToTeamMetadata = serde_json::from_value(wire).unwrap();
+ assert!(!parsed.reminder);
+}
diff --git a/crates/macro_db_client/migrations/20261022214832_team_invite_reminders.sql b/crates/macro_db_client/migrations/20261022214832_team_invite_reminders.sql
new file mode 100644
index 0000000000..e978718ee4
--- /dev/null
+++ b/crates/macro_db_client/migrations/20261022214832_team_invite_reminders.sql
@@ -0,0 +1,3 @@
+-- How many reminder emails an unanswered team invite has sent. The reminder
+-- sweep stops at two; accepting or revoking an invite deletes the row.
+ALTER TABLE team_invite ADD COLUMN reminders_sent SMALLINT NOT NULL DEFAULT 0;
diff --git a/crates/teams/AGENTS.md b/crates/teams/AGENTS.md
index 99281a26ea..0b2c062994 100644
--- a/crates/teams/AGENTS.md
+++ b/crates/teams/AGENTS.md
@@ -14,6 +14,11 @@ event contract (schema, sanitization, delivery semantics).
- `src/domain/team_service/invite_link.rs`: the team's shareable invite link
(`TeamInviteLinkService`) — who may see, create, reset, or turn it off, and
joining through it via the same direct-join path as domain auto-join.
+- `src/domain/team_service/invite_reminders.rs` +
+ `src/inbound/invite_reminder_worker.rs`: reminder emails for unanswered
+ invites, swept hourly in `authentication_service`. The repository claims
+ due invites and counts the reminder before sending, so replicas never
+ double-send and a failed send drops that reminder rather than retrying.
- `src/domain/owned_entity_cleanup.rs` + `open_seat_release.rs`: account/team
deletion side effects (owned-entity transfer, seat release).
- `src/inbound/axum_router.rs` / `src/inbound/toolset.rs`: HTTP routes and AI
diff --git a/crates/teams/src/domain/model.rs b/crates/teams/src/domain/model.rs
index 0c3ae18671..ef2d1abc21 100644
--- a/crates/teams/src/domain/model.rs
+++ b/crates/teams/src/domain/model.rs
@@ -586,6 +586,30 @@ impl TeamInvite<'static> {
}
}
+/// An unanswered team invite whose reminder email is due, claimed by the
+/// reminder sweep. Claiming already counted the reminder as sent.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct DueInviteReminder {
+ /// The team invite id
+ pub team_invite_id: uuid::Uuid,
+ /// The team id
+ pub team_id: uuid::Uuid,
+ /// The team name
+ pub team_name: String,
+ /// The invited email
+ pub email: String,
+ /// The user who sent the invitation
+ pub invited_by: String,
+ /// Which reminder this is, starting at 1
+ pub reminder_number: u8,
+ /// Whether the team is an enterprise team
+ pub enterprise: bool,
+ /// Whether the team is in good standing
+ pub paying: bool,
+ /// Whether the team has a subscription
+ pub has_subscription: bool,
+}
+
/// Snapshot of a team invite before it is accepted.
#[derive(Debug, Clone)]
pub struct TeamInviteSnapshot<'a> {
diff --git a/crates/teams/src/domain/team_repo.rs b/crates/teams/src/domain/team_repo.rs
index 117609be6b..a31f430a50 100644
--- a/crates/teams/src/domain/team_repo.rs
+++ b/crates/teams/src/domain/team_repo.rs
@@ -8,10 +8,10 @@ use entity_access::domain::models::{
use macro_user_id::{email::Email, lowercased::Lowercase, user_id::MacroUserIdStr};
use crate::domain::model::{
- AcceptedTeamInvite, CreateTeamError, DeleteTeamError, InviteUsersToTeamError,
- JoinTeamByInviteLinkError, JoinTeamByInviteLinkOutcome, JoinTeamDirectlyError, JoinTeamError,
- ManageTeamInviteLinkError, PatchTeamCrmSettingsResponse, PatchTeamRequest,
- RemoveTeamInviteError, RemoveUserFromAllTeamsError, RemoveUserFromTeamError,
+ AcceptedTeamInvite, CreateTeamError, DeleteTeamError, DueInviteReminder,
+ InviteUsersToTeamError, JoinTeamByInviteLinkError, JoinTeamByInviteLinkOutcome,
+ JoinTeamDirectlyError, JoinTeamError, ManageTeamInviteLinkError, PatchTeamCrmSettingsResponse,
+ PatchTeamRequest, RemoveTeamInviteError, RemoveUserFromAllTeamsError, RemoveUserFromTeamError,
RestorePermissionsForTeamMembersError, RevokePermissionsForTeamMembersError, SeatPlan,
SetTeamMemberPlanError, Team, TeamError, TeamInvite, TeamInviteDetails, TeamInviteLinkTeam,
TeamInviteLinkToken, TeamMember, TeamMembers, TeamPlan, TeamRole, TeamWithMembers,
@@ -102,6 +102,13 @@ pub trait TeamRepository: Clone + Send + Sync + 'static {
invite_ids: &[uuid::Uuid],
) -> impl Future<Output = Result<(), TeamError>> + Send;
+ /// Claims up to `limit` unanswered invites whose next reminder is due,
+ /// counting the reminder as sent. Concurrent callers claim disjoint invites.
+ fn claim_due_invite_reminders(
+ &self,
+ limit: i64,
+ ) -> impl Future<Output = Result<Vec<DueInviteReminder>, TeamError>> + Send;
+
/// Removes user from a team.
fn remove_user_from_team(
&self,
diff --git a/crates/teams/src/domain/team_service.rs b/crates/teams/src/domain/team_service.rs
index 62d84ad6cf..8ad5b86abf 100644
--- a/crates/teams/src/domain/team_service.rs
+++ b/crates/teams/src/domain/team_service.rs
@@ -1,6 +1,8 @@
//! Contains the service logic for teams
mod invite_link;
+#[cfg(feature = "ports")]
+pub mod invite_reminders;
#[cfg(test)]
mod test;
@@ -1602,6 +1604,7 @@ where
role: None,
sender_profile_picture_url: None,
invitee_plan,
+ reminder: false,
},
)
.await
diff --git a/crates/teams/src/domain/team_service/invite_reminders.rs b/crates/teams/src/domain/team_service/invite_reminders.rs
new file mode 100644
index 0000000000..b606e0b6f2
--- /dev/null
+++ b/crates/teams/src/domain/team_service/invite_reminders.rs
@@ -0,0 +1,182 @@
+//! Reminder emails for team invites nobody has answered: at most two per
+//! invite, 3 days after the last email and then 4 days after that.
+
+use std::collections::HashSet;
+
+use channels::domain::ports::ChannelService;
+use macro_event_broker::MacroEventBroker;
+use macro_user_id::{cowlike::CowLike, user_id::MacroUserIdStr};
+use model_entity::EntityType;
+use model_notifications::{InviteToTeamMetadata, InviteePlan};
+use notification::domain::{models::SendNotificationRequestBuilder, service::NotificationIngress};
+use roles_and_permissions::domain::port::UserRolesAndPermissionsService;
+
+use super::TeamServiceImpl;
+use crate::domain::{
+ contacts_enqueuer::ContactsEnqueuer,
+ crm_enqueuer::CrmEnqueuer,
+ customer_repo::CustomerRepository,
+ model::{DueInviteReminder, TeamError},
+ open_seat_release::OpenSeatRelease,
+ owned_entity_cleanup::OwnedEntityCleanup,
+ team_analytics::TeamAnalytics,
+ team_crm_settings_repo::TeamCrmSettingsRepository,
+ team_repo::TeamRepository,
+};
+
+/// Most invites one sweep claims. A full batch means more may be due, so
+/// the worker sweeps again right away.
+pub const INVITE_REMINDER_BATCH: i64 = 100;
+
+/// What one reminder sweep did.
+#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
+pub struct InviteReminderReport {
+ /// Invites whose reminder was due and claimed.
+ pub claimed: usize,
+ /// Reminders handed to the notification service.
+ pub sent: usize,
+ /// Reminders that could not be sent. They are not retried: the claim
+ /// already counted them, so a failure costs a reminder, never doubles one.
+ pub failed: usize,
+}
+
+/// Sends the reminder emails that are due.
+pub trait InviteReminderSender: Send + Sync + 'static {
+ /// Claims every invite whose reminder is due, up to
+ /// [`INVITE_REMINDER_BATCH`], and emails each invitee.
+ fn send_due_invite_reminders(
+ &self,
+ ) -> impl Future<Output = Result<InviteReminderReport, TeamError>> + Send;
+}
+
+/// The plan the reminder promises, following `invite_users_to_team` without
+/// its subscription backfill, which a background sweep must not trigger. A
+/// team whose owner's subscription is not linked yet reads as free, which
+/// never promises more than joining grants.
+fn invitee_plan(reminder: &DueInviteReminder) -> InviteePlan {
+ if reminder.enterprise || (reminder.paying && reminder.has_subscription) {
+ InviteePlan::Premium
+ } else {
+ InviteePlan::Free
+ }
+}
+
+/// One notification id per invite and reminder, so delivering the same
+/// reminder twice creates one notification.
+fn reminder_notification_id(reminder: &DueInviteReminder) -> uuid::Uuid {
+ uuid::Uuid::new_v5(
+ &reminder.team_invite_id,
+ format!("team-invite-reminder-{}", reminder.reminder_number).as_bytes(),
+ )
+}
+
+impl<TR, CR, CS, URPS, NI, CE, TCRMS, TA, CNE, EB, OSR, OEC> InviteReminderSender
+ for TeamServiceImpl<TR, CR, CS, URPS, NI, CE, TCRMS, TA, CNE, EB, OSR, OEC>
+where
+ TR: TeamRepository,
+ CR: CustomerRepository,
+ CS: ChannelService + Clone,
+ URPS: UserRolesAndPermissionsService,
+ NI: NotificationIngress,
+ CE: CrmEnqueuer,
+ TCRMS: TeamCrmSettingsRepository,
+ TA: TeamAnalytics,
+ CNE: ContactsEnqueuer,
+ EB: MacroEventBroker,
+ OSR: OpenSeatRelease,
+ OEC: OwnedEntityCleanup,
+{
+ #[tracing::instrument(
+ name = "teams.invite_reminder_sweep",
+ skip(self),
+ fields(claimed, sent, failed),
+ err
+ )]
+ async fn send_due_invite_reminders(&self) -> Result<InviteReminderReport, TeamError> {
+ let due = self
+ .team_repository
+ .claim_due_invite_reminders(INVITE_REMINDER_BATCH)
+ .await?;
+
+ let mut report = InviteReminderReport {
+ claimed: due.len(),
+ ..InviteReminderReport::default()
+ };
+ for reminder in &due {
+ match self.send_invite_reminder(reminder).await {
+ Ok(()) => report.sent += 1,
+ Err(_) => report.failed += 1,
+ }
+ }
+
+ let span = tracing::Span::current();
+ span.record("claimed", report.claimed);
+ span.record("sent", report.sent);
+ span.record("failed", report.failed);
+ Ok(report)
+ }
+}
+
+impl<TR, CR, CS, URPS, NI, CE, TCRMS, TA, CNE, EB, OSR, OEC>
+ TeamServiceImpl<TR, CR, CS, URPS, NI, CE, TCRMS, TA, CNE, EB, OSR, OEC>
+where
+ TR: TeamRepository,
+ CR: CustomerRepository,
+ CS: ChannelService + Clone,
+ URPS: UserRolesAndPermissionsService,
+ NI: NotificationIngress,
+ CE: CrmEnqueuer,
+ TCRMS: TeamCrmSettingsRepository,
+ TA: TeamAnalytics,
+ CNE: ContactsEnqueuer,
+ EB: MacroEventBroker,
+ OSR: OpenSeatRelease,
+ OEC: OwnedEntityCleanup,
+{
+ /// Emails one reminder. Email only: the first invite already put a
+ /// notification in the invitee's inbox if they have an account.
+ #[tracing::instrument(
+ name = "teams.send_invite_reminder",
+ skip_all,
+ fields(
+ team_id = %reminder.team_id,
+ team_invite_id = %reminder.team_invite_id,
+ reminder_number = reminder.reminder_number,
+ invitee_plan = ?invitee_plan(reminder),
+ ),
+ err
+ )]
+ async fn send_invite_reminder(&self, reminder: &DueInviteReminder) -> anyhow::Result<()> {
+ let recipient = MacroUserIdStr::try_from_email(&reminder.email)
+ .map_err(|e| anyhow::anyhow!("invalid invitee email: {e:?}"))?;
+ let invited_by = MacroUserIdStr::parse_from_str(&reminder.invited_by)
+ .map_err(|e| anyhow::anyhow!("invalid inviter id: {e:?}"))?
+ .into_owned();
+
+ let request = SendNotificationRequestBuilder {
+ notification_entity: EntityType::Team
+ .with_entity_string(reminder.team_invite_id.to_string()),
+ secondary_notification_entity: None,
+ sender_id: Some(invited_by.clone()),
+ notification: InviteToTeamMetadata {
+ team_id: reminder.team_id,
+ team_invite_id: reminder.team_invite_id,
+ invited_by,
+ team_name: reminder.team_name.clone(),
+ role: None,
+ sender_profile_picture_url: None,
+ invitee_plan: invitee_plan(reminder),
+ reminder: true,
+ },
+ recipient_ids: HashSet::from([recipient]),
+ }
+ .into_request_with_id(reminder_notification_id(reminder))
+ .with_email();
+
+ self.notification_ingress
+ .send_notification(request)
+ .await
+ .map_err(|e| anyhow::anyhow!("failed to send notification: {e}"))?;
+ Ok(())
+ }
+}
diff --git a/crates/teams/src/domain/team_service/test.rs b/crates/teams/src/domain/team_service/test.rs
index 46a055712f..b8c0bf5ae6 100644
--- a/crates/teams/src/domain/team_service/test.rs
+++ b/crates/teams/src/domain/team_service/test.rs
@@ -31,6 +31,7 @@ use roles_and_permissions::domain::{
port::UserRolesAndPermissionsService,
};
+use super::invite_reminders::{InviteReminderReport, InviteReminderSender};
use crate::domain::{
contacts_enqueuer::ContactsEnqueuer,
crm_enqueuer::{CrmEnqueuer, NoOpCrmEnqueuer},
@@ -55,8 +56,8 @@ use super::*;
use crate::domain::{
customer_repo::CustomerRepository,
model::{
- AcceptedTeamInvite, CustomerError, JoinTeamDirectlyError, PatchTeamRequest,
- PatchTeamUserRole, RemoveTeamInviteError, RemoveUserFromAllTeamsError,
+ AcceptedTeamInvite, CustomerError, DueInviteReminder, JoinTeamDirectlyError,
+ PatchTeamRequest, PatchTeamUserRole, RemoveTeamInviteError, RemoveUserFromAllTeamsError,
RemoveUserFromTeamError, SeatPlan, SetTeamMemberPlanError, Team, TeamError, TeamInvite,
TeamInviteDetails, TeamInviteLinkTeam, TeamInviteLinkToken, TeamInviteSnapshot, TeamMember,
TeamPlan, TeamRole, TeamWithMembers, ToggleAutoJoinDomainError,
@@ -145,6 +146,8 @@ struct MockTeamRepository {
journal: Journal,
invite_link: Arc<Mutex<Option<TeamInviteLinkToken>>>,
invite_link_team: Option<TeamInviteLinkTeam>,
+ /// What `claim_due_invite_reminders` hands out, once.
+ due_invite_reminders: Arc<Mutex<Vec<DueInviteReminder>>>,
}
impl MockTeamRepository {
@@ -228,6 +231,7 @@ impl MockTeamRepository {
journal: Journal::default(),
invite_link: Arc::new(Mutex::new(None)),
invite_link_team: None,
+ due_invite_reminders: Arc::new(Mutex::new(Vec::new())),
}
}
@@ -451,6 +455,16 @@ impl TeamRepository for MockTeamRepository {
async { Ok(()) }
}
+ fn claim_due_invite_reminders(
+ &self,
+ limit: i64,
+ ) -> impl Future<Output = Result<Vec<DueInviteReminder>, TeamError>> + Send {
+ let mut due = self.due_invite_reminders.lock().unwrap();
+ let take = due.len().min(usize::try_from(limit).unwrap_or(0));
+ let claimed: Vec<_> = due.drain(..take).collect();
+ async move { Ok(claimed) }
+ }
+
fn remove_user_from_team(
&self,
_: &uuid::Uuid,
@@ -8371,3 +8385,168 @@ async fn failed_member_removal_preserves_the_pending_downgrade() {
assert_eq!(pending.plan, SeatPlan::Premium, "{failure:?}");
}
}
+
+// -- Invite reminders --
+
+fn due_reminder(invite: u128, reminder_number: u8) -> DueInviteReminder {
+ DueInviteReminder {
+ team_invite_id: uuid::Uuid::from_u128(invite),
+ team_id: uuid::Uuid::from_u128(8000),
+ team_name: "Acme".to_string(),
+ email: format!("invitee{invite}@example.com"),
+ invited_by: "macro|[email protected]".to_string(),
+ reminder_number,
+ enterprise: false,
+ paying: true,
+ has_subscription: true,
+ }
+}
+
+fn build_reminder_service(
+ due: Vec<DueInviteReminder>,
+ fail_indices: HashSet<usize>,
+) -> (impl InviteReminderSender, Arc<MockNotificationIngress>) {
+ let team_repo = MockTeamRepository::new(Vec::new(), "Acme", Arc::new(Mutex::new(Vec::new())));
+ *team_repo.due_invite_reminders.lock().unwrap() = due;
+ let notification_ingress = Arc::new(MockNotificationIngress::new(fail_indices));
+ let service = TeamServiceImpl::new(
+ team_repo,
+ MockCustomerRepository::default(),
+ RecordingChannelService::default(),
+ MockUserRolesAndPermissionsService::default(),
+ notification_ingress.clone(),
+ NoOpCrmEnqueuer,
+ NoOpTeamCrmSettingsRepository,
+ );
+ (service, notification_ingress)
+}
+
+/// Each claimed invite gets one reminder email, marked as a reminder and
+/// written by the original inviter, with no in-app notification.
+#[tokio::test]
+async fn invite_reminders_email_each_claimed_invite() {
+ let (service, notification_ingress) =
+ build_reminder_service(vec![due_reminder(1, 1), due_reminder(2, 2)], HashSet::new());
+
+ let report = service.send_due_invite_reminders().await.unwrap();
+
+ assert_eq!(
+ report,
+ InviteReminderReport {
+ claimed: 2,
+ sent: 2,
+ failed: 0
+ }
+ );
+ let requests = notification_ingress.recorded_requests.lock().unwrap();
+ assert_eq!(requests.len(), 2);
+ for (request, invite) in requests.iter().zip([1u128, 2]) {
+ let content = &request["req"]["notification"]["content"];
+ assert_eq!(content["reminder"], true);
+ assert_eq!(content["teamName"], "Acme");
+ assert_eq!(
+ content["teamInviteId"],
+ uuid::Uuid::from_u128(invite).to_string()
+ );
+ assert_eq!(request["req"]["sender_id"], "macro|[email protected]");
+ assert_eq!(
+ request["req"]["recipient_ids"],
+ serde_json::json!([format!("macro|invitee{invite}@example.com")])
+ );
+ assert!(!request["build_email"].is_null());
+ assert_eq!(request["send_conn_gateway"], false);
+ }
+}
+
+/// Redelivering the same reminder reuses its notification id, while the
+/// next reminder for that invite gets a new one.
+#[tokio::test]
+async fn invite_reminder_notification_ids_are_stable_per_reminder() {
+ let (service, notification_ingress) = build_reminder_service(
+ vec![due_reminder(1, 1), due_reminder(1, 1), due_reminder(1, 2)],
+ HashSet::new(),
+ );
+
+ service.send_due_invite_reminders().await.unwrap();
+
+ let ids: Vec<_> = notification_ingress
+ .recorded_requests
+ .lock()
+ .unwrap()
+ .iter()
+ .map(|request| request["uuid_to_write"].clone())
+ .collect();
+ assert_eq!(ids[0], ids[1]);
+ assert_ne!(ids[0], ids[2]);
+}
+
+/// A failed send is counted and does not stop the rest of the batch.
+#[tokio::test]
+async fn invite_reminders_keep_going_after_a_failed_send() {
+ let (service, notification_ingress) = build_reminder_service(
+ vec![due_reminder(1, 1), due_reminder(2, 1), due_reminder(3, 1)],
+ HashSet::from([1]),
+ );
+
+ let report = service.send_due_invite_reminders().await.unwrap();
+
+ assert_eq!(
+ report,
+ InviteReminderReport {
+ claimed: 3,
+ sent: 2,
+ failed: 1
+ }
+ );
+ assert_eq!(
+ notification_ingress.recorded_requests.lock().unwrap().len(),
+ 3
+ );
+}
+
+/// A sweep with nothing due sends nothing.
+#[tokio::test]
+async fn invite_reminders_with_nothing_due_send_nothing() {
+ let (service, notification_ingress) = build_reminder_service(Vec::new(), HashSet::new());
+
+ let report = service.send_due_invite_reminders().await.unwrap();
+
+ assert_eq!(report, InviteReminderReport::default());
+ assert!(
+ notification_ingress
+ .recorded_requests
+ .lock()
+ .unwrap()
+ .is_empty()
+ );
+}
+
+/// The reminder promises Pro only when joining grants it, like the invite.
+#[tokio::test]
+async fn invite_reminders_promise_what_joining_grants() {
+ let cases = [
+ // (enterprise, paying, has_subscription, plan)
+ (true, false, false, "premium"),
+ (false, true, true, "premium"),
+ (false, true, false, "free"),
+ (false, false, false, "free"),
+ ];
+ let due = cases
+ .iter()
+ .zip(1u128..)
+ .map(
+ |(&(enterprise, paying, has_subscription, _), invite)| DueInviteReminder {
+ enterprise,
+ paying,
+ has_subscription,
+ ..due_reminder(invite, 1)
+ },
+ )
+ .collect();
+ let (service, notification_ingress) = build_reminder_service(due, HashSet::new());
+
+ service.send_due_invite_reminders().await.unwrap();
+
+ let expected: Vec<_> = cases.iter().map(|case| serde_json::json!(case.3)).collect();
+ assert_eq!(invitee_plans_sent(&notification_ingress), expected);
+}
diff --git a/crates/teams/src/inbound.rs b/crates/teams/src/inbound.rs
index 2f5fb01a15..d50997b5f7 100644
--- a/crates/teams/src/inbound.rs
+++ b/crates/teams/src/inbound.rs
@@ -3,5 +3,8 @@
#[cfg(feature = "axum")]
pub mod axum_router;
+#[cfg(feature = "ports")]
+pub mod invite_reminder_worker;
+
#[cfg(feature = "ai_tools")]
pub mod toolset;
diff --git a/crates/teams/src/inbound/invite_reminder_worker.rs b/crates/teams/src/inbound/invite_reminder_worker.rs
new file mode 100644
index 0000000000..a8ae0101ed
--- /dev/null
+++ b/crates/teams/src/inbound/invite_reminder_worker.rs
@@ -0,0 +1,59 @@
+//! Runs the team invite reminder sweep on a schedule.
+
+use std::{sync::Arc, time::Duration};
+
+use crate::domain::team_service::invite_reminders::{INVITE_REMINDER_BATCH, InviteReminderSender};
+
+/// How long after boot the first sweep runs, so a deploy's rolling restart
+/// is past before reminders go out.
+pub const INVITE_REMINDER_SWEEP_INITIAL_DELAY: Duration = Duration::from_secs(5 * 60);
+
+/// How often the sweep runs after that. Reminders are days apart, so an hour
+/// late costs nothing.
+pub const INVITE_REMINDER_SWEEP_INTERVAL: Duration = Duration::from_secs(60 * 60);
+
+/// Sweeps once after `initial_delay`, then every `interval`, until `shutdown`
+/// resolves. A full batch sweeps again right away.
+///
+/// Shutdown is checked between sweeps, never during one: a sweep's claim
+/// already counted its reminders as sent, so stopping mid-batch would drop
+/// the rest. Replicas may sweep concurrently; each claims different invites.
+pub async fn run_invite_reminder_sweep<S: InviteReminderSender>(
+ sender: Arc<S>,
+ initial_delay: Duration,
+ interval: Duration,
+ shutdown: impl Future<Output = ()> + Send,
+) {
+ tokio::pin!(shutdown);
+ let mut wait = initial_delay;
+ loop {
+ tokio::select! {
+ () = &mut shutdown => return,
+ () = tokio::time::sleep(wait) => {}
+ }
+ wait = match sender.send_due_invite_reminders().await {
+ Ok(report) => {
+ tracing::info!(
+ claimed = report.claimed,
+ sent = report.sent,
+ failed = report.failed,
+ "team invite reminder sweep finished"
+ );
+ if i64::try_from(report.claimed)
+ .is_ok_and(|claimed| claimed >= INVITE_REMINDER_BATCH)
+ {
+ Duration::ZERO
+ } else {
+ interval
+ }
+ }
+ Err(error) => {
+ tracing::warn!(error = ?error, "team invite reminder sweep failed");
+ interval
+ }
+ };
+ }
+}
+
+#[cfg(test)]
+mod test;
diff --git a/crates/teams/src/inbound/invite_reminder_worker/test.rs b/crates/teams/src/inbound/invite_reminder_worker/test.rs
new file mode 100644
index 0000000000..0192330316
--- /dev/null
+++ b/crates/teams/src/inbound/invite_reminder_worker/test.rs
@@ -0,0 +1,130 @@
+use std::sync::Mutex;
+
+use super::*;
+use crate::domain::{
+ model::TeamError,
+ team_service::invite_reminders::{INVITE_REMINDER_BATCH, InviteReminderReport},
+};
+
+/// Hands out one scripted result per sweep, then empty sweeps.
+struct ScriptedSweeps {
+ results: Mutex<Vec<Result<usize, ()>>>,
+ sweeps: Mutex<Vec<tokio::time::Instant>>,
+}
+
+impl ScriptedSweeps {
+ fn new(results: Vec<Result<usize, ()>>) -> Arc<Self> {
+ Arc::new(Self {
+ results: Mutex::new(results),
+ sweeps: Mutex::new(Vec::new()),
+ })
+ }
+
+ fn sweep_times(&self) -> Vec<tokio::time::Instant> {
+ self.sweeps.lock().unwrap().clone()
+ }
+}
+
+impl InviteReminderSender for ScriptedSweeps {
+ fn send_due_invite_reminders(
+ &self,
+ ) -> impl Future<Output = Result<InviteReminderReport, TeamError>> + Send {
+ self.sweeps
+ .lock()
+ .unwrap()
+ .push(tokio::time::Instant::now());
+ let mut results = self.results.lock().unwrap();
+ let next = if results.is_empty() {
+ Ok(0)
+ } else {
+ results.remove(0)
+ };
+ async move {
+ next.map(|claimed| InviteReminderReport {
+ claimed,
+ sent: claimed,
+ failed: 0,
+ })
+ .map_err(|()| TeamError::StorageLayerError(anyhow::anyhow!("database down")))
+ }
+ }
+}
+
+fn full_batch() -> usize {
+ usize::try_from(INVITE_REMINDER_BATCH).unwrap()
+}
+
+const INITIAL: Duration = Duration::from_secs(60);
+const INTERVAL: Duration = Duration::from_secs(3600);
+
+/// Runs the worker until `until` has passed, then stops it.
+async fn run_for(sender: Arc<ScriptedSweeps>, until: Duration) {
+ let (stop, stopped) = tokio::sync::oneshot::channel::<()>();
+ let worker = tokio::spawn(run_invite_reminder_sweep(
+ sender,
+ INITIAL,
+ INTERVAL,
+ async move {
+ let _ = stopped.await;
+ },
+ ));
+ tokio::time::sleep(until).await;
+ stop.send(()).unwrap();
+ worker.await.unwrap();
+}
+
+#[tokio::test(start_paused = true)]
+async fn sweeps_after_the_initial_delay_then_every_interval() {
+ let start = tokio::time::Instant::now();
+ let sender = ScriptedSweeps::new(vec![Ok(3)]);
+
+ run_for(
+ sender.clone(),
+ INITIAL + INTERVAL * 2 + Duration::from_secs(1),
+ )
+ .await;
+
+ assert_eq!(
+ sender.sweep_times(),
+ vec![
+ start + INITIAL,
+ start + INITIAL + INTERVAL,
+ start + INITIAL + INTERVAL * 2
+ ]
+ );
+}
+
+#[tokio::test(start_paused = true)]
+async fn a_full_batch_sweeps_again_right_away() {
+ let start = tokio::time::Instant::now();
+ let sender = ScriptedSweeps::new(vec![Ok(full_batch()), Ok(full_batch()), Ok(1)]);
+
+ run_for(sender.clone(), INITIAL + Duration::from_secs(1)).await;
+
+ assert_eq!(
+ sender.sweep_times(),
+ vec![start + INITIAL, start + INITIAL, start + INITIAL]
+ );
+}
+
+#[tokio::test(start_paused = true)]
+async fn a_failed_sweep_waits_for_the_next_interval() {
+ let start = tokio::time::Instant::now();
+ let sender = ScriptedSweeps::new(vec![Err(())]);
+
+ run_for(sender.clone(), INITIAL + INTERVAL + Duration::from_secs(1)).await;
+
+ assert_eq!(
+ sender.sweep_times(),
+ vec![start + INITIAL, start + INITIAL + INTERVAL]
+ );
+}
+
+#[tokio::test(start_paused = true)]
+async fn shutdown_before_the_first_sweep_sends_nothing() {
+ let sender = ScriptedSweeps::new(vec![]);
+
+ run_for(sender.clone(), INITIAL / 2).await;
+
+ assert!(sender.sweep_times().is_empty());
+}
diff --git a/crates/teams/src/outbound/team_repo.rs b/crates/teams/src/outbound/team_repo.rs
index fc4b48dbe7..ca5d121e51 100644
--- a/crates/teams/src/outbound/team_repo.rs
+++ b/crates/teams/src/outbound/team_repo.rs
@@ -1,11 +1,11 @@
//! Implementation for TeamRepository using MacroDB.
use crate::domain::{
model::{
- AcceptedTeamInvite, CreateTeamError, InviteUsersToTeamError, PatchTeamRequest,
- RemoveTeamInviteError, RemoveUserFromTeamError, SeatPlan, Team, TeamError, TeamInvite,
- TeamInviteDetails, TeamInviteLinkTeam, TeamInviteLinkToken, TeamInviteSnapshot, TeamMember,
- TeamMembers, TeamPlan, TeamRole, TeamWithMembers, ToggleAutoJoinDomainError,
- is_generic_email_domain, normalize_team_slug,
+ AcceptedTeamInvite, CreateTeamError, DueInviteReminder, InviteUsersToTeamError,
+ PatchTeamRequest, RemoveTeamInviteError, RemoveUserFromTeamError, SeatPlan, Team,
+ TeamError, TeamInvite, TeamInviteDetails, TeamInviteLinkTeam, TeamInviteLinkToken,
+ TeamInviteSnapshot, TeamMember, TeamMembers, TeamPlan, TeamRole, TeamWithMembers,
+ ToggleAutoJoinDomainError, is_generic_email_domain, normalize_team_slug,
},
owned_entity_cleanup::ClearedTeam,
team_repo::{TeamMembersService, TeamRepository},
@@ -544,6 +544,80 @@ impl TeamRepository for TeamRepositoryImpl {
Ok(())
}
+ #[tracing::instrument(skip(self), fields(claimed = tracing::field::Empty), err)]
+ async fn claim_due_invite_reminders(
+ &self,
+ limit: i64,
+ ) -> Result<Vec<DueInviteReminder>, TeamError> {
+ // The first reminder goes 3 days after the last email, the second 4
+ // days after the first. Invites older than 14 days are left alone, so
+ // a deploy never reminds people about invites from long ago. Skips
+ // invites the invitee could not accept (the team stopped paying for
+ // its subscription), already-members, and invites whose sender left
+ // the team, since the email is written in the sender's name.
+ let reminders = sqlx::query!(
+ r#"
+ WITH due AS (
+ SELECT ti.id
+ FROM team_invite ti
+ JOIN team t ON t.id = ti.team_id
+ WHERE ti.created_at > NOW() - INTERVAL '14 days'
+ AND (
+ (ti.reminders_sent = 0 AND ti.last_sent_at <= NOW() - INTERVAL '3 days')
+ OR (ti.reminders_sent = 1 AND ti.last_sent_at <= NOW() - INTERVAL '4 days')
+ )
+ AND (t.enterprise OR t.paying OR t.subscription_id IS NULL)
+ AND EXISTS (
+ SELECT 1 FROM team_user tu
+ WHERE tu.team_id = ti.team_id AND tu.user_id = ti.invited_by
+ )
+ AND NOT EXISTS (
+ SELECT 1 FROM team_user tu
+ WHERE tu.team_id = ti.team_id AND tu.user_id = 'macro|' || ti.email
+ )
+ ORDER BY ti.created_at
+ LIMIT $1
+ FOR UPDATE OF ti SKIP LOCKED
+ )
+ UPDATE team_invite ti
+ SET reminders_sent = ti.reminders_sent + 1,
+ last_sent_at = NOW()
+ FROM due, team t
+ WHERE ti.id = due.id AND t.id = ti.team_id
+ RETURNING
+ ti.id,
+ ti.team_id,
+ t.name AS team_name,
+ ti.email,
+ ti.invited_by,
+ ti.reminders_sent,
+ t.enterprise,
+ t.paying,
+ t.subscription_id IS NOT NULL AS "has_subscription!"
+ "#,
+ limit,
+ )
+ .fetch_all(&self.pool)
+ .await?
+ .into_iter()
+ .map(|r| {
+ Ok(DueInviteReminder {
+ team_invite_id: r.id,
+ team_id: r.team_id,
+ team_name: r.team_name,
+ email: r.email,
+ invited_by: r.invited_by,
+ reminder_number: u8::try_from(r.reminders_sent).map_err(anyhow::Error::from)?,
+ enterprise: r.enterprise,
+ paying: r.paying,
+ has_subscription: r.has_subscription,
+ })
+ })
+ .collect::<Result<Vec<_>, TeamError>>()?;
+ tracing::Span::current().record("claimed", reminders.len());
+ Ok(reminders)
+ }
+
#[tracing::instrument(skip(self), err)]
#[allow(clippy::disallowed_methods, reason = "legacy code. fix later")]
async fn remove_user_from_team(
diff --git a/crates/teams/src/outbound/team_repo/test.rs b/crates/teams/src/outbound/team_repo/test.rs
index 2428f26131..50f5f0244f 100644
--- a/crates/teams/src/outbound/team_repo/test.rs
+++ b/crates/teams/src/outbound/team_repo/test.rs
@@ -1817,3 +1817,234 @@ async fn test_allow_non_admin_invites_defaults_true_and_toggles(
Ok(())
}
+
+// -- Invite reminders --
+
+const TEAM_1: &str = "11111111-1111-1111-1111-111111111111";
+
+/// Sets the fixture invite to `[email protected]` as `days_old` days old, last
+/// emailed `last_sent_days_ago` days ago, with `reminders_sent` reminders.
+async fn age_invite(
+ pool: &Pool<Postgres>,
+ days_old: i32,
+ last_sent_days_ago: i32,
+ reminders_sent: i16,
+) -> anyhow::Result<()> {
+ sqlx::query(
+ r#"
+ UPDATE team_invite
+ SET created_at = NOW() - make_interval(days => $1),
+ last_sent_at = NOW() - make_interval(days => $2),
+ reminders_sent = $3
+ WHERE email = '[email protected]'
+ "#,
+ )
+ .bind(days_old)
+ .bind(last_sent_days_ago)
+ .bind(reminders_sent)
+ .execute(pool)
+ .await?;
+ Ok(())
+}
+
+/// Puts team1 in good standing; the fixture leaves it not paying.
+async fn mark_team_1_paying(pool: &Pool<Postgres>) -> anyhow::Result<()> {
+ sqlx::query("UPDATE team SET paying = true WHERE id = $1::uuid")
+ .bind(TEAM_1)
+ .execute(pool)
+ .await?;
+ Ok(())
+}
+
+async fn claimed_emails(team_repo: &TeamRepositoryImpl) -> anyhow::Result<Vec<(String, u8)>> {
+ Ok(team_repo
+ .claim_due_invite_reminders(100)
+ .await?
+ .into_iter()
+ .map(|r| (r.email, r.reminder_number))
+ .collect())
+}
+
+/// Three days after the invite email, the first reminder is claimed once.
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("teams"))
+)]
+async fn first_invite_reminder_is_due_after_three_days(pool: Pool<Postgres>) -> anyhow::Result<()> {
+ let team_repo = TeamRepositoryImpl::new(pool.clone());
+ mark_team_1_paying(&pool).await?;
+ age_invite(&pool, 3, 3, 0).await?;
+
+ let claimed = team_repo.claim_due_invite_reminders(100).await?;
+ assert_eq!(claimed.len(), 1);
+ let reminder = &claimed[0];
+ assert_eq!(reminder.email, "[email protected]");
+ assert_eq!(reminder.reminder_number, 1);
+ assert_eq!(reminder.team_name, "team1");
+ assert_eq!(reminder.invited_by, "macro|[email protected]");
+ assert!(reminder.paying && reminder.has_subscription && !reminder.enterprise);
+
+ // Claiming counted the reminder and restarted the clock.
+ assert!(claimed_emails(&team_repo).await?.is_empty());
+ let (reminders_sent, recently_sent): (i16, bool) = sqlx::query_as(
+ "SELECT reminders_sent, last_sent_at > NOW() - INTERVAL '1 minute' FROM team_invite WHERE email = '[email protected]'",
+ )
+ .fetch_one(&pool)
+ .await?;
+ assert_eq!((reminders_sent, recently_sent), (1, true));
+ Ok(())
+}
+
+/// Two days after the invite email, nothing is due yet.
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("teams"))
+)]
+async fn invite_reminder_is_not_due_before_three_days(pool: Pool<Postgres>) -> anyhow::Result<()> {
+ let team_repo = TeamRepositoryImpl::new(pool.clone());
+ mark_team_1_paying(&pool).await?;
+ age_invite(&pool, 2, 2, 0).await?;
+
+ assert!(claimed_emails(&team_repo).await?.is_empty());
+ Ok(())
+}
+
+/// The second reminder waits four days after the first, and there is no third.
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("teams"))
+)]
+async fn second_invite_reminder_is_the_last(pool: Pool<Postgres>) -> anyhow::Result<()> {
+ let team_repo = TeamRepositoryImpl::new(pool.clone());
+ mark_team_1_paying(&pool).await?;
+
+ age_invite(&pool, 6, 3, 1).await?;
+ assert!(claimed_emails(&team_repo).await?.is_empty());
+
+ age_invite(&pool, 7, 4, 1).await?;
+ assert_eq!(
+ claimed_emails(&team_repo).await?,
+ vec![("[email protected]".to_string(), 2)]
+ );
+
+ age_invite(&pool, 13, 6, 2).await?;
+ assert!(claimed_emails(&team_repo).await?.is_empty());
+ Ok(())
+}
+
+/// Invites older than 14 days are never reminded, so a deploy does not
+/// email people about invites from long ago.
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("teams"))
+)]
+async fn old_invites_are_not_reminded(pool: Pool<Postgres>) -> anyhow::Result<()> {
+ let team_repo = TeamRepositoryImpl::new(pool.clone());
+ mark_team_1_paying(&pool).await?;
+ age_invite(&pool, 15, 15, 0).await?;
+
+ assert!(claimed_emails(&team_repo).await?.is_empty());
+ Ok(())
+}
+
+/// No reminder for an invitee who already joined, one whose inviter left the
+/// team, or one the invitee could not accept because the team stopped paying.
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("teams"))
+)]
+async fn invite_reminders_skip_invites_that_cannot_lead_anywhere(
+ pool: Pool<Postgres>,
+) -> anyhow::Result<()> {
+ let team_repo = TeamRepositoryImpl::new(pool.clone());
+ age_invite(&pool, 5, 5, 0).await?;
+
+ // team1 has a subscription but is not paying.
+ assert!(claimed_emails(&team_repo).await?.is_empty());
+ mark_team_1_paying(&pool).await?;
+
+ // The invitee (here user3, who has an account) joined some other way
+ // and the invite row stayed.
+ sqlx::query("DELETE FROM team_invite WHERE email = '[email protected]'")
+ .execute(&pool)
+ .await?;
+ sqlx::query("UPDATE team_invite SET email = '[email protected]' WHERE email = '[email protected]'")
+ .execute(&pool)
+ .await?;
+ sqlx::query("INSERT INTO team_user (team_id, user_id, team_role) VALUES ($1::uuid, 'macro|[email protected]', 'member')")
+ .bind(TEAM_1)
+ .execute(&pool)
+ .await?;
+ assert!(claimed_emails(&team_repo).await?.is_empty());
+ sqlx::query("DELETE FROM team_user WHERE user_id = 'macro|[email protected]'")
+ .execute(&pool)
+ .await?;
+ assert_eq!(claimed_emails(&team_repo).await?.len(), 1);
+ sqlx::query(
+ "UPDATE team_invite SET reminders_sent = 0, last_sent_at = NOW() - INTERVAL '5 days'",
+ )
+ .execute(&pool)
+ .await?;
+
+ // The inviter is no longer on the team.
+ sqlx::query("UPDATE team_invite SET invited_by = 'macro|[email protected]'")
+ .execute(&pool)
+ .await?;
+ assert!(claimed_emails(&team_repo).await?.is_empty());
+ Ok(())
+}
+
+/// Free teams and enterprise teams get reminders too.
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("teams"))
+)]
+async fn free_and_enterprise_teams_get_invite_reminders(
+ pool: Pool<Postgres>,
+) -> anyhow::Result<()> {
+ let team_repo = TeamRepositoryImpl::new(pool.clone());
+ age_invite(&pool, 5, 5, 0).await?;
+
+ sqlx::query("UPDATE team SET enterprise = true WHERE id = $1::uuid")
+ .bind(TEAM_1)
+ .execute(&pool)
+ .await?;
+ let claimed = team_repo.claim_due_invite_reminders(100).await?;
+ assert_eq!(claimed.len(), 1);
+ assert!(claimed[0].enterprise);
+
+ age_invite(&pool, 5, 5, 0).await?;
+ sqlx::query("UPDATE team SET enterprise = false, subscription_id = NULL WHERE id = $1::uuid")
+ .bind(TEAM_1)
+ .execute(&pool)
+ .await?;
+ let claimed = team_repo.claim_due_invite_reminders(100).await?;
+ assert_eq!(claimed.len(), 1);
+ assert!(!claimed[0].paying && !claimed[0].has_subscription);
+ Ok(())
+}
+
+/// A sweep claims at most `limit` invites, oldest first.
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("teams"))
+)]
+async fn invite_reminder_claims_respect_the_limit(pool: Pool<Postgres>) -> anyhow::Result<()> {
+ let team_repo = TeamRepositoryImpl::new(pool.clone());
+ mark_team_1_paying(&pool).await?;
+ sqlx::query(
+ "UPDATE team_invite SET created_at = NOW() - INTERVAL '6 days', last_sent_at = NOW() - INTERVAL '6 days' WHERE email = '[email protected]'",
+ )
+ .execute(&pool)
+ .await?;
+ age_invite(&pool, 5, 5, 0).await?;
+
+ let first = team_repo.claim_due_invite_reminders(1).await?;
+ assert_eq!(first.len(), 1);
+ assert_eq!(first[0].email, "[email protected]");
+ assert_eq!(
+ claimed_emails(&team_repo).await?,
+ vec![("[email protected]".to_string(), 1)]
+ );
+ Ok(())
+}
diff --git a/docs/agent-guide/settings.md b/docs/agent-guide/settings.md
index ced3b9295b..9f2a114bed 100644
--- a/docs/agent-guide/settings.md
+++ b/docs/agent-guide/settings.md
@@ -160,6 +160,9 @@ as before. Each email says what joining gives: **Pro is included** when joining
grants a Pro seat (an enterprise team, or one with a subscription), otherwise
**Free to join**. Examples: [desktop](media/team-invite-email/desktop.png) and
[mobile](media/team-invite-email/mobile.png).
+An unanswered invite gets up to two reminder emails, with subjects starting
+**Reminder:**, 3 days after the last email and 4 days after that. Invites more
+than 14 days old, already-members, and invites whose sender left the team get none.
Under **Team → Members** (**Invite settings**), owners/admins can turn
**Auto-join on domain** off and can restrict invitations to admins with
diff --git a/packages/sdk-docs/reference/generated/notification/types.gen/type-aliases/InviteToTeamMetadata.md b/packages/sdk-docs/reference/generated/notification/types.gen/type-aliases/InviteToTeamMetadata.md
index 8a254b19e6..e7c9655c04 100644
--- a/packages/sdk-docs/reference/generated/notification/types.gen/type-aliases/InviteToTeamMetadata.md
+++ b/packages/sdk-docs/reference/generated/notification/types.gen/type-aliases/InviteToTeamMetadata.md
@@ -1,6 +1,6 @@
# Type Alias: InviteToTeamMetadata
-> **InviteToTeamMetadata** = \{ `invitedBy`: `string`; `inviteePlan?`: [`InviteePlan`](InviteePlan.md); `role?`: `string` \| `null`; `senderProfilePictureUrl?`: `string` \| `null`; `teamId`: `string`; `teamInviteId`: `string`; `teamName`: `string`; \}
+> **InviteToTeamMetadata** = \{ `invitedBy`: `string`; `inviteePlan?`: [`InviteePlan`](InviteePlan.md); `reminder?`: `boolean`; `role?`: `string` \| `null`; `senderProfilePictureUrl?`: `string` \| `null`; `teamId`: `string`; `teamInviteId`: `string`; `teamName`: `string`; \}
Metadata for when a user is invited to a team.
@@ -10,6 +10,7 @@ Metadata for when a user is invited to a team.
| ------ | ------ | ------ |
| <a id="property-invitedby"></a> `invitedBy` | `string` | The user who sent the invitation |
| <a id="property-inviteeplan"></a> `inviteePlan?` | [`InviteePlan`](InviteePlan.md) | What the invitee gets by joining, as the team stood when the invite was sent. |
+| <a id="property-reminder"></a> `reminder?` | `boolean` | Whether this email reminds the invitee of an invite they have not answered. |
| <a id="property-role"></a> `role?` | `string` \| `null` | Role/permission level in the team |
| <a id="property-senderprofilepictureurl"></a> `senderProfilePictureUrl?` | `string` \| `null` | The sender's profile picture URL, if available. |
| <a id="property-teamid"></a> `teamId` | `string` | The unique identifier of the team |
diff --git a/packages/sdk/generated/notification/types.gen.ts b/packages/sdk/generated/notification/types.gen.ts
index 84ec13c5c5..4dccef0416 100644
--- a/packages/sdk/generated/notification/types.gen.ts
+++ b/packages/sdk/generated/notification/types.gen.ts
@@ -942,6 +942,10 @@ export type InviteToTeamMetadata = {
* What the invitee gets by joining, as the team stood when the invite was sent.
*/
inviteePlan?: InviteePlan;
+ /**
+ * Whether this email reminds the invitee of an invite they have not answered.
+ */
+ reminder?: boolean;
/**
* Role/permission level in the team
*/
diff --git a/packages/sdk/specs/notification.json b/packages/sdk/specs/notification.json
index 8499efa7db..e55047f29a 100644
--- a/packages/sdk/specs/notification.json
+++ b/packages/sdk/specs/notification.json
@@ -2291,6 +2291,10 @@
"$ref": "#/components/schemas/InviteePlan",
"description": "What the invitee gets by joining, as the team stood when the invite was sent."
},
+ "reminder": {
+ "type": "boolean",
+ "description": "Whether this email reminds the invitee of an invite they have not answered."
+ },
"role": {
"type": ["string", "null"],
"description": "Role/permission level in the team"
diff --git a/services/authentication_service/src/server.rs b/services/authentication_service/src/server.rs
index 11dd247047..33e88669c9 100644
--- a/services/authentication_service/src/server.rs
+++ b/services/authentication_service/src/server.rs
@@ -94,7 +94,7 @@ use crate::{
outbound::team_owned_entity_cleanup::TeamOwnedEntityCleanupAdapter,
};
use std::{sync::Arc, time::Duration};
-use tokio_util::task::TaskTracker;
+use tokio_util::{sync::CancellationToken, task::TaskTracker};
/// Build the service from the environment and serve until shutdown.
pub async fn run() -> anyhow::Result<()> {
@@ -637,6 +637,19 @@ pub async fn run() -> anyhow::Result<()> {
.with_open_seat_release((*ai_billing_service).clone())
.with_owned_entity_cleanup(team_owned_entity_cleanup);
let teams_service = Arc::new(teams_service_impl);
+ // Reminds people of team invites they have not answered. Replicas claim
+ // disjoint invites, so every replica sweeps.
+ let invite_reminders_stop = CancellationToken::new();
+ let invite_reminders = TaskTracker::new();
+ invite_reminders.spawn(
+ teams::inbound::invite_reminder_worker::run_invite_reminder_sweep(
+ teams_service.clone(),
+ teams::inbound::invite_reminder_worker::INVITE_REMINDER_SWEEP_INITIAL_DELAY,
+ teams::inbound::invite_reminder_worker::INVITE_REMINDER_SWEEP_INTERVAL,
+ invite_reminders_stop.clone().cancelled_owned(),
+ ),
+ );
+ invite_reminders.close();
let user_deletion = Arc::new(
crate::outbound::user_deletion::UserDeletionAdapter::new(
db.clone(),
@@ -766,6 +779,19 @@ pub async fn run() -> anyhow::Result<()> {
sweep.abort();
}
+ // Lets a sweep in progress finish: its reminders are already counted as
+ // sent, so abandoning the batch would drop them.
+ invite_reminders_stop.cancel();
+ if tokio::time::timeout(INVITE_REMINDER_DRAIN_TIMEOUT, invite_reminders.wait())
+ .await
+ .is_err()
+ {
+ tracing::warn!(
+ timeout_seconds = INVITE_REMINDER_DRAIN_TIMEOUT.as_secs(),
+ "timed out waiting for the team invite reminder sweep to finish"
+ );
+ }
+
tracing::info!("waiting for event broker publishes to drain");
event_broker_tracker.close();
match tokio::time::timeout(EVENT_BROKER_DRAIN_TIMEOUT, event_broker_tracker.wait()).await {
@@ -783,6 +809,7 @@ pub async fn run() -> anyhow::Result<()> {
}
const EVENT_BROKER_DRAIN_TIMEOUT: Duration = Duration::from_secs(10);
+const INVITE_REMINDER_DRAIN_TIMEOUT: Duration = Duration::from_secs(10);
const MICROSOFT_GRANT_CLEANUP_INTERVAL: Duration = Duration::from_secs(5 * 60);
// SAFETY: this is not a secret value