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(github): expanded github PR events (#4038)

Will Hutchinsona28560736a4f
diff --git a/js/app/packages/entity/src/extractors-notification/notification-description-helpers.ts b/js/app/packages/entity/src/extractors-notification/notification-description-helpers.ts
index aab4385a87..2936b06621 100644
--- a/js/app/packages/entity/src/extractors-notification/notification-description-helpers.ts
+++ b/js/app/packages/entity/src/extractors-notification/notification-description-helpers.ts
@@ -34,7 +34,11 @@ export function getActionVerb(type: NotificationType): string {
.with('channel_invite', () => 'invited you')
.with('invite_to_team', () => 'invited you')
.with('task_assigned', () => 'assigned you')
- .with('github_pr_event', () => 'updated a pull request')
+ .with('github_pr_status_changed', () => 'updated a pull request')
+ .with('github_review_requested', () => 'requested your review')
+ .with('github_pr_comment', () => 'commented on a pull request')
+ .with('github_pr_mention', () => 'mentioned you on a pull request')
+ .with('github_pr_review', () => 'reviewed your pull request')
.with('call-started', () => 'started a call')
.exhaustive();
}
@@ -63,9 +67,15 @@ export function getTypeNoun(type: NotificationType, count: number): string {
.with('channel_invite', () => (count === 1 ? 'invite' : 'invites'))
.with('invite_to_team', () => (count === 1 ? 'invite' : 'invites'))
.with('task_assigned', () => (count === 1 ? 'task' : 'tasks'))
- .with('github_pr_event', () =>
+ .with('github_pr_status_changed', () =>
count === 1 ? 'pull request' : 'pull requests'
)
+ .with('github_review_requested', () =>
+ count === 1 ? 'review request' : 'review requests'
+ )
+ .with('github_pr_comment', () => (count === 1 ? 'comment' : 'comments'))
+ .with('github_pr_mention', () => (count === 1 ? 'mention' : 'mentions'))
+ .with('github_pr_review', () => (count === 1 ? 'review' : 'reviews'))
.with('call-started', () => (count === 1 ? 'call' : 'calls'))
.exhaustive();
}
diff --git a/js/app/packages/entity/src/extractors-notification/notification-icon.tsx b/js/app/packages/entity/src/extractors-notification/notification-icon.tsx
index 4e26086d3e..807174b79d 100644
--- a/js/app/packages/entity/src/extractors-notification/notification-icon.tsx
+++ b/js/app/packages/entity/src/extractors-notification/notification-icon.tsx
@@ -12,7 +12,7 @@ import UserPlusIcon from '@phosphor/user-plus.svg';
import { cn } from '@ui';
import type { JSX } from 'solid-js';
import { Dynamic } from 'solid-js/web';
-import { match } from 'ts-pattern';
+import { match, P } from 'ts-pattern';
import type { Notification } from '../types/notification';
interface NotificationIconProps {
@@ -40,7 +40,16 @@ function getNotificationIcon(
.with('invite_to_team', () => UserPlusIcon)
.with('task_assigned', () => CheckIcon)
.with('ai_response', () => ChatIcon)
- .with('github_pr_event', () => GithubIcon)
+ .with(
+ P.union(
+ 'github_pr_status_changed',
+ 'github_review_requested',
+ 'github_pr_comment',
+ 'github_pr_mention',
+ 'github_pr_review'
+ ),
+ () => GithubIcon
+ )
.with('call-started', () => PhoneIcon)
.exhaustive();
}
diff --git a/js/app/packages/entity/src/utils/notification.ts b/js/app/packages/entity/src/utils/notification.ts
index 8ea75470f6..8f6ab43f78 100644
--- a/js/app/packages/entity/src/utils/notification.ts
+++ b/js/app/packages/entity/src/utils/notification.ts
@@ -2,7 +2,7 @@ import { ENABLE_DOCUMENT_MENTION_NOTIFICATIONS } from '@core/constant/featureFla
import type { Entity, NotificationType } from '@core/types';
import { notificationIsRead, type UnifiedNotification } from '@notifications';
import type { NotificationStack } from '@notifications/notification-stacking';
-import { match } from 'ts-pattern';
+import { match, P } from 'ts-pattern';
import type { EntityData } from '../types/entity';
import type { Notification } from '../types/notification';
@@ -97,7 +97,11 @@ export function getNotificationActionText(n: Notification): string {
.with('invite_to_team', () => 'invited')
.with('task_assigned', () => 'assigned')
.with('ai_response', () => 'responded')
- .with('github_pr_event', () => 'updated')
+ .with('github_pr_status_changed', () => 'updated')
+ .with('github_review_requested', () => 'requested')
+ .with('github_pr_comment', () => 'commented')
+ .with('github_pr_mention', () => 'mentioned')
+ .with('github_pr_review', () => 'reviewed')
.with('call-started', () => 'called')
.exhaustive();
}
@@ -127,9 +131,30 @@ export function extractMessageContent(notification: Notification): string {
.with({ tag: 'task_assigned' }, (m) => m.content.taskName ?? '')
.with({ tag: 'ai_response' }, (m) => m.content.summary || '')
.with(
- { tag: 'github_pr_event' },
+ { tag: P.union('github_pr_status_changed', 'github_review_requested') },
(m) => m.content.title || m.content.displayName || ''
)
+ .with(
+ { tag: 'github_pr_comment' },
+ (m) =>
+ m.content.commentSnippet ||
+ m.content.title ||
+ m.content.displayName ||
+ ''
+ )
+ .with(
+ { tag: 'github_pr_mention' },
+ (m) =>
+ m.content.textSnippet || m.content.title || m.content.displayName || ''
+ )
+ .with(
+ { tag: 'github_pr_review' },
+ (m) =>
+ m.content.reviewSnippet ||
+ m.content.title ||
+ m.content.displayName ||
+ ''
+ )
.with({ tag: 'channel_invite' }, () => '')
.with({ tag: 'invite_to_team' }, () => '')
.with({ tag: 'call-started' }, (m) => m.content.channel_name ?? '')
diff --git a/js/app/packages/entity/tests/notification-description.test.ts b/js/app/packages/entity/tests/notification-description.test.ts
index fa4d5dfb17..a7b4273522 100644
--- a/js/app/packages/entity/tests/notification-description.test.ts
+++ b/js/app/packages/entity/tests/notification-description.test.ts
@@ -111,8 +111,10 @@ describe('notification-description helpers', () => {
expect(getActionVerb('task_assigned')).toBe('assigned you');
});
- it('returns correct verb for github_pr_event', () => {
- expect(getActionVerb('github_pr_event')).toBe('updated a pull request');
+ it('returns correct verb for github_pr_status_changed', () => {
+ expect(getActionVerb('github_pr_status_changed')).toBe(
+ 'updated a pull request'
+ );
});
});
@@ -211,13 +213,15 @@ describe('notification-description helpers', () => {
});
});
- describe('github_pr_event', () => {
+ describe('github_pr_status_changed', () => {
it('returns singular for count of 1', () => {
- expect(getTypeNoun('github_pr_event', 1)).toBe('pull request');
+ expect(getTypeNoun('github_pr_status_changed', 1)).toBe('pull request');
});
it('returns plural for count greater than 1', () => {
- expect(getTypeNoun('github_pr_event', 2)).toBe('pull requests');
+ expect(getTypeNoun('github_pr_status_changed', 2)).toBe(
+ 'pull requests'
+ );
});
});
diff --git a/js/app/packages/entity/tests/notification.test.ts b/js/app/packages/entity/tests/notification.test.ts
index 44b1805844..e307fcb7f4 100644
--- a/js/app/packages/entity/tests/notification.test.ts
+++ b/js/app/packages/entity/tests/notification.test.ts
@@ -1,4 +1,4 @@
-import type { GithubPrEvent } from '@service-notification/generated/schemas';
+import type { GithubPrStatusChanged } from '@service-notification/generated/schemas';
import { describe, expect, it } from 'vitest';
import type { Notification } from '../src/types/notification';
import {
@@ -14,12 +14,14 @@ const GITHUB_PR_FOREIGN_ENTITY_ID = '123e4567-e89b-12d3-a456-426614174000';
type GithubPrNotification = Notification & {
notification_metadata: {
- content: GithubPrEvent;
- tag: 'github_pr_event';
+ content: GithubPrStatusChanged;
+ tag: 'github_pr_status_changed';
};
};
-function githubPrEvent(overrides: Partial<GithubPrEvent> = {}): GithubPrEvent {
+function githubPrStatusChanged(
+ overrides: Partial<GithubPrStatusChanged> = {}
+): GithubPrStatusChanged {
return {
action: 'opened',
displayName: 'macro/macro#42',
@@ -36,12 +38,12 @@ function githubPrEvent(overrides: Partial<GithubPrEvent> = {}): GithubPrEvent {
}
function githubPrNotification(
- overrides: Partial<GithubPrEvent> = {}
+ overrides: Partial<GithubPrStatusChanged> = {}
): GithubPrNotification {
return {
notification_metadata: {
- content: githubPrEvent(overrides),
- tag: 'github_pr_event',
+ content: githubPrStatusChanged(overrides),
+ tag: 'github_pr_status_changed',
},
} as GithubPrNotification;
}
@@ -286,7 +288,7 @@ describe('notification utils', () => {
expect(getNotificationActionText(notification)).toBe('assigned');
});
- it('returns correct action text for github_pr_event', () => {
+ it('returns correct action text for github_pr_status_changed', () => {
expect(getNotificationActionText(githubPrNotification())).toBe('updated');
});
});
diff --git a/js/app/packages/notifications/github-event-types.ts b/js/app/packages/notifications/github-event-types.ts
new file mode 100644
index 0000000000..d81ef380f1
--- /dev/null
+++ b/js/app/packages/notifications/github-event-types.ts
@@ -0,0 +1,13 @@
+/**
+ * The notification event tags emitted for GitHub pull request activity.
+ *
+ * Kept in a dependency-free module so display helpers (and their tests) can
+ * import it without pulling in the notification source's client-only graph.
+ */
+export const GITHUB_EVENT_TYPES = [
+ 'github_pr_status_changed',
+ 'github_review_requested',
+ 'github_pr_comment',
+ 'github_pr_mention',
+ 'github_pr_review',
+] as const;
diff --git a/js/app/packages/notifications/notification-metadata.ts b/js/app/packages/notifications/notification-metadata.ts
index 0ad16f5e95..f324641b23 100644
--- a/js/app/packages/notifications/notification-metadata.ts
+++ b/js/app/packages/notifications/notification-metadata.ts
@@ -1,4 +1,5 @@
-import { match } from 'ts-pattern';
+import { match, P } from 'ts-pattern';
+import { GITHUB_EVENT_TYPES } from './github-event-types';
import type { UnifiedNotification } from './types';
// Helper functions for derived notification data
@@ -17,7 +18,11 @@ export function getNotificationAction(n: UnifiedNotification): string {
.with('new_email', () => 'sent a new email')
.with('invite_to_team', () => 'invited you to')
.with('task_assigned', () => 'assigned you a task')
- .with('github_pr_event', () => 'updated a pull request')
+ .with('github_pr_status_changed', () => 'updated a pull request')
+ .with('github_review_requested', () => 'requested your review on')
+ .with('github_pr_comment', () => 'commented on')
+ .with('github_pr_mention', () => 'mentioned you in')
+ .with('github_pr_review', () => 'reviewed')
.exhaustive();
}
@@ -40,7 +45,7 @@ export function getNotificationTargetName(
.with({ tag: 'invite_to_team' }, (m) => m.content.teamName)
.with({ tag: 'task_assigned' }, (m) => m.content.taskName ?? undefined)
.with(
- { tag: 'github_pr_event' },
+ { tag: P.union(...GITHUB_EVENT_TYPES) },
(m) => `${m.content.owner}/${m.content.repo}#${m.content.number}`
)
.with({ tag: 'channel_mention' }, () => undefined)
@@ -67,9 +72,22 @@ export function getNotificationContent(
.with({ tag: 'new_email' }, (m) => m.content.subject)
.with({ tag: 'task_assigned' }, (m) => m.content.taskName ?? undefined)
.with(
- { tag: 'github_pr_event' },
+ { tag: P.union('github_pr_status_changed', 'github_review_requested') },
(m) => m.content.title || m.content.displayName
)
+ .with(
+ { tag: 'github_pr_comment' },
+ (m) =>
+ m.content.commentSnippet || m.content.title || m.content.displayName
+ )
+ .with(
+ { tag: 'github_pr_mention' },
+ (m) => m.content.textSnippet || m.content.title || m.content.displayName
+ )
+ .with(
+ { tag: 'github_pr_review' },
+ (m) => m.content.reviewSnippet || m.content.title || m.content.displayName
+ )
.with({ tag: 'channel_invite' }, () => undefined)
.with({ tag: 'invite_to_team' }, () => undefined)
.exhaustive();
@@ -93,7 +111,7 @@ export function shouldShowNotificationTarget(n: UnifiedNotification): boolean {
.with({ tag: 'ai_response' }, () => false)
.with({ tag: 'new_email' }, () => false)
.with({ tag: 'task_assigned' }, () => true)
- .with({ tag: 'github_pr_event' }, () => true)
+ .with({ tag: P.union(...GITHUB_EVENT_TYPES) }, () => true)
.with({ tag: 'document_mention' }, () => true)
.with({ tag: 'mentioned_in_document_comment' }, () => true)
.with({ tag: 'replied_to_document_comment_thread' }, () => true)
diff --git a/js/app/packages/notifications/notification-navigation.ts b/js/app/packages/notifications/notification-navigation.ts
index 4d97e962c9..36e583c22e 100644
--- a/js/app/packages/notifications/notification-navigation.ts
+++ b/js/app/packages/notifications/notification-navigation.ts
@@ -16,6 +16,7 @@ import { openExternalUrl } from '@core/util/url';
import { getNotificationById } from '@queries/notification/user-notifications';
import { errAsync, ResultAsync } from 'neverthrow';
import { match, P } from 'ts-pattern';
+import { GITHUB_EVENT_TYPES } from './github-event-types';
import { isChannelNotification } from './notification-helpers';
import type { NotificationSource } from './notification-source';
import { CHANNEL_EVENT_TYPES } from './notification-source';
@@ -238,9 +239,17 @@ function getSupportedHandler(
openSplitIfNotOpen(lm, 'task', meta.content.taskId, { newSplit });
};
})
- .with('github_pr_event', () => {
+ .with(P.union(...GITHUB_EVENT_TYPES), () => {
const meta = notification.notification_metadata;
- if (meta.tag !== 'github_pr_event') return null;
+ if (
+ meta.tag !== 'github_pr_status_changed' &&
+ meta.tag !== 'github_review_requested' &&
+ meta.tag !== 'github_pr_comment' &&
+ meta.tag !== 'github_pr_mention' &&
+ meta.tag !== 'github_pr_review'
+ ) {
+ return null;
+ }
return async () => {
// TODO(dev-rb/github): Route GitHub PR notifications to /pr.
openExternalUrl(meta.content.url);
diff --git a/js/app/packages/notifications/notification-platform.ts b/js/app/packages/notifications/notification-platform.ts
index 1a52c064bf..8fe9bc7520 100644
--- a/js/app/packages/notifications/notification-platform.ts
+++ b/js/app/packages/notifications/notification-platform.ts
@@ -3,6 +3,7 @@ import { getFaviconUrl } from '@app/util/favicon';
import { markdownToPlainText } from '@lexical-core';
import { themeReactive } from '../theme/signals/themeReactive';
import type { PlatformNotificationState } from './components/PlatformNotificationProvider';
+import { GITHUB_EVENT_TYPES } from './github-event-types';
import {
getNotificationAction,
getNotificationContent,
@@ -86,7 +87,9 @@ export async function maybeHandlePlatformNotification(
// render as browser/system popups.
if (
notification.notification_metadata.tag === 'document_mention' ||
- notification.notification_metadata.tag === 'github_pr_event'
+ (GITHUB_EVENT_TYPES as readonly string[]).includes(
+ notification.notification_metadata.tag
+ )
) {
return;
}
diff --git a/js/app/packages/notifications/notification-preview.ts b/js/app/packages/notifications/notification-preview.ts
index c1a0071602..8533120d00 100644
--- a/js/app/packages/notifications/notification-preview.ts
+++ b/js/app/packages/notifications/notification-preview.ts
@@ -13,6 +13,10 @@ export const NOTIFICATION_LABEL_BY_TYPE: Record<NotificationType, string> = {
invite_to_team: 'INVITE',
task_assigned: 'ASSIGNED',
ai_response: 'AI',
- github_pr_event: 'GITHUB',
+ github_pr_status_changed: 'GITHUB',
+ github_review_requested: 'REVIEW',
+ github_pr_comment: 'COMMENT',
+ github_pr_mention: 'MENTION',
+ github_pr_review: 'REVIEW',
'call-started': 'CALL',
} as const;
diff --git a/js/app/packages/notifications/tests/notification-platform.test.ts b/js/app/packages/notifications/tests/notification-platform.test.ts
index 9f44721f7f..7dbc3341d5 100644
--- a/js/app/packages/notifications/tests/notification-platform.test.ts
+++ b/js/app/packages/notifications/tests/notification-platform.test.ts
@@ -70,9 +70,9 @@ function createGithubPrNotification(): UnifiedNotification {
return baseNotification({
entity_id: '123e4567-e89b-12d3-a456-426614174000',
entity_type: 'foreign_entity',
- notification_event_type: 'github_pr_event',
+ notification_event_type: 'github_pr_status_changed',
notification_metadata: {
- tag: 'github_pr_event',
+ tag: 'github_pr_status_changed',
content: {
action: 'opened',
displayName: 'macro/macro#42',
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrComment.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrComment.ts
new file mode 100644
index 0000000000..059f1a1022
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrComment.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+import type { GithubPrCommentAllOf } from './githubPrCommentAllOf';
+import type { GithubPrNotificationCommon } from './githubPrNotificationCommon';
+
+/**
+ * Metadata for a notification that a GitHub pull request was commented on.
+ */
+export type GithubPrComment = GithubPrNotificationCommon & GithubPrCommentAllOf;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrCommentAllOf.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrCommentAllOf.ts
new file mode 100644
index 0000000000..69277af5d2
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrCommentAllOf.ts
@@ -0,0 +1,23 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { GithubPrCommentAllOfCommentGithubId } from './githubPrCommentAllOfCommentGithubId';
+import type { GithubPrCommentAllOfCommentUrl } from './githubPrCommentAllOfCommentUrl';
+import type { GithubPrCommentKind } from './githubPrCommentKind';
+
+export type GithubPrCommentAllOf = {
+ /**
+ * The GitHub numeric id of the comment, when available.
+ * @minimum 0
+ */
+ commentGithubId?: GithubPrCommentAllOfCommentGithubId;
+ /** The kind of comment that was posted. */
+ commentKind: GithubPrCommentKind;
+ /** A truncated excerpt of the comment body. */
+ commentSnippet: string;
+ /** The public GitHub URL for the comment, when available. */
+ commentUrl?: GithubPrCommentAllOfCommentUrl;
+};
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrCommentAllOfCommentGithubId.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrCommentAllOfCommentGithubId.ts
new file mode 100644
index 0000000000..78e303e67a
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrCommentAllOfCommentGithubId.ts
@@ -0,0 +1,12 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * The GitHub numeric id of the comment, when available.
+ * @minimum 0
+ */
+export type GithubPrCommentAllOfCommentGithubId = number | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrCommentAllOfCommentUrl.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrCommentAllOfCommentUrl.ts
new file mode 100644
index 0000000000..e27a2991f0
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrCommentAllOfCommentUrl.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * The public GitHub URL for the comment, when available.
+ */
+export type GithubPrCommentAllOfCommentUrl = string | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrCommentKind.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrCommentKind.ts
new file mode 100644
index 0000000000..464de7a1e8
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrCommentKind.ts
@@ -0,0 +1,18 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * The kind of GitHub comment that triggered a [`GithubPrComment`] notification.
+ */
+export type GithubPrCommentKind =
+ (typeof GithubPrCommentKind)[keyof typeof GithubPrCommentKind];
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const GithubPrCommentKind = {
+ issue: 'issue',
+ review_comment: 'review_comment',
+} as const;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrEvent.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrEvent.ts
deleted file mode 100644
index 79e2af0c6d..0000000000
--- a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrEvent.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Generated by orval v7.21.0 🍺
- * Do not edit manually.
- * notification_service
- * OpenAPI spec version: 0.1.0
- */
-import type { GithubPrEventAction } from './githubPrEventAction';
-import type { GithubPrEventBaseBranch } from './githubPrEventBaseBranch';
-import type { GithubPrEventHeadBranch } from './githubPrEventHeadBranch';
-import type { GithubPrEventMergedAt } from './githubPrEventMergedAt';
-import type { GithubPrEventPreviousStatus } from './githubPrEventPreviousStatus';
-import type { GithubPrEventSenderGithubAvatarUrl } from './githubPrEventSenderGithubAvatarUrl';
-import type { GithubPrEventSenderGithubLogin } from './githubPrEventSenderGithubLogin';
-import type { GithubPrEventSenderGithubUserId } from './githubPrEventSenderGithubUserId';
-import type { GithubPrEventStatus } from './githubPrEventStatus';
-
-/**
- * Metadata for a GitHub pull request lifecycle notification.
- */
-export interface GithubPrEvent {
- /** The webhook action that triggered this notification. */
- action: GithubPrEventAction;
- /** The pull request base branch, when available. */
- baseBranch?: GithubPrEventBaseBranch;
- /** A compact label suitable for display in the UI. */
- displayName: string;
- /** The source-specific internal foreign entity row id for this pull request. */
- foreignEntityId: string;
- /** The external GitHub key, in `owner/repo/pull/number` format. */
- githubKey: string;
- /** The pull request head branch, when available. */
- headBranch?: GithubPrEventHeadBranch;
- /** When the pull request was merged, when available. */
- mergedAt?: GithubPrEventMergedAt;
- /**
- * The GitHub pull request number.
- * @minimum 0
- */
- number: number;
- /** The GitHub repository owner or organization. */
- owner: string;
- previousStatus?: GithubPrEventPreviousStatus;
- /** The GitHub repository name. */
- repo: string;
- /** The GitHub avatar URL for the sender, when available. */
- senderGithubAvatarUrl?: GithubPrEventSenderGithubAvatarUrl;
- /** The GitHub login for the sender, when available. */
- senderGithubLogin?: GithubPrEventSenderGithubLogin;
- /** The stable GitHub numeric user id for the sender, serialized as a string. */
- senderGithubUserId?: GithubPrEventSenderGithubUserId;
- /** The current normalized pull request status. */
- status: GithubPrEventStatus;
- /** The GitHub pull request title. Falls back to `display_name` when GitHub has no title. */
- title: string;
- /** The public GitHub URL for the pull request. */
- url: string;
-}
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrMention.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrMention.ts
new file mode 100644
index 0000000000..fc556be335
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrMention.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+import type { GithubPrMentionAllOf } from './githubPrMentionAllOf';
+import type { GithubPrNotificationCommon } from './githubPrNotificationCommon';
+
+/**
+ * Metadata for a notification that the user was mentioned on a GitHub pull request.
+ */
+export type GithubPrMention = GithubPrNotificationCommon & GithubPrMentionAllOf;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrMentionAllOf.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrMentionAllOf.ts
new file mode 100644
index 0000000000..ecc05c8f8e
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrMentionAllOf.ts
@@ -0,0 +1,23 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { GithubPrMentionAllOfCommentGithubId } from './githubPrMentionAllOfCommentGithubId';
+import type { GithubPrMentionAllOfCommentUrl } from './githubPrMentionAllOfCommentUrl';
+import type { GithubPrMentionLocation } from './githubPrMentionLocation';
+
+export type GithubPrMentionAllOf = {
+ /**
+ * The GitHub numeric id of the comment or review containing the mention, when available.
+ * @minimum 0
+ */
+ commentGithubId?: GithubPrMentionAllOfCommentGithubId;
+ /** The public GitHub URL for the text containing the mention, when available. */
+ commentUrl?: GithubPrMentionAllOfCommentUrl;
+ /** Where the mention appeared. */
+ location: GithubPrMentionLocation;
+ /** A truncated excerpt of the text containing the mention. */
+ textSnippet: string;
+};
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrMentionAllOfCommentGithubId.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrMentionAllOfCommentGithubId.ts
new file mode 100644
index 0000000000..20d5e99b7c
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrMentionAllOfCommentGithubId.ts
@@ -0,0 +1,12 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * The GitHub numeric id of the comment or review containing the mention, when available.
+ * @minimum 0
+ */
+export type GithubPrMentionAllOfCommentGithubId = number | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrMentionAllOfCommentUrl.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrMentionAllOfCommentUrl.ts
new file mode 100644
index 0000000000..c20cfa089d
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrMentionAllOfCommentUrl.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * The public GitHub URL for the text containing the mention, when available.
+ */
+export type GithubPrMentionAllOfCommentUrl = string | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrMentionLocation.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrMentionLocation.ts
new file mode 100644
index 0000000000..6d10826bb5
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrMentionLocation.ts
@@ -0,0 +1,20 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Where in a GitHub pull request the user was mentioned.
+ */
+export type GithubPrMentionLocation =
+ (typeof GithubPrMentionLocation)[keyof typeof GithubPrMentionLocation];
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const GithubPrMentionLocation = {
+ pr_body: 'pr_body',
+ comment: 'comment',
+ review: 'review',
+ review_comment: 'review_comment',
+} as const;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrNotificationCommon.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrNotificationCommon.ts
new file mode 100644
index 0000000000..e65600db14
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrNotificationCommon.ts
@@ -0,0 +1,43 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { GithubPrNotificationCommonSenderGithubAvatarUrl } from './githubPrNotificationCommonSenderGithubAvatarUrl';
+import type { GithubPrNotificationCommonSenderGithubLogin } from './githubPrNotificationCommonSenderGithubLogin';
+import type { GithubPrNotificationCommonSenderGithubUserId } from './githubPrNotificationCommonSenderGithubUserId';
+
+/**
+ * Fields shared by every GitHub pull request notification type.
+
+Embedded with `#[serde(flatten)]` so the wire shape keeps these keys at the
+top level of the metadata object.
+ */
+export interface GithubPrNotificationCommon {
+ /** A compact label suitable for display in the UI. */
+ displayName: string;
+ /** The source-specific internal foreign entity row id for this pull request. */
+ foreignEntityId: string;
+ /** The external GitHub key, in `owner/repo/pull/number` format. */
+ githubKey: string;
+ /**
+ * The GitHub pull request number.
+ * @minimum 0
+ */
+ number: number;
+ /** The GitHub repository owner or organization. */
+ owner: string;
+ /** The GitHub repository name. */
+ repo: string;
+ /** The GitHub avatar URL for the sender, when available. */
+ senderGithubAvatarUrl?: GithubPrNotificationCommonSenderGithubAvatarUrl;
+ /** The GitHub login for the sender, when available. */
+ senderGithubLogin?: GithubPrNotificationCommonSenderGithubLogin;
+ /** The stable GitHub numeric user id for the sender, serialized as a string. */
+ senderGithubUserId?: GithubPrNotificationCommonSenderGithubUserId;
+ /** The GitHub pull request title. Falls back to `display_name` when GitHub has no title. */
+ title: string;
+ /** The public GitHub URL for the pull request. */
+ url: string;
+}
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventSenderGithubAvatarUrl.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrNotificationCommonSenderGithubAvatarUrl.ts
similarity index 71%
rename from js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventSenderGithubAvatarUrl.ts
rename to js/app/packages/service-clients/service-notification/generated/schemas/githubPrNotificationCommonSenderGithubAvatarUrl.ts
index 766ba1ea25..f64b3d6cc6 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventSenderGithubAvatarUrl.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrNotificationCommonSenderGithubAvatarUrl.ts
@@ -8,4 +8,4 @@
/**
* The GitHub avatar URL for the sender, when available.
*/
-export type GithubPrEventSenderGithubAvatarUrl = string | null;
+export type GithubPrNotificationCommonSenderGithubAvatarUrl = string | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventSenderGithubLogin.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrNotificationCommonSenderGithubLogin.ts
similarity index 71%
rename from js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventSenderGithubLogin.ts
rename to js/app/packages/service-clients/service-notification/generated/schemas/githubPrNotificationCommonSenderGithubLogin.ts
index 40821dbfb9..8a0ae6a5a7 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventSenderGithubLogin.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrNotificationCommonSenderGithubLogin.ts
@@ -8,4 +8,4 @@
/**
* The GitHub login for the sender, when available.
*/
-export type GithubPrEventSenderGithubLogin = string | null;
+export type GithubPrNotificationCommonSenderGithubLogin = string | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventSenderGithubUserId.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrNotificationCommonSenderGithubUserId.ts
similarity index 73%
rename from js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventSenderGithubUserId.ts
rename to js/app/packages/service-clients/service-notification/generated/schemas/githubPrNotificationCommonSenderGithubUserId.ts
index 48ad2d9fc3..f1dcafb503 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventSenderGithubUserId.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrNotificationCommonSenderGithubUserId.ts
@@ -8,4 +8,4 @@
/**
* The stable GitHub numeric user id for the sender, serialized as a string.
*/
-export type GithubPrEventSenderGithubUserId = string | null;
+export type GithubPrNotificationCommonSenderGithubUserId = string | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrReview.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrReview.ts
new file mode 100644
index 0000000000..5ec33c8dc1
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrReview.ts
@@ -0,0 +1,13 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { GithubPrNotificationCommon } from './githubPrNotificationCommon';
+import type { GithubPrReviewAllOf } from './githubPrReviewAllOf';
+
+/**
+ * Metadata for a notification that a review was submitted on the user's GitHub pull request.
+ */
+export type GithubPrReview = GithubPrNotificationCommon & GithubPrReviewAllOf;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrReviewAllOf.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrReviewAllOf.ts
new file mode 100644
index 0000000000..5c76f31839
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrReviewAllOf.ts
@@ -0,0 +1,24 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { GithubPrReviewAllOfReviewGithubId } from './githubPrReviewAllOfReviewGithubId';
+import type { GithubPrReviewAllOfReviewSnippet } from './githubPrReviewAllOfReviewSnippet';
+import type { GithubPrReviewAllOfReviewUrl } from './githubPrReviewAllOfReviewUrl';
+import type { GithubPrReviewState } from './githubPrReviewState';
+
+export type GithubPrReviewAllOf = {
+ /**
+ * The GitHub numeric id of the review, when available.
+ * @minimum 0
+ */
+ reviewGithubId?: GithubPrReviewAllOfReviewGithubId;
+ /** A truncated excerpt of the review body, when any was written. */
+ reviewSnippet?: GithubPrReviewAllOfReviewSnippet;
+ /** The public GitHub URL for the review, when available. */
+ reviewUrl?: GithubPrReviewAllOfReviewUrl;
+ /** The review decision state. */
+ state: GithubPrReviewState;
+};
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrReviewAllOfReviewGithubId.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrReviewAllOfReviewGithubId.ts
new file mode 100644
index 0000000000..c99821ac6d
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrReviewAllOfReviewGithubId.ts
@@ -0,0 +1,12 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * The GitHub numeric id of the review, when available.
+ * @minimum 0
+ */
+export type GithubPrReviewAllOfReviewGithubId = number | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrReviewAllOfReviewSnippet.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrReviewAllOfReviewSnippet.ts
new file mode 100644
index 0000000000..147d375aa9
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrReviewAllOfReviewSnippet.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * A truncated excerpt of the review body, when any was written.
+ */
+export type GithubPrReviewAllOfReviewSnippet = string | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrReviewAllOfReviewUrl.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrReviewAllOfReviewUrl.ts
new file mode 100644
index 0000000000..f849a7ec16
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrReviewAllOfReviewUrl.ts
@@ -0,0 +1,11 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * The public GitHub URL for the review, when available.
+ */
+export type GithubPrReviewAllOfReviewUrl = string | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrReviewState.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrReviewState.ts
new file mode 100644
index 0000000000..5d75e353a4
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrReviewState.ts
@@ -0,0 +1,19 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * The state of a submitted GitHub pull request review.
+ */
+export type GithubPrReviewState =
+ (typeof GithubPrReviewState)[keyof typeof GithubPrReviewState];
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const GithubPrReviewState = {
+ approved: 'approved',
+ changes_requested: 'changes_requested',
+ commented: 'commented',
+} as const;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrStatusChanged.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrStatusChanged.ts
new file mode 100644
index 0000000000..5fda4108be
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrStatusChanged.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { GithubPrNotificationCommon } from './githubPrNotificationCommon';
+import type { GithubPrStatusChangedAllOf } from './githubPrStatusChangedAllOf';
+
+/**
+ * Metadata for a GitHub pull request lifecycle notification.
+ */
+export type GithubPrStatusChanged = GithubPrNotificationCommon &
+ GithubPrStatusChangedAllOf;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrStatusChangedAllOf.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrStatusChangedAllOf.ts
new file mode 100644
index 0000000000..89bdb0c9d4
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrStatusChangedAllOf.ts
@@ -0,0 +1,26 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { GithubPrEventAction } from './githubPrEventAction';
+import type { GithubPrEventStatus } from './githubPrEventStatus';
+import type { GithubPrStatusChangedAllOfBaseBranch } from './githubPrStatusChangedAllOfBaseBranch';
+import type { GithubPrStatusChangedAllOfHeadBranch } from './githubPrStatusChangedAllOfHeadBranch';
+import type { GithubPrStatusChangedAllOfMergedAt } from './githubPrStatusChangedAllOfMergedAt';
+import type { GithubPrStatusChangedAllOfPreviousStatus } from './githubPrStatusChangedAllOfPreviousStatus';
+
+export type GithubPrStatusChangedAllOf = {
+ /** The webhook action that triggered this notification. */
+ action: GithubPrEventAction;
+ /** The pull request base branch, when available. */
+ baseBranch?: GithubPrStatusChangedAllOfBaseBranch;
+ /** The pull request head branch, when available. */
+ headBranch?: GithubPrStatusChangedAllOfHeadBranch;
+ /** When the pull request was merged, when available. */
+ mergedAt?: GithubPrStatusChangedAllOfMergedAt;
+ previousStatus?: GithubPrStatusChangedAllOfPreviousStatus;
+ /** The current normalized pull request status. */
+ status: GithubPrEventStatus;
+};
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventBaseBranch.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrStatusChangedAllOfBaseBranch.ts
similarity index 73%
rename from js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventBaseBranch.ts
rename to js/app/packages/service-clients/service-notification/generated/schemas/githubPrStatusChangedAllOfBaseBranch.ts
index 4116bacfa5..239471ef5e 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventBaseBranch.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrStatusChangedAllOfBaseBranch.ts
@@ -8,4 +8,4 @@
/**
* The pull request base branch, when available.
*/
-export type GithubPrEventBaseBranch = string | null;
+export type GithubPrStatusChangedAllOfBaseBranch = string | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventHeadBranch.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrStatusChangedAllOfHeadBranch.ts
similarity index 73%
rename from js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventHeadBranch.ts
rename to js/app/packages/service-clients/service-notification/generated/schemas/githubPrStatusChangedAllOfHeadBranch.ts
index ac66aa1045..6faf3db1d5 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventHeadBranch.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrStatusChangedAllOfHeadBranch.ts
@@ -8,4 +8,4 @@
/**
* The pull request head branch, when available.
*/
-export type GithubPrEventHeadBranch = string | null;
+export type GithubPrStatusChangedAllOfHeadBranch = string | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventMergedAt.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrStatusChangedAllOfMergedAt.ts
similarity index 74%
rename from js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventMergedAt.ts
rename to js/app/packages/service-clients/service-notification/generated/schemas/githubPrStatusChangedAllOfMergedAt.ts
index f548197229..88124c7a21 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventMergedAt.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrStatusChangedAllOfMergedAt.ts
@@ -8,4 +8,4 @@
/**
* When the pull request was merged, when available.
*/
-export type GithubPrEventMergedAt = string | null;
+export type GithubPrStatusChangedAllOfMergedAt = string | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventPreviousStatus.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrStatusChangedAllOfPreviousStatus.ts
similarity index 69%
rename from js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventPreviousStatus.ts
rename to js/app/packages/service-clients/service-notification/generated/schemas/githubPrStatusChangedAllOfPreviousStatus.ts
index 99a9df0ce9..9b8fc517f1 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/githubPrEventPreviousStatus.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubPrStatusChangedAllOfPreviousStatus.ts
@@ -6,4 +6,5 @@
*/
import type { GithubPrEventStatus } from './githubPrEventStatus';
-export type GithubPrEventPreviousStatus = null | GithubPrEventStatus;
+export type GithubPrStatusChangedAllOfPreviousStatus =
+ null | GithubPrEventStatus;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubReviewRequested.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubReviewRequested.ts
new file mode 100644
index 0000000000..d80ce1f233
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubReviewRequested.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { GithubPrNotificationCommon } from './githubPrNotificationCommon';
+import type { GithubReviewRequestedAllOf } from './githubReviewRequestedAllOf';
+
+/**
+ * Metadata for a notification that the user's review was requested on a GitHub pull request.
+ */
+export type GithubReviewRequested = GithubPrNotificationCommon &
+ GithubReviewRequestedAllOf;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubReviewRequestedAllOf.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubReviewRequestedAllOf.ts
new file mode 100644
index 0000000000..ce989f038b
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubReviewRequestedAllOf.ts
@@ -0,0 +1,15 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { GithubReviewRequestedAllOfRequestedReviewerGithubLogin } from './githubReviewRequestedAllOfRequestedReviewerGithubLogin';
+import type { GithubReviewRequestedAllOfRequestedReviewerGithubUserId } from './githubReviewRequestedAllOfRequestedReviewerGithubUserId';
+
+export type GithubReviewRequestedAllOf = {
+ /** The GitHub login of the requested reviewer, when available. */
+ requestedReviewerGithubLogin?: GithubReviewRequestedAllOfRequestedReviewerGithubLogin;
+ /** The stable GitHub numeric user id of the requested reviewer, serialized as a string. */
+ requestedReviewerGithubUserId?: GithubReviewRequestedAllOfRequestedReviewerGithubUserId;
+};
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubReviewRequestedAllOfRequestedReviewerGithubLogin.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubReviewRequestedAllOfRequestedReviewerGithubLogin.ts
new file mode 100644
index 0000000000..4d342163e4
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubReviewRequestedAllOfRequestedReviewerGithubLogin.ts
@@ -0,0 +1,13 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * The GitHub login of the requested reviewer, when available.
+ */
+export type GithubReviewRequestedAllOfRequestedReviewerGithubLogin =
+ | string
+ | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/githubReviewRequestedAllOfRequestedReviewerGithubUserId.ts b/js/app/packages/service-clients/service-notification/generated/schemas/githubReviewRequestedAllOfRequestedReviewerGithubUserId.ts
new file mode 100644
index 0000000000..3eca4de100
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/githubReviewRequestedAllOfRequestedReviewerGithubUserId.ts
@@ -0,0 +1,13 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * The stable GitHub numeric user id of the requested reviewer, serialized as a string.
+ */
+export type GithubReviewRequestedAllOfRequestedReviewerGithubUserId =
+ | string
+ | null;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/index.ts b/js/app/packages/service-clients/service-notification/generated/schemas/index.ts
index 7cd28c2d5e..c1fc2692c8 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/index.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/index.ts
@@ -60,16 +60,38 @@ export * from './getAllUserNotificationsResponse';
export * from './getAllUserNotificationsResponseNextCursor';
export * from './getNotificationTypePreferencesResponse';
export * from './getTypedNotificationsByEventItemIdParams';
-export * from './githubPrEvent';
+export * from './githubPrComment';
+export * from './githubPrCommentAllOf';
+export * from './githubPrCommentAllOfCommentGithubId';
+export * from './githubPrCommentAllOfCommentUrl';
+export * from './githubPrCommentKind';
export * from './githubPrEventAction';
-export * from './githubPrEventBaseBranch';
-export * from './githubPrEventHeadBranch';
-export * from './githubPrEventMergedAt';
-export * from './githubPrEventPreviousStatus';
-export * from './githubPrEventSenderGithubAvatarUrl';
-export * from './githubPrEventSenderGithubLogin';
-export * from './githubPrEventSenderGithubUserId';
export * from './githubPrEventStatus';
+export * from './githubPrMention';
+export * from './githubPrMentionAllOf';
+export * from './githubPrMentionAllOfCommentGithubId';
+export * from './githubPrMentionAllOfCommentUrl';
+export * from './githubPrMentionLocation';
+export * from './githubPrNotificationCommon';
+export * from './githubPrNotificationCommonSenderGithubAvatarUrl';
+export * from './githubPrNotificationCommonSenderGithubLogin';
+export * from './githubPrNotificationCommonSenderGithubUserId';
+export * from './githubPrReview';
+export * from './githubPrReviewAllOf';
+export * from './githubPrReviewAllOfReviewGithubId';
+export * from './githubPrReviewAllOfReviewSnippet';
+export * from './githubPrReviewAllOfReviewUrl';
+export * from './githubPrReviewState';
+export * from './githubPrStatusChanged';
+export * from './githubPrStatusChangedAllOf';
+export * from './githubPrStatusChangedAllOfBaseBranch';
+export * from './githubPrStatusChangedAllOfHeadBranch';
+export * from './githubPrStatusChangedAllOfMergedAt';
+export * from './githubPrStatusChangedAllOfPreviousStatus';
+export * from './githubReviewRequested';
+export * from './githubReviewRequestedAllOf';
+export * from './githubReviewRequestedAllOfRequestedReviewerGithubLogin';
+export * from './githubReviewRequestedAllOfRequestedReviewerGithubUserId';
export * from './inviteToTeamMetadata';
export * from './inviteToTeamMetadataRole';
export * from './inviteToTeamMetadataSenderProfilePictureUrl';
@@ -104,11 +126,19 @@ export * from './notifEventOneOfSeven';
export * from './notifEventOneOfSevenTag';
export * from './notifEventOneOfTag';
export * from './notifEventOneOfThree';
+export * from './notifEventOneOfThreeone';
+export * from './notifEventOneOfThreeoneTag';
export * from './notifEventOneOfThreeTag';
+export * from './notifEventOneOfThreethree';
+export * from './notifEventOneOfThreethreeTag';
export * from './notifEventOneOfTwofive';
export * from './notifEventOneOfTwofiveTag';
+export * from './notifEventOneOfTwonine';
+export * from './notifEventOneOfTwonineTag';
export * from './notifEventOneOfTwoone';
export * from './notifEventOneOfTwooneTag';
+export * from './notifEventOneOfTwoseven';
+export * from './notifEventOneOfTwosevenTag';
export * from './notifEventOneOfTwothree';
export * from './notifEventOneOfTwothreeTag';
export * from './notificationBulkRequest';
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/notifEvent.ts b/js/app/packages/service-clients/service-notification/generated/schemas/notifEvent.ts
index 89682d89a2..d1a1602aa2 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/notifEvent.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/notifEvent.ts
@@ -14,8 +14,12 @@ import type { NotifEventOneOfOneseven } from './notifEventOneOfOneseven';
import type { NotifEventOneOfOnethree } from './notifEventOneOfOnethree';
import type { NotifEventOneOfSeven } from './notifEventOneOfSeven';
import type { NotifEventOneOfThree } from './notifEventOneOfThree';
+import type { NotifEventOneOfThreeone } from './notifEventOneOfThreeone';
+import type { NotifEventOneOfThreethree } from './notifEventOneOfThreethree';
import type { NotifEventOneOfTwofive } from './notifEventOneOfTwofive';
+import type { NotifEventOneOfTwonine } from './notifEventOneOfTwonine';
import type { NotifEventOneOfTwoone } from './notifEventOneOfTwoone';
+import type { NotifEventOneOfTwoseven } from './notifEventOneOfTwoseven';
import type { NotifEventOneOfTwothree } from './notifEventOneOfTwothree';
/**
@@ -39,4 +43,8 @@ export type NotifEvent =
| NotifEventOneOfOnenine
| NotifEventOneOfTwoone
| NotifEventOneOfTwothree
- | NotifEventOneOfTwofive;
+ | NotifEventOneOfTwofive
+ | NotifEventOneOfTwoseven
+ | NotifEventOneOfTwonine
+ | NotifEventOneOfThreeone
+ | NotifEventOneOfThreethree;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfThreeone.ts b/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfThreeone.ts
new file mode 100644
index 0000000000..30a475f962
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfThreeone.ts
@@ -0,0 +1,17 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { GithubPrMention } from './githubPrMention';
+import type { NotifEventOneOfThreeoneTag } from './notifEventOneOfThreeoneTag';
+
+/**
+ * The user was mentioned on a GitHub pull request.
+ */
+export type NotifEventOneOfThreeone = {
+ /** The user was mentioned on a GitHub pull request. */
+ content: GithubPrMention;
+ tag: NotifEventOneOfThreeoneTag;
+};
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfThreeoneTag.ts b/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfThreeoneTag.ts
new file mode 100644
index 0000000000..cb019c1e9d
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfThreeoneTag.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type NotifEventOneOfThreeoneTag =
+ (typeof NotifEventOneOfThreeoneTag)[keyof typeof NotifEventOneOfThreeoneTag];
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const NotifEventOneOfThreeoneTag = {
+ github_pr_mention: 'github_pr_mention',
+} as const;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfThreethree.ts b/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfThreethree.ts
new file mode 100644
index 0000000000..ce826e9322
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfThreethree.ts
@@ -0,0 +1,17 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { GithubPrReview } from './githubPrReview';
+import type { NotifEventOneOfThreethreeTag } from './notifEventOneOfThreethreeTag';
+
+/**
+ * A review was submitted on the user's GitHub pull request.
+ */
+export type NotifEventOneOfThreethree = {
+ /** A review was submitted on the user's GitHub pull request. */
+ content: GithubPrReview;
+ tag: NotifEventOneOfThreethreeTag;
+};
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfThreethreeTag.ts b/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfThreethreeTag.ts
new file mode 100644
index 0000000000..4d60611c72
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfThreethreeTag.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type NotifEventOneOfThreethreeTag =
+ (typeof NotifEventOneOfThreethreeTag)[keyof typeof NotifEventOneOfThreethreeTag];
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const NotifEventOneOfThreethreeTag = {
+ github_pr_review: 'github_pr_review',
+} as const;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfTwofive.ts b/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfTwofive.ts
index 524d3c5bb0..85e779a63e 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfTwofive.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfTwofive.ts
@@ -4,14 +4,20 @@
* notification_service
* OpenAPI spec version: 0.1.0
*/
-import type { GithubPrEvent } from './githubPrEvent';
+import type { GithubPrStatusChanged } from './githubPrStatusChanged';
import type { NotifEventOneOfTwofiveTag } from './notifEventOneOfTwofiveTag';
/**
* A GitHub pull request changed lifecycle state.
+
+The `github_pr_event` alias keeps rows and queue messages persisted
+before the rename deserializable.
*/
export type NotifEventOneOfTwofive = {
- /** A GitHub pull request changed lifecycle state. */
- content: GithubPrEvent;
+ /** A GitHub pull request changed lifecycle state.
+
+The `github_pr_event` alias keeps rows and queue messages persisted
+before the rename deserializable. */
+ content: GithubPrStatusChanged;
tag: NotifEventOneOfTwofiveTag;
};
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfTwofiveTag.ts b/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfTwofiveTag.ts
index e5d09b173d..70863e176f 100644
--- a/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfTwofiveTag.ts
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfTwofiveTag.ts
@@ -10,5 +10,5 @@ export type NotifEventOneOfTwofiveTag =
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const NotifEventOneOfTwofiveTag = {
- github_pr_event: 'github_pr_event',
+ github_pr_status_changed: 'github_pr_status_changed',
} as const;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfTwonine.ts b/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfTwonine.ts
new file mode 100644
index 0000000000..88b141c373
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfTwonine.ts
@@ -0,0 +1,17 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { GithubPrComment } from './githubPrComment';
+import type { NotifEventOneOfTwonineTag } from './notifEventOneOfTwonineTag';
+
+/**
+ * A GitHub pull request was commented on.
+ */
+export type NotifEventOneOfTwonine = {
+ /** A GitHub pull request was commented on. */
+ content: GithubPrComment;
+ tag: NotifEventOneOfTwonineTag;
+};
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfTwonineTag.ts b/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfTwonineTag.ts
new file mode 100644
index 0000000000..920c0cce78
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfTwonineTag.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type NotifEventOneOfTwonineTag =
+ (typeof NotifEventOneOfTwonineTag)[keyof typeof NotifEventOneOfTwonineTag];
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const NotifEventOneOfTwonineTag = {
+ github_pr_comment: 'github_pr_comment',
+} as const;
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfTwoseven.ts b/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfTwoseven.ts
new file mode 100644
index 0000000000..b52a2e2929
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfTwoseven.ts
@@ -0,0 +1,17 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { GithubReviewRequested } from './githubReviewRequested';
+import type { NotifEventOneOfTwosevenTag } from './notifEventOneOfTwosevenTag';
+
+/**
+ * The user's review was requested on a GitHub pull request.
+ */
+export type NotifEventOneOfTwoseven = {
+ /** The user's review was requested on a GitHub pull request. */
+ content: GithubReviewRequested;
+ tag: NotifEventOneOfTwosevenTag;
+};
diff --git a/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfTwosevenTag.ts b/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfTwosevenTag.ts
new file mode 100644
index 0000000000..3cbaa37699
--- /dev/null
+++ b/js/app/packages/service-clients/service-notification/generated/schemas/notifEventOneOfTwosevenTag.ts
@@ -0,0 +1,14 @@
+/**
+ * Generated by orval v7.21.0 🍺
+ * Do not edit manually.
+ * notification_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+export type NotifEventOneOfTwosevenTag =
+ (typeof NotifEventOneOfTwosevenTag)[keyof typeof NotifEventOneOfTwosevenTag];
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export const NotifEventOneOfTwosevenTag = {
+ github_review_requested: 'github_review_requested',
+} as const;
diff --git a/js/app/packages/service-clients/service-notification/generated/zod.ts b/js/app/packages/service-clients/service-notification/generated/zod.ts
index 2b2c1c54d4..f47fcca25e 100644
--- a/js/app/packages/service-clients/service-notification/generated/zod.ts
+++ b/js/app/packages/service-clients/service-notification/generated/zod.ts
@@ -101,6 +101,20 @@ export const listTypedNotificationsQueryParams = zod.object({
export const listTypedNotificationsResponseItemsItemNotificationMetadataContentNumberMin = 0;
+export const listTypedNotificationsResponseItemsItemNotificationMetadataContentNumberMinOne = 0;
+
+export const listTypedNotificationsResponseItemsItemNotificationMetadataContentNumberMinTwo = 0;
+
+export const listTypedNotificationsResponseItemsItemNotificationMetadataContentCommentGithubIdMin = 0;
+
+export const listTypedNotificationsResponseItemsItemNotificationMetadataContentNumberMinThree = 0;
+
+export const listTypedNotificationsResponseItemsItemNotificationMetadataContentCommentGithubIdMinOne = 0;
+
+export const listTypedNotificationsResponseItemsItemNotificationMetadataContentNumberMinFour = 0;
+
+export const listTypedNotificationsResponseItemsItemNotificationMetadataContentReviewGithubIdMin = 0;
+
export const listTypedNotificationsResponse = zod
.object({
items: zod
@@ -616,17 +630,6 @@ export const listTypedNotificationsResponse = zod
.object({
content: zod
.object({
- action: zod
- .enum(['opened', 'reopened', 'closed'])
- .describe(
- 'The GitHub pull request webhook action that triggered the notification.'
- ),
- baseBranch: zod
- .string()
- .nullish()
- .describe(
- 'The pull request base branch, when available.'
- ),
displayName: zod
.string()
.describe(
@@ -642,18 +645,6 @@ export const listTypedNotificationsResponse = zod
.describe(
'The external GitHub key, in `owner\/repo\/pull\/number` format.'
),
- headBranch: zod
- .string()
- .nullish()
- .describe(
- 'The pull request head branch, when available.'
- ),
- mergedAt: zod.iso
- .datetime({})
- .nullish()
- .describe(
- 'When the pull request was merged, when available.'
- ),
number: zod
.number()
.min(
@@ -665,16 +656,6 @@ export const listTypedNotificationsResponse = zod
.describe(
'The GitHub repository owner or organization.'
),
- previousStatus: zod
- .union([
- zod.null(),
- zod
- .enum(['open', 'closed', 'merged'])
- .describe(
- 'The normalized lifecycle status for a GitHub pull request notification.'
- ),
- ])
- .optional(),
repo: zod
.string()
.describe('The GitHub repository name.'),
@@ -696,11 +677,6 @@ export const listTypedNotificationsResponse = zod
.describe(
'The stable GitHub numeric user id for the sender, serialized as a string.'
),
- status: zod
- .enum(['open', 'closed', 'merged'])
- .describe(
- 'The normalized lifecycle status for a GitHub pull request notification.'
- ),
title: zod
.string()
.describe(
@@ -713,242 +689,706 @@ export const listTypedNotificationsResponse = zod
),
})
.describe(
- 'Metadata for a GitHub pull request lifecycle notification.'
- ),
- tag: zod.enum(['github_pr_event']),
- })
- .describe('A GitHub pull request changed lifecycle state.'),
- ])
- .describe(
- 'Mirrors [`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.'
- ),
- owner_id: zod
- .string()
- .describe('The user who owns this notification.'),
- sender_id: zod
- .string()
- .nullish()
- .describe('The user who triggered the notification.'),
- sent: zod
- .boolean()
- .describe('Whether the notification has been sent.'),
- updated_at: zod.iso
- .datetime({})
- .describe('When the notification was last updated.'),
- viewed_at: zod.iso
- .datetime({})
- .nullish()
- .describe('When the notification was viewed\/seen.'),
- })
- )
- )
- .describe('The list of items returned.'),
- next_cursor: zod
- .string()
- .nullish()
- .describe('The next page cursor if it exists.'),
- })
- .describe('The strongly typed response for listing user notifications.');
-
-/**
- * Rows that fail to deserialize are dropped with a warning log.
- * @summary Wrapper handler that calls the inner generic bulk-get handler with `serde_json::Value`,
-then converts each row to [`UserNotificationRow<NotifEvent>`].
- */
-export const bulkGetTypedNotificationsByEventItemIdsQueryLimitMin = 0;
-
-export const bulkGetTypedNotificationsByEventItemIdsQueryParams = zod.object({
- limit: zod
- .number()
- .min(bulkGetTypedNotificationsByEventItemIdsQueryLimitMin)
- .optional()
- .describe('Size limit per page. Default 20, max 500.'),
- cursor: zod
- .string()
- .optional()
- .describe('Cursor value. Base64 encoded timestamp and item id.'),
-});
-
-export const bulkGetTypedNotificationsByEventItemIdsBody = zod
- .object({
- eventItemIds: zod
- .array(zod.uuid())
- .describe('The event item IDs to filter notifications by.'),
- })
- .describe('Request body for bulk-fetching notifications by event item IDs.');
-
-export const bulkGetTypedNotificationsByEventItemIdsResponseItemsItemNotificationMetadataContentNumberMin = 0;
-
-export const bulkGetTypedNotificationsByEventItemIdsResponse = zod
- .object({
- items: zod
- .array(
- zod
- .object({
- entity_id: zod.string().describe('The id of that entity'),
- entity_type: zod
- .enum([
- 'user',
- 'chat',
- 'channel',
- 'document',
- 'project',
- 'email_thread',
- 'team',
- 'call',
- 'foreign_entity',
- 'static_file',
- 'crm_company',
- 'crm_contact',
- ])
- .describe('The type of an entity in Macro'),
- })
- .describe(
- 'The 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'
- )
- .and(
- zod.object({
- created_at: zod.iso
- .datetime({})
- .describe('When the notification was created.'),
- deleted_at: zod.iso
- .datetime({})
- .nullish()
- .describe('When the notification was deleted.'),
- done: zod
- .boolean()
- .describe('Whether the notification is marked as done.'),
- id: zod.uuid().describe('The notification ID.'),
- notification_event_type: zod
- .string()
- .describe(
- 'The notification event type string (e.g. \"channel_mention\").\nTODO make this a new type'
- ),
- notification_metadata: zod
- .union([
- zod
- .object({
- content: zod
- .object({
- channelName: zod.string().optional(),
- channelType: zod.enum([
- 'public',
- 'private',
- 'directMessage',
- 'team',
- ]),
- })
- .describe(
- 'Common metadata for notifications on channels'
+ 'Fields 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.'
)
.and(
zod.object({
- messageContent: zod
- .string()
- .describe('The message content'),
- messageId: zod
- .string()
- .describe('The message you were mentioned in'),
- senderDisplayName: zod
- .string()
- .nullish()
+ action: zod
+ .enum(['opened', 'reopened', 'closed'])
.describe(
- 'Display name for non-user senders such as bots'
+ 'The GitHub pull request webhook action that triggered the notification.'
),
- senderProfilePictureUrl: zod.string().nullish(),
- threadId: zod
- .string()
- .nullish()
- .describe('the id of the thread'),
- })
- ),
- tag: zod.enum(['channel_mention']),
- })
- .describe('Someone mentioned you in a channel.'),
- zod
- .object({
- content: zod
- .object({
- channelName: zod.string().optional(),
- channelType: zod.enum([
- 'public',
- 'private',
- 'directMessage',
- 'team',
- ]),
- })
- .describe(
- 'Common metadata for notifications on channels'
- )
- .and(
- zod.object({
- messageContent: zod
- .string()
- .describe('The message content'),
- messageId: zod
- .string()
- .describe('The message you were mentioned in'),
- senderDisplayName: zod
+ baseBranch: zod
.string()
.nullish()
.describe(
- 'Display name for non-user senders such as bots'
+ 'The pull request base branch, when available.'
),
- senderProfilePictureUrl: zod.string().nullish(),
- threadId: zod
+ headBranch: zod
.string()
.nullish()
- .describe('the id of the thread'),
- })
- )
- .and(
- zod.object({
- documentName: zod
- .string()
- .describe('The name of the document'),
- fileType: zod
- .string()
+ .describe(
+ 'The pull request head branch, when available.'
+ ),
+ mergedAt: zod.iso
+ .datetime({})
.nullish()
- .describe('The file type of the document'),
- owner: zod
- .string()
- .describe('The owner of the document'),
- subType: zod
+ .describe(
+ 'When the pull request was merged, when available.'
+ ),
+ previousStatus: zod
.union([
zod.null(),
zod
- .union([
- zod.object({
- type: zod.enum(['task']),
- }),
- zod.object({
- type: zod.enum(['snippet']),
- }),
- ])
+ .enum(['open', 'closed', 'merged'])
.describe(
- 'The sub type of a document in a notification.\nSerializes as `{ \"type\": \"task\" }` matching the storage service pattern.'
+ 'The normalized lifecycle status for a GitHub pull request notification.'
),
])
.optional(),
+ status: zod
+ .enum(['open', 'closed', 'merged'])
+ .describe(
+ 'The normalized lifecycle status for a GitHub pull request notification.'
+ ),
})
)
- .describe('Someone mentioned a document in a channel'),
- tag: zod.enum(['document_mention']),
+ .describe(
+ 'Metadata for a GitHub pull request lifecycle notification.'
+ ),
+ tag: zod.enum(['github_pr_status_changed']),
})
- .describe('Someone mentioned a document in a channel.'),
+ .describe(
+ 'A GitHub pull request changed lifecycle state.\n\nThe `github_pr_event` alias keeps rows and queue messages persisted\nbefore the rename deserializable.'
+ ),
zod
.object({
content: zod
.object({
- commentId: zod.number().describe('the comment id'),
- documentName: zod
+ displayName: zod
.string()
- .describe('The name of the document.'),
- fileType: zod
+ .describe(
+ 'A compact label suitable for display in the UI.'
+ ),
+ foreignEntityId: zod
+ .uuid()
+ .describe(
+ 'The source-specific internal foreign entity row id for this pull request.'
+ ),
+ githubKey: zod
.string()
- .nullish()
- .describe('The file type of the document.'),
- mentionId: zod.string().describe('The mention ID.'),
+ .describe(
+ 'The external GitHub key, in `owner\/repo\/pull\/number` format.'
+ ),
+ number: zod
+ .number()
+ .min(
+ listTypedNotificationsResponseItemsItemNotificationMetadataContentNumberMinOne
+ )
+ .describe('The GitHub pull request number.'),
+ owner: zod
+ .string()
+ .describe(
+ 'The GitHub repository owner or organization.'
+ ),
+ repo: zod
+ .string()
+ .describe('The GitHub repository name.'),
+ senderGithubAvatarUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub avatar URL for the sender, when available.'
+ ),
+ senderGithubLogin: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub login for the sender, when available.'
+ ),
+ senderGithubUserId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The stable GitHub numeric user id for the sender, serialized as a string.'
+ ),
+ title: zod
+ .string()
+ .describe(
+ 'The GitHub pull request title. Falls back to `display_name` when GitHub has no title.'
+ ),
+ url: zod
+ .string()
+ .describe(
+ 'The public GitHub URL for the pull request.'
+ ),
+ })
+ .describe(
+ 'Fields 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.'
+ )
+ .and(
+ zod.object({
+ requestedReviewerGithubLogin: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub login of the requested reviewer, when available.'
+ ),
+ requestedReviewerGithubUserId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The stable GitHub numeric user id of the requested reviewer, serialized as a string.'
+ ),
+ })
+ )
+ .describe(
+ "Metadata for a notification that the user's review was requested on a GitHub pull request."
+ ),
+ tag: zod.enum(['github_review_requested']),
+ })
+ .describe(
+ "The user's review was requested on a GitHub pull request."
+ ),
+ zod
+ .object({
+ content: zod
+ .object({
+ displayName: zod
+ .string()
+ .describe(
+ 'A compact label suitable for display in the UI.'
+ ),
+ foreignEntityId: zod
+ .uuid()
+ .describe(
+ 'The source-specific internal foreign entity row id for this pull request.'
+ ),
+ githubKey: zod
+ .string()
+ .describe(
+ 'The external GitHub key, in `owner\/repo\/pull\/number` format.'
+ ),
+ number: zod
+ .number()
+ .min(
+ listTypedNotificationsResponseItemsItemNotificationMetadataContentNumberMinTwo
+ )
+ .describe('The GitHub pull request number.'),
+ owner: zod
+ .string()
+ .describe(
+ 'The GitHub repository owner or organization.'
+ ),
+ repo: zod
+ .string()
+ .describe('The GitHub repository name.'),
+ senderGithubAvatarUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub avatar URL for the sender, when available.'
+ ),
+ senderGithubLogin: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub login for the sender, when available.'
+ ),
+ senderGithubUserId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The stable GitHub numeric user id for the sender, serialized as a string.'
+ ),
+ title: zod
+ .string()
+ .describe(
+ 'The GitHub pull request title. Falls back to `display_name` when GitHub has no title.'
+ ),
+ url: zod
+ .string()
+ .describe(
+ 'The public GitHub URL for the pull request.'
+ ),
+ })
+ .describe(
+ 'Fields 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.'
+ )
+ .and(
+ zod.object({
+ commentGithubId: zod
+ .number()
+ .min(
+ listTypedNotificationsResponseItemsItemNotificationMetadataContentCommentGithubIdMin
+ )
+ .nullish()
+ .describe(
+ 'The GitHub numeric id of the comment, when available.'
+ ),
+ commentKind: zod
+ .enum(['issue', 'review_comment'])
+ .describe(
+ 'The kind of GitHub comment that triggered a [`GithubPrComment`] notification.'
+ ),
+ commentSnippet: zod
+ .string()
+ .describe(
+ 'A truncated excerpt of the comment body.'
+ ),
+ commentUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The public GitHub URL for the comment, when available.'
+ ),
+ })
+ )
+ .describe(
+ 'Metadata for a notification that a GitHub pull request was commented on.'
+ ),
+ tag: zod.enum(['github_pr_comment']),
+ })
+ .describe('A GitHub pull request was commented on.'),
+ zod
+ .object({
+ content: zod
+ .object({
+ displayName: zod
+ .string()
+ .describe(
+ 'A compact label suitable for display in the UI.'
+ ),
+ foreignEntityId: zod
+ .uuid()
+ .describe(
+ 'The source-specific internal foreign entity row id for this pull request.'
+ ),
+ githubKey: zod
+ .string()
+ .describe(
+ 'The external GitHub key, in `owner\/repo\/pull\/number` format.'
+ ),
+ number: zod
+ .number()
+ .min(
+ listTypedNotificationsResponseItemsItemNotificationMetadataContentNumberMinThree
+ )
+ .describe('The GitHub pull request number.'),
+ owner: zod
+ .string()
+ .describe(
+ 'The GitHub repository owner or organization.'
+ ),
+ repo: zod
+ .string()
+ .describe('The GitHub repository name.'),
+ senderGithubAvatarUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub avatar URL for the sender, when available.'
+ ),
+ senderGithubLogin: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub login for the sender, when available.'
+ ),
+ senderGithubUserId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The stable GitHub numeric user id for the sender, serialized as a string.'
+ ),
+ title: zod
+ .string()
+ .describe(
+ 'The GitHub pull request title. Falls back to `display_name` when GitHub has no title.'
+ ),
+ url: zod
+ .string()
+ .describe(
+ 'The public GitHub URL for the pull request.'
+ ),
+ })
+ .describe(
+ 'Fields 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.'
+ )
+ .and(
+ zod.object({
+ commentGithubId: zod
+ .number()
+ .min(
+ listTypedNotificationsResponseItemsItemNotificationMetadataContentCommentGithubIdMinOne
+ )
+ .nullish()
+ .describe(
+ 'The GitHub numeric id of the comment or review containing the mention, when available.'
+ ),
+ commentUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The public GitHub URL for the text containing the mention, when available.'
+ ),
+ location: zod
+ .enum([
+ 'pr_body',
+ 'comment',
+ 'review',
+ 'review_comment',
+ ])
+ .describe(
+ 'Where in a GitHub pull request the user was mentioned.'
+ ),
+ textSnippet: zod
+ .string()
+ .describe(
+ 'A truncated excerpt of the text containing the mention.'
+ ),
+ })
+ )
+ .describe(
+ 'Metadata for a notification that the user was mentioned on a GitHub pull request.'
+ ),
+ tag: zod.enum(['github_pr_mention']),
+ })
+ .describe(
+ 'The user was mentioned on a GitHub pull request.'
+ ),
+ zod
+ .object({
+ content: zod
+ .object({
+ displayName: zod
+ .string()
+ .describe(
+ 'A compact label suitable for display in the UI.'
+ ),
+ foreignEntityId: zod
+ .uuid()
+ .describe(
+ 'The source-specific internal foreign entity row id for this pull request.'
+ ),
+ githubKey: zod
+ .string()
+ .describe(
+ 'The external GitHub key, in `owner\/repo\/pull\/number` format.'
+ ),
+ number: zod
+ .number()
+ .min(
+ listTypedNotificationsResponseItemsItemNotificationMetadataContentNumberMinFour
+ )
+ .describe('The GitHub pull request number.'),
+ owner: zod
+ .string()
+ .describe(
+ 'The GitHub repository owner or organization.'
+ ),
+ repo: zod
+ .string()
+ .describe('The GitHub repository name.'),
+ senderGithubAvatarUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub avatar URL for the sender, when available.'
+ ),
+ senderGithubLogin: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub login for the sender, when available.'
+ ),
+ senderGithubUserId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The stable GitHub numeric user id for the sender, serialized as a string.'
+ ),
+ title: zod
+ .string()
+ .describe(
+ 'The GitHub pull request title. Falls back to `display_name` when GitHub has no title.'
+ ),
+ url: zod
+ .string()
+ .describe(
+ 'The public GitHub URL for the pull request.'
+ ),
+ })
+ .describe(
+ 'Fields 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.'
+ )
+ .and(
+ zod.object({
+ reviewGithubId: zod
+ .number()
+ .min(
+ listTypedNotificationsResponseItemsItemNotificationMetadataContentReviewGithubIdMin
+ )
+ .nullish()
+ .describe(
+ 'The GitHub numeric id of the review, when available.'
+ ),
+ reviewSnippet: zod
+ .string()
+ .nullish()
+ .describe(
+ 'A truncated excerpt of the review body, when any was written.'
+ ),
+ reviewUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The public GitHub URL for the review, when available.'
+ ),
+ state: zod
+ .enum([
+ 'approved',
+ 'changes_requested',
+ 'commented',
+ ])
+ .describe(
+ 'The state of a submitted GitHub pull request review.'
+ ),
+ })
+ )
+ .describe(
+ "Metadata for a notification that a review was submitted on the user's GitHub pull request."
+ ),
+ tag: zod.enum(['github_pr_review']),
+ })
+ .describe(
+ "A review was submitted on the user's GitHub pull request."
+ ),
+ ])
+ .describe(
+ 'Mirrors [`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.'
+ ),
+ owner_id: zod
+ .string()
+ .describe('The user who owns this notification.'),
+ sender_id: zod
+ .string()
+ .nullish()
+ .describe('The user who triggered the notification.'),
+ sent: zod
+ .boolean()
+ .describe('Whether the notification has been sent.'),
+ updated_at: zod.iso
+ .datetime({})
+ .describe('When the notification was last updated.'),
+ viewed_at: zod.iso
+ .datetime({})
+ .nullish()
+ .describe('When the notification was viewed\/seen.'),
+ })
+ )
+ )
+ .describe('The list of items returned.'),
+ next_cursor: zod
+ .string()
+ .nullish()
+ .describe('The next page cursor if it exists.'),
+ })
+ .describe('The strongly typed response for listing user notifications.');
+
+/**
+ * Rows that fail to deserialize are dropped with a warning log.
+ * @summary Wrapper handler that calls the inner generic bulk-get handler with `serde_json::Value`,
+then converts each row to [`UserNotificationRow<NotifEvent>`].
+ */
+export const bulkGetTypedNotificationsByEventItemIdsQueryLimitMin = 0;
+
+export const bulkGetTypedNotificationsByEventItemIdsQueryParams = zod.object({
+ limit: zod
+ .number()
+ .min(bulkGetTypedNotificationsByEventItemIdsQueryLimitMin)
+ .optional()
+ .describe('Size limit per page. Default 20, max 500.'),
+ cursor: zod
+ .string()
+ .optional()
+ .describe('Cursor value. Base64 encoded timestamp and item id.'),
+});
+
+export const bulkGetTypedNotificationsByEventItemIdsBody = zod
+ .object({
+ eventItemIds: zod
+ .array(zod.uuid())
+ .describe('The event item IDs to filter notifications by.'),
+ })
+ .describe('Request body for bulk-fetching notifications by event item IDs.');
+
+export const bulkGetTypedNotificationsByEventItemIdsResponseItemsItemNotificationMetadataContentNumberMin = 0;
+
+export const bulkGetTypedNotificationsByEventItemIdsResponseItemsItemNotificationMetadataContentNumberMinOne = 0;
+
+export const bulkGetTypedNotificationsByEventItemIdsResponseItemsItemNotificationMetadataContentNumberMinTwo = 0;
+
+export const bulkGetTypedNotificationsByEventItemIdsResponseItemsItemNotificationMetadataContentCommentGithubIdMin = 0;
+
+export const bulkGetTypedNotificationsByEventItemIdsResponseItemsItemNotificationMetadataContentNumberMinThree = 0;
+
+export const bulkGetTypedNotificationsByEventItemIdsResponseItemsItemNotificationMetadataContentCommentGithubIdMinOne = 0;
+
+export const bulkGetTypedNotificationsByEventItemIdsResponseItemsItemNotificationMetadataContentNumberMinFour = 0;
+
+export const bulkGetTypedNotificationsByEventItemIdsResponseItemsItemNotificationMetadataContentReviewGithubIdMin = 0;
+
+export const bulkGetTypedNotificationsByEventItemIdsResponse = zod
+ .object({
+ items: zod
+ .array(
+ zod
+ .object({
+ entity_id: zod.string().describe('The id of that entity'),
+ entity_type: zod
+ .enum([
+ 'user',
+ 'chat',
+ 'channel',
+ 'document',
+ 'project',
+ 'email_thread',
+ 'team',
+ 'call',
+ 'foreign_entity',
+ 'static_file',
+ 'crm_company',
+ 'crm_contact',
+ ])
+ .describe('The type of an entity in Macro'),
+ })
+ .describe(
+ 'The 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'
+ )
+ .and(
+ zod.object({
+ created_at: zod.iso
+ .datetime({})
+ .describe('When the notification was created.'),
+ deleted_at: zod.iso
+ .datetime({})
+ .nullish()
+ .describe('When the notification was deleted.'),
+ done: zod
+ .boolean()
+ .describe('Whether the notification is marked as done.'),
+ id: zod.uuid().describe('The notification ID.'),
+ notification_event_type: zod
+ .string()
+ .describe(
+ 'The notification event type string (e.g. \"channel_mention\").\nTODO make this a new type'
+ ),
+ notification_metadata: zod
+ .union([
+ zod
+ .object({
+ content: zod
+ .object({
+ channelName: zod.string().optional(),
+ channelType: zod.enum([
+ 'public',
+ 'private',
+ 'directMessage',
+ 'team',
+ ]),
+ })
+ .describe(
+ 'Common metadata for notifications on channels'
+ )
+ .and(
+ zod.object({
+ messageContent: zod
+ .string()
+ .describe('The message content'),
+ messageId: zod
+ .string()
+ .describe('The message you were mentioned in'),
+ senderDisplayName: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Display name for non-user senders such as bots'
+ ),
+ senderProfilePictureUrl: zod.string().nullish(),
+ threadId: zod
+ .string()
+ .nullish()
+ .describe('the id of the thread'),
+ })
+ ),
+ tag: zod.enum(['channel_mention']),
+ })
+ .describe('Someone mentioned you in a channel.'),
+ zod
+ .object({
+ content: zod
+ .object({
+ channelName: zod.string().optional(),
+ channelType: zod.enum([
+ 'public',
+ 'private',
+ 'directMessage',
+ 'team',
+ ]),
+ })
+ .describe(
+ 'Common metadata for notifications on channels'
+ )
+ .and(
+ zod.object({
+ messageContent: zod
+ .string()
+ .describe('The message content'),
+ messageId: zod
+ .string()
+ .describe('The message you were mentioned in'),
+ senderDisplayName: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Display name for non-user senders such as bots'
+ ),
+ senderProfilePictureUrl: zod.string().nullish(),
+ threadId: zod
+ .string()
+ .nullish()
+ .describe('the id of the thread'),
+ })
+ )
+ .and(
+ zod.object({
+ documentName: zod
+ .string()
+ .describe('The name of the document'),
+ fileType: zod
+ .string()
+ .nullish()
+ .describe('The file type of the document'),
+ owner: zod
+ .string()
+ .describe('The owner of the document'),
+ subType: zod
+ .union([
+ zod.null(),
+ zod
+ .union([
+ zod.object({
+ type: zod.enum(['task']),
+ }),
+ zod.object({
+ type: zod.enum(['snippet']),
+ }),
+ ])
+ .describe(
+ 'The sub type of a document in a notification.\nSerializes as `{ \"type\": \"task\" }` matching the storage service pattern.'
+ ),
+ ])
+ .optional(),
+ })
+ )
+ .describe('Someone mentioned a document in a channel'),
+ tag: zod.enum(['document_mention']),
+ })
+ .describe('Someone mentioned a document in a channel.'),
+ zod
+ .object({
+ content: zod
+ .object({
+ commentId: zod.number().describe('the comment id'),
+ documentName: zod
+ .string()
+ .describe('The name of the document.'),
+ fileType: zod
+ .string()
+ .nullish()
+ .describe('The file type of the document.'),
+ mentionId: zod.string().describe('The mention ID.'),
owner: zod
.string()
.describe('The owner of the document.'),
@@ -980,68 +1420,275 @@ export const bulkGetTypedNotificationsByEventItemIdsResponse = zod
),
tag: zod.enum(['mentioned_in_document_comment']),
})
- .describe('User was mentioned in a comment in a document'),
+ .describe('User was mentioned in a comment in a document'),
+ zod
+ .object({
+ content: zod
+ .object({
+ commentId: zod.number().describe('the comment id'),
+ documentName: zod
+ .string()
+ .describe('The name of the document.'),
+ fileType: zod
+ .string()
+ .nullish()
+ .describe('The file type of the document.'),
+ owner: zod
+ .string()
+ .describe('The owner of the document.'),
+ senderProfilePictureUrl: zod.string().nullish(),
+ subType: zod
+ .union([
+ zod.null(),
+ zod
+ .union([
+ zod.object({
+ type: zod.enum(['task']),
+ }),
+ zod.object({
+ type: zod.enum(['snippet']),
+ }),
+ ])
+ .describe(
+ 'The sub type of a document in a notification.\nSerializes as `{ \"type\": \"task\" }` matching the storage service pattern.'
+ ),
+ ])
+ .optional(),
+ text: zod
+ .string()
+ .describe('the text of the comment'),
+ threadId: zod.number().describe('the thread id'),
+ })
+ .describe(
+ 'Notification sent when someone replies to a document comment thread.'
+ ),
+ tag: zod.enum(['replied_to_document_comment_thread']),
+ })
+ .describe(
+ 'Someone replied to a document comment thread the user participated in.'
+ ),
+ zod
+ .object({
+ content: zod
+ .object({
+ commentId: zod.number().describe('the comment id'),
+ documentName: zod
+ .string()
+ .describe('The name of the document.'),
+ fileType: zod
+ .string()
+ .nullish()
+ .describe('The file type of the document.'),
+ owner: zod
+ .string()
+ .describe('The owner of the document.'),
+ senderProfilePictureUrl: zod.string().nullish(),
+ subType: zod
+ .union([
+ zod.null(),
+ zod
+ .union([
+ zod.object({
+ type: zod.enum(['task']),
+ }),
+ zod.object({
+ type: zod.enum(['snippet']),
+ }),
+ ])
+ .describe(
+ 'The sub type of a document in a notification.\nSerializes as `{ \"type\": \"task\" }` matching the storage service pattern.'
+ ),
+ ])
+ .optional(),
+ text: zod
+ .string()
+ .describe('the text of the comment'),
+ threadId: zod.number().describe('the thread id'),
+ })
+ .describe(
+ 'Notification sent when someone comments on a document the user owns.'
+ ),
+ tag: zod.enum(['commented_on_document']),
+ })
+ .describe('Someone commented on a document the user owns.'),
+ zod
+ .object({
+ content: zod
+ .object({
+ channelName: zod
+ .string()
+ .optional()
+ .describe('The name of the channel'),
+ invitedBy: zod
+ .string()
+ .describe('The user who sent the invitation'),
+ messageContent: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Message content to show in the invite email, when the invite was triggered by a message.'
+ ),
+ senderProfilePictureUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ "The sender's profile picture URL, if available."
+ ),
+ })
+ .describe(
+ 'Metadata for when a user is invited to a channel.'
+ ),
+ tag: zod.enum(['channel_invite']),
+ })
+ .describe('The user was invited to a channel.'),
+ zod
+ .object({
+ content: zod
+ .object({
+ channelName: zod.string().optional(),
+ channelType: zod.enum([
+ 'public',
+ 'private',
+ 'directMessage',
+ 'team',
+ ]),
+ })
+ .describe(
+ 'Common metadata for notifications on channels'
+ )
+ .and(
+ zod.object({
+ messageContent: zod
+ .string()
+ .optional()
+ .describe('The content of the message'),
+ messageId: zod.string().describe('The message id'),
+ sender: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The user who sent the message, when sent by a user'
+ ),
+ senderDisplayName: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Display name for non-user senders such as bots'
+ ),
+ senderProfilePictureUrl: zod.string().nullish(),
+ })
+ ),
+ tag: zod.enum(['channel_message_send']),
+ })
+ .describe('A user sent a message in a channel.'),
+ zod
+ .object({
+ content: zod
+ .object({
+ channelName: zod.string().optional(),
+ channelType: zod.enum([
+ 'public',
+ 'private',
+ 'directMessage',
+ 'team',
+ ]),
+ })
+ .describe(
+ 'Common metadata for notifications on channels'
+ )
+ .and(
+ zod.object({
+ messageContent: zod
+ .string()
+ .describe('The message content'),
+ messageId: zod
+ .string()
+ .describe('The id of the new message'),
+ senderDisplayName: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Display name for non-user senders such as bots'
+ ),
+ senderProfilePictureUrl: zod.string().nullish(),
+ threadId: zod
+ .string()
+ .describe(
+ 'The id of the thread that has the reply'
+ ),
+ threadParentSenderId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The user who sent the root message of the thread'
+ ),
+ userId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The sender id of the reply, when sent by a user'
+ ),
+ })
+ ),
+ tag: zod.enum(['channel_message_reply']),
+ })
+ .describe(
+ 'Someone replied to a thread in a channel that the user is part of.'
+ ),
+ zod
+ .object({
+ content: zod.object({
+ sender: zod.string().nullish(),
+ snippet: zod.string(),
+ subject: zod.string(),
+ threadId: zod.string(),
+ toEmail: zod.string(),
+ }),
+ tag: zod.enum(['new_email']),
+ })
+ .describe('A new email has been sent to the user.'),
zod
.object({
content: zod
.object({
- commentId: zod.number().describe('the comment id'),
- documentName: zod
+ invitedBy: zod
.string()
- .describe('The name of the document.'),
- fileType: zod
+ .describe('The user who sent the invitation'),
+ role: zod
.string()
.nullish()
- .describe('The file type of the document.'),
- owner: zod
+ .describe('Role\/permission level in the team'),
+ senderProfilePictureUrl: zod
.string()
- .describe('The owner of the document.'),
- senderProfilePictureUrl: zod.string().nullish(),
- subType: zod
- .union([
- zod.null(),
- zod
- .union([
- zod.object({
- type: zod.enum(['task']),
- }),
- zod.object({
- type: zod.enum(['snippet']),
- }),
- ])
- .describe(
- 'The sub type of a document in a notification.\nSerializes as `{ \"type\": \"task\" }` matching the storage service pattern.'
- ),
- ])
- .optional(),
- text: zod
+ .nullish()
+ .describe(
+ "The sender's profile picture URL, if available."
+ ),
+ teamId: zod
+ .uuid()
+ .describe('The unique identifier of the team'),
+ teamInviteId: zod
+ .uuid()
+ .describe(
+ 'The unique identifier of the team invite'
+ ),
+ teamName: zod
.string()
- .describe('the text of the comment'),
- threadId: zod.number().describe('the thread id'),
+ .describe('The name of the team being invited to'),
})
.describe(
- 'Notification sent when someone replies to a document comment thread.'
+ 'Metadata for when a user is invited to a team.'
),
- tag: zod.enum(['replied_to_document_comment_thread']),
+ tag: zod.enum(['invite_to_team']),
})
- .describe(
- 'Someone replied to a document comment thread the user participated in.'
- ),
+ .describe('A user was invited to a team.'),
zod
.object({
content: zod
.object({
- commentId: zod.number().describe('the comment id'),
- documentName: zod
- .string()
- .describe('The name of the document.'),
- fileType: zod
- .string()
- .nullish()
- .describe('The file type of the document.'),
- owner: zod
+ assignedBy: zod
.string()
- .describe('The owner of the document.'),
+ .describe('The user who assigned the task'),
senderProfilePictureUrl: zod.string().nullish(),
subType: zod
.union([
@@ -1060,251 +1707,444 @@ export const bulkGetTypedNotificationsByEventItemIdsResponse = zod
),
])
.optional(),
- text: zod
+ taskId: zod
.string()
- .describe('the text of the comment'),
- threadId: zod.number().describe('the thread id'),
+ .describe('The unique identifier of the task'),
+ taskName: zod
+ .string()
+ .nullish()
+ .describe('The name of the task (optional)'),
})
.describe(
- 'Notification sent when someone comments on a document the user owns.'
+ 'Metadata for when a user is assigned to a task'
),
- tag: zod.enum(['commented_on_document']),
+ tag: zod.enum(['task_assigned']),
})
- .describe('Someone commented on a document the user owns.'),
+ .describe('A user was assigned to a task.'),
+ zod
+ .object({
+ content: zod.object({
+ messageId: zod.string(),
+ summary: zod.string(),
+ }),
+ tag: zod.enum(['ai_response']),
+ })
+ .describe('An AI assistant responded to a chat.'),
zod
.object({
content: zod
.object({
- channelName: zod
+ displayName: zod
.string()
- .optional()
- .describe('The name of the channel'),
- invitedBy: zod
+ .describe(
+ 'A compact label suitable for display in the UI.'
+ ),
+ foreignEntityId: zod
+ .uuid()
+ .describe(
+ 'The source-specific internal foreign entity row id for this pull request.'
+ ),
+ githubKey: zod
.string()
- .describe('The user who sent the invitation'),
- messageContent: zod
+ .describe(
+ 'The external GitHub key, in `owner\/repo\/pull\/number` format.'
+ ),
+ number: zod
+ .number()
+ .min(
+ bulkGetTypedNotificationsByEventItemIdsResponseItemsItemNotificationMetadataContentNumberMin
+ )
+ .describe('The GitHub pull request number.'),
+ owner: zod
+ .string()
+ .describe(
+ 'The GitHub repository owner or organization.'
+ ),
+ repo: zod
+ .string()
+ .describe('The GitHub repository name.'),
+ senderGithubAvatarUrl: zod
.string()
.nullish()
.describe(
- 'Message content to show in the invite email, when the invite was triggered by a message.'
+ 'The GitHub avatar URL for the sender, when available.'
),
- senderProfilePictureUrl: zod
+ senderGithubLogin: zod
.string()
.nullish()
.describe(
- "The sender's profile picture URL, if available."
+ 'The GitHub login for the sender, when available.'
+ ),
+ senderGithubUserId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The stable GitHub numeric user id for the sender, serialized as a string.'
+ ),
+ title: zod
+ .string()
+ .describe(
+ 'The GitHub pull request title. Falls back to `display_name` when GitHub has no title.'
+ ),
+ url: zod
+ .string()
+ .describe(
+ 'The public GitHub URL for the pull request.'
),
})
.describe(
- 'Metadata for when a user is invited to a channel.'
+ 'Fields 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.'
+ )
+ .and(
+ zod.object({
+ action: zod
+ .enum(['opened', 'reopened', 'closed'])
+ .describe(
+ 'The GitHub pull request webhook action that triggered the notification.'
+ ),
+ baseBranch: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The pull request base branch, when available.'
+ ),
+ headBranch: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The pull request head branch, when available.'
+ ),
+ mergedAt: zod.iso
+ .datetime({})
+ .nullish()
+ .describe(
+ 'When the pull request was merged, when available.'
+ ),
+ previousStatus: zod
+ .union([
+ zod.null(),
+ zod
+ .enum(['open', 'closed', 'merged'])
+ .describe(
+ 'The normalized lifecycle status for a GitHub pull request notification.'
+ ),
+ ])
+ .optional(),
+ status: zod
+ .enum(['open', 'closed', 'merged'])
+ .describe(
+ 'The normalized lifecycle status for a GitHub pull request notification.'
+ ),
+ })
+ )
+ .describe(
+ 'Metadata for a GitHub pull request lifecycle notification.'
),
- tag: zod.enum(['channel_invite']),
+ tag: zod.enum(['github_pr_status_changed']),
})
- .describe('The user was invited to a channel.'),
+ .describe(
+ 'A GitHub pull request changed lifecycle state.\n\nThe `github_pr_event` alias keeps rows and queue messages persisted\nbefore the rename deserializable.'
+ ),
zod
.object({
content: zod
.object({
- channelName: zod.string().optional(),
- channelType: zod.enum([
- 'public',
- 'private',
- 'directMessage',
- 'team',
- ]),
+ displayName: zod
+ .string()
+ .describe(
+ 'A compact label suitable for display in the UI.'
+ ),
+ foreignEntityId: zod
+ .uuid()
+ .describe(
+ 'The source-specific internal foreign entity row id for this pull request.'
+ ),
+ githubKey: zod
+ .string()
+ .describe(
+ 'The external GitHub key, in `owner\/repo\/pull\/number` format.'
+ ),
+ number: zod
+ .number()
+ .min(
+ bulkGetTypedNotificationsByEventItemIdsResponseItemsItemNotificationMetadataContentNumberMinOne
+ )
+ .describe('The GitHub pull request number.'),
+ owner: zod
+ .string()
+ .describe(
+ 'The GitHub repository owner or organization.'
+ ),
+ repo: zod
+ .string()
+ .describe('The GitHub repository name.'),
+ senderGithubAvatarUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub avatar URL for the sender, when available.'
+ ),
+ senderGithubLogin: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub login for the sender, when available.'
+ ),
+ senderGithubUserId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The stable GitHub numeric user id for the sender, serialized as a string.'
+ ),
+ title: zod
+ .string()
+ .describe(
+ 'The GitHub pull request title. Falls back to `display_name` when GitHub has no title.'
+ ),
+ url: zod
+ .string()
+ .describe(
+ 'The public GitHub URL for the pull request.'
+ ),
})
.describe(
- 'Common metadata for notifications on channels'
+ 'Fields 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.'
)
- .and(
- zod.object({
- messageContent: zod
- .string()
- .optional()
- .describe('The content of the message'),
- messageId: zod.string().describe('The message id'),
- sender: zod
+ .and(
+ zod.object({
+ requestedReviewerGithubLogin: zod
.string()
.nullish()
.describe(
- 'The user who sent the message, when sent by a user'
+ 'The GitHub login of the requested reviewer, when available.'
),
- senderDisplayName: zod
+ requestedReviewerGithubUserId: zod
.string()
.nullish()
.describe(
- 'Display name for non-user senders such as bots'
+ 'The stable GitHub numeric user id of the requested reviewer, serialized as a string.'
),
- senderProfilePictureUrl: zod.string().nullish(),
})
+ )
+ .describe(
+ "Metadata for a notification that the user's review was requested on a GitHub pull request."
),
- tag: zod.enum(['channel_message_send']),
+ tag: zod.enum(['github_review_requested']),
})
- .describe('A user sent a message in a channel.'),
+ .describe(
+ "The user's review was requested on a GitHub pull request."
+ ),
zod
.object({
content: zod
.object({
- channelName: zod.string().optional(),
- channelType: zod.enum([
- 'public',
- 'private',
- 'directMessage',
- 'team',
- ]),
+ displayName: zod
+ .string()
+ .describe(
+ 'A compact label suitable for display in the UI.'
+ ),
+ foreignEntityId: zod
+ .uuid()
+ .describe(
+ 'The source-specific internal foreign entity row id for this pull request.'
+ ),
+ githubKey: zod
+ .string()
+ .describe(
+ 'The external GitHub key, in `owner\/repo\/pull\/number` format.'
+ ),
+ number: zod
+ .number()
+ .min(
+ bulkGetTypedNotificationsByEventItemIdsResponseItemsItemNotificationMetadataContentNumberMinTwo
+ )
+ .describe('The GitHub pull request number.'),
+ owner: zod
+ .string()
+ .describe(
+ 'The GitHub repository owner or organization.'
+ ),
+ repo: zod
+ .string()
+ .describe('The GitHub repository name.'),
+ senderGithubAvatarUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub avatar URL for the sender, when available.'
+ ),
+ senderGithubLogin: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub login for the sender, when available.'
+ ),
+ senderGithubUserId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The stable GitHub numeric user id for the sender, serialized as a string.'
+ ),
+ title: zod
+ .string()
+ .describe(
+ 'The GitHub pull request title. Falls back to `display_name` when GitHub has no title.'
+ ),
+ url: zod
+ .string()
+ .describe(
+ 'The public GitHub URL for the pull request.'
+ ),
})
.describe(
- 'Common metadata for notifications on channels'
+ 'Fields 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.'
)
.and(
zod.object({
- messageContent: zod
- .string()
- .describe('The message content'),
- messageId: zod
- .string()
- .describe('The id of the new message'),
- senderDisplayName: zod
- .string()
+ commentGithubId: zod
+ .number()
+ .min(
+ bulkGetTypedNotificationsByEventItemIdsResponseItemsItemNotificationMetadataContentCommentGithubIdMin
+ )
.nullish()
.describe(
- 'Display name for non-user senders such as bots'
+ 'The GitHub numeric id of the comment, when available.'
),
- senderProfilePictureUrl: zod.string().nullish(),
- threadId: zod
- .string()
+ commentKind: zod
+ .enum(['issue', 'review_comment'])
.describe(
- 'The id of the thread that has the reply'
+ 'The kind of GitHub comment that triggered a [`GithubPrComment`] notification.'
),
- threadParentSenderId: zod
+ commentSnippet: zod
.string()
- .nullish()
.describe(
- 'The user who sent the root message of the thread'
+ 'A truncated excerpt of the comment body.'
),
- userId: zod
+ commentUrl: zod
.string()
.nullish()
.describe(
- 'The sender id of the reply, when sent by a user'
+ 'The public GitHub URL for the comment, when available.'
),
})
+ )
+ .describe(
+ 'Metadata for a notification that a GitHub pull request was commented on.'
),
- tag: zod.enum(['channel_message_reply']),
- })
- .describe(
- 'Someone replied to a thread in a channel that the user is part of.'
- ),
- zod
- .object({
- content: zod.object({
- sender: zod.string().nullish(),
- snippet: zod.string(),
- subject: zod.string(),
- threadId: zod.string(),
- toEmail: zod.string(),
- }),
- tag: zod.enum(['new_email']),
+ tag: zod.enum(['github_pr_comment']),
})
- .describe('A new email has been sent to the user.'),
+ .describe('A GitHub pull request was commented on.'),
zod
.object({
content: zod
.object({
- invitedBy: zod
- .string()
- .describe('The user who sent the invitation'),
- role: zod
- .string()
- .nullish()
- .describe('Role\/permission level in the team'),
- senderProfilePictureUrl: zod
+ displayName: zod
.string()
- .nullish()
.describe(
- "The sender's profile picture URL, if available."
+ 'A compact label suitable for display in the UI.'
),
- teamId: zod
- .uuid()
- .describe('The unique identifier of the team'),
- teamInviteId: zod
+ foreignEntityId: zod
.uuid()
.describe(
- 'The unique identifier of the team invite'
+ 'The source-specific internal foreign entity row id for this pull request.'
),
- teamName: zod
+ githubKey: zod
.string()
- .describe('The name of the team being invited to'),
- })
- .describe(
- 'Metadata for when a user is invited to a team.'
- ),
- tag: zod.enum(['invite_to_team']),
- })
- .describe('A user was invited to a team.'),
- zod
- .object({
- content: zod
- .object({
- assignedBy: zod
+ .describe(
+ 'The external GitHub key, in `owner\/repo\/pull\/number` format.'
+ ),
+ number: zod
+ .number()
+ .min(
+ bulkGetTypedNotificationsByEventItemIdsResponseItemsItemNotificationMetadataContentNumberMinThree
+ )
+ .describe('The GitHub pull request number.'),
+ owner: zod
.string()
- .describe('The user who assigned the task'),
- senderProfilePictureUrl: zod.string().nullish(),
- subType: zod
- .union([
- zod.null(),
- zod
- .union([
- zod.object({
- type: zod.enum(['task']),
- }),
- zod.object({
- type: zod.enum(['snippet']),
- }),
- ])
- .describe(
- 'The sub type of a document in a notification.\nSerializes as `{ \"type\": \"task\" }` matching the storage service pattern.'
- ),
- ])
- .optional(),
- taskId: zod
+ .describe(
+ 'The GitHub repository owner or organization.'
+ ),
+ repo: zod
.string()
- .describe('The unique identifier of the task'),
- taskName: zod
+ .describe('The GitHub repository name.'),
+ senderGithubAvatarUrl: zod
.string()
.nullish()
- .describe('The name of the task (optional)'),
+ .describe(
+ 'The GitHub avatar URL for the sender, when available.'
+ ),
+ senderGithubLogin: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub login for the sender, when available.'
+ ),
+ senderGithubUserId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The stable GitHub numeric user id for the sender, serialized as a string.'
+ ),
+ title: zod
+ .string()
+ .describe(
+ 'The GitHub pull request title. Falls back to `display_name` when GitHub has no title.'
+ ),
+ url: zod
+ .string()
+ .describe(
+ 'The public GitHub URL for the pull request.'
+ ),
})
.describe(
- 'Metadata for when a user is assigned to a task'
+ 'Fields 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.'
+ )
+ .and(
+ zod.object({
+ commentGithubId: zod
+ .number()
+ .min(
+ bulkGetTypedNotificationsByEventItemIdsResponseItemsItemNotificationMetadataContentCommentGithubIdMinOne
+ )
+ .nullish()
+ .describe(
+ 'The GitHub numeric id of the comment or review containing the mention, when available.'
+ ),
+ commentUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The public GitHub URL for the text containing the mention, when available.'
+ ),
+ location: zod
+ .enum([
+ 'pr_body',
+ 'comment',
+ 'review',
+ 'review_comment',
+ ])
+ .describe(
+ 'Where in a GitHub pull request the user was mentioned.'
+ ),
+ textSnippet: zod
+ .string()
+ .describe(
+ 'A truncated excerpt of the text containing the mention.'
+ ),
+ })
+ )
+ .describe(
+ 'Metadata for a notification that the user was mentioned on a GitHub pull request.'
),
- tag: zod.enum(['task_assigned']),
- })
- .describe('A user was assigned to a task.'),
- zod
- .object({
- content: zod.object({
- messageId: zod.string(),
- summary: zod.string(),
- }),
- tag: zod.enum(['ai_response']),
+ tag: zod.enum(['github_pr_mention']),
})
- .describe('An AI assistant responded to a chat.'),
+ .describe(
+ 'The user was mentioned on a GitHub pull request.'
+ ),
zod
.object({
content: zod
.object({
- action: zod
- .enum(['opened', 'reopened', 'closed'])
- .describe(
- 'The GitHub pull request webhook action that triggered the notification.'
- ),
- baseBranch: zod
- .string()
- .nullish()
- .describe(
- 'The pull request base branch, when available.'
- ),
displayName: zod
.string()
.describe(
@@ -1318,24 +2158,12 @@ export const bulkGetTypedNotificationsByEventItemIdsResponse = zod
githubKey: zod
.string()
.describe(
- 'The external GitHub key, in `owner\/repo\/pull\/number` format.'
- ),
- headBranch: zod
- .string()
- .nullish()
- .describe(
- 'The pull request head branch, when available.'
- ),
- mergedAt: zod.iso
- .datetime({})
- .nullish()
- .describe(
- 'When the pull request was merged, when available.'
+ 'The external GitHub key, in `owner\/repo\/pull\/number` format.'
),
number: zod
.number()
.min(
- bulkGetTypedNotificationsByEventItemIdsResponseItemsItemNotificationMetadataContentNumberMin
+ bulkGetTypedNotificationsByEventItemIdsResponseItemsItemNotificationMetadataContentNumberMinFour
)
.describe('The GitHub pull request number.'),
owner: zod
@@ -1343,16 +2171,6 @@ export const bulkGetTypedNotificationsByEventItemIdsResponse = zod
.describe(
'The GitHub repository owner or organization.'
),
- previousStatus: zod
- .union([
- zod.null(),
- zod
- .enum(['open', 'closed', 'merged'])
- .describe(
- 'The normalized lifecycle status for a GitHub pull request notification.'
- ),
- ])
- .optional(),
repo: zod
.string()
.describe('The GitHub repository name.'),
@@ -1374,11 +2192,6 @@ export const bulkGetTypedNotificationsByEventItemIdsResponse = zod
.describe(
'The stable GitHub numeric user id for the sender, serialized as a string.'
),
- status: zod
- .enum(['open', 'closed', 'merged'])
- .describe(
- 'The normalized lifecycle status for a GitHub pull request notification.'
- ),
title: zod
.string()
.describe(
@@ -1391,11 +2204,50 @@ export const bulkGetTypedNotificationsByEventItemIdsResponse = zod
),
})
.describe(
- 'Metadata for a GitHub pull request lifecycle notification.'
+ 'Fields 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.'
+ )
+ .and(
+ zod.object({
+ reviewGithubId: zod
+ .number()
+ .min(
+ bulkGetTypedNotificationsByEventItemIdsResponseItemsItemNotificationMetadataContentReviewGithubIdMin
+ )
+ .nullish()
+ .describe(
+ 'The GitHub numeric id of the review, when available.'
+ ),
+ reviewSnippet: zod
+ .string()
+ .nullish()
+ .describe(
+ 'A truncated excerpt of the review body, when any was written.'
+ ),
+ reviewUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The public GitHub URL for the review, when available.'
+ ),
+ state: zod
+ .enum([
+ 'approved',
+ 'changes_requested',
+ 'commented',
+ ])
+ .describe(
+ 'The state of a submitted GitHub pull request review.'
+ ),
+ })
+ )
+ .describe(
+ "Metadata for a notification that a review was submitted on the user's GitHub pull request."
),
- tag: zod.enum(['github_pr_event']),
+ tag: zod.enum(['github_pr_review']),
})
- .describe('A GitHub pull request changed lifecycle state.'),
+ .describe(
+ "A review was submitted on the user's GitHub pull request."
+ ),
])
.describe(
'Mirrors [`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.'
@@ -1451,6 +2303,20 @@ export const getTypedNotificationsByEventItemIdQueryParams = zod.object({
export const getTypedNotificationsByEventItemIdResponseItemsItemNotificationMetadataContentNumberMin = 0;
+export const getTypedNotificationsByEventItemIdResponseItemsItemNotificationMetadataContentNumberMinOne = 0;
+
+export const getTypedNotificationsByEventItemIdResponseItemsItemNotificationMetadataContentNumberMinTwo = 0;
+
+export const getTypedNotificationsByEventItemIdResponseItemsItemNotificationMetadataContentCommentGithubIdMin = 0;
+
+export const getTypedNotificationsByEventItemIdResponseItemsItemNotificationMetadataContentNumberMinThree = 0;
+
+export const getTypedNotificationsByEventItemIdResponseItemsItemNotificationMetadataContentCommentGithubIdMinOne = 0;
+
+export const getTypedNotificationsByEventItemIdResponseItemsItemNotificationMetadataContentNumberMinFour = 0;
+
+export const getTypedNotificationsByEventItemIdResponseItemsItemNotificationMetadataContentReviewGithubIdMin = 0;
+
export const getTypedNotificationsByEventItemIdResponse = zod
.object({
items: zod
@@ -1652,68 +2518,275 @@ export const getTypedNotificationsByEventItemIdResponse = zod
),
tag: zod.enum(['mentioned_in_document_comment']),
})
- .describe('User was mentioned in a comment in a document'),
+ .describe('User was mentioned in a comment in a document'),
+ zod
+ .object({
+ content: zod
+ .object({
+ commentId: zod.number().describe('the comment id'),
+ documentName: zod
+ .string()
+ .describe('The name of the document.'),
+ fileType: zod
+ .string()
+ .nullish()
+ .describe('The file type of the document.'),
+ owner: zod
+ .string()
+ .describe('The owner of the document.'),
+ senderProfilePictureUrl: zod.string().nullish(),
+ subType: zod
+ .union([
+ zod.null(),
+ zod
+ .union([
+ zod.object({
+ type: zod.enum(['task']),
+ }),
+ zod.object({
+ type: zod.enum(['snippet']),
+ }),
+ ])
+ .describe(
+ 'The sub type of a document in a notification.\nSerializes as `{ \"type\": \"task\" }` matching the storage service pattern.'
+ ),
+ ])
+ .optional(),
+ text: zod
+ .string()
+ .describe('the text of the comment'),
+ threadId: zod.number().describe('the thread id'),
+ })
+ .describe(
+ 'Notification sent when someone replies to a document comment thread.'
+ ),
+ tag: zod.enum(['replied_to_document_comment_thread']),
+ })
+ .describe(
+ 'Someone replied to a document comment thread the user participated in.'
+ ),
+ zod
+ .object({
+ content: zod
+ .object({
+ commentId: zod.number().describe('the comment id'),
+ documentName: zod
+ .string()
+ .describe('The name of the document.'),
+ fileType: zod
+ .string()
+ .nullish()
+ .describe('The file type of the document.'),
+ owner: zod
+ .string()
+ .describe('The owner of the document.'),
+ senderProfilePictureUrl: zod.string().nullish(),
+ subType: zod
+ .union([
+ zod.null(),
+ zod
+ .union([
+ zod.object({
+ type: zod.enum(['task']),
+ }),
+ zod.object({
+ type: zod.enum(['snippet']),
+ }),
+ ])
+ .describe(
+ 'The sub type of a document in a notification.\nSerializes as `{ \"type\": \"task\" }` matching the storage service pattern.'
+ ),
+ ])
+ .optional(),
+ text: zod
+ .string()
+ .describe('the text of the comment'),
+ threadId: zod.number().describe('the thread id'),
+ })
+ .describe(
+ 'Notification sent when someone comments on a document the user owns.'
+ ),
+ tag: zod.enum(['commented_on_document']),
+ })
+ .describe('Someone commented on a document the user owns.'),
+ zod
+ .object({
+ content: zod
+ .object({
+ channelName: zod
+ .string()
+ .optional()
+ .describe('The name of the channel'),
+ invitedBy: zod
+ .string()
+ .describe('The user who sent the invitation'),
+ messageContent: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Message content to show in the invite email, when the invite was triggered by a message.'
+ ),
+ senderProfilePictureUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ "The sender's profile picture URL, if available."
+ ),
+ })
+ .describe(
+ 'Metadata for when a user is invited to a channel.'
+ ),
+ tag: zod.enum(['channel_invite']),
+ })
+ .describe('The user was invited to a channel.'),
+ zod
+ .object({
+ content: zod
+ .object({
+ channelName: zod.string().optional(),
+ channelType: zod.enum([
+ 'public',
+ 'private',
+ 'directMessage',
+ 'team',
+ ]),
+ })
+ .describe(
+ 'Common metadata for notifications on channels'
+ )
+ .and(
+ zod.object({
+ messageContent: zod
+ .string()
+ .optional()
+ .describe('The content of the message'),
+ messageId: zod.string().describe('The message id'),
+ sender: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The user who sent the message, when sent by a user'
+ ),
+ senderDisplayName: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Display name for non-user senders such as bots'
+ ),
+ senderProfilePictureUrl: zod.string().nullish(),
+ })
+ ),
+ tag: zod.enum(['channel_message_send']),
+ })
+ .describe('A user sent a message in a channel.'),
+ zod
+ .object({
+ content: zod
+ .object({
+ channelName: zod.string().optional(),
+ channelType: zod.enum([
+ 'public',
+ 'private',
+ 'directMessage',
+ 'team',
+ ]),
+ })
+ .describe(
+ 'Common metadata for notifications on channels'
+ )
+ .and(
+ zod.object({
+ messageContent: zod
+ .string()
+ .describe('The message content'),
+ messageId: zod
+ .string()
+ .describe('The id of the new message'),
+ senderDisplayName: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Display name for non-user senders such as bots'
+ ),
+ senderProfilePictureUrl: zod.string().nullish(),
+ threadId: zod
+ .string()
+ .describe(
+ 'The id of the thread that has the reply'
+ ),
+ threadParentSenderId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The user who sent the root message of the thread'
+ ),
+ userId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The sender id of the reply, when sent by a user'
+ ),
+ })
+ ),
+ tag: zod.enum(['channel_message_reply']),
+ })
+ .describe(
+ 'Someone replied to a thread in a channel that the user is part of.'
+ ),
+ zod
+ .object({
+ content: zod.object({
+ sender: zod.string().nullish(),
+ snippet: zod.string(),
+ subject: zod.string(),
+ threadId: zod.string(),
+ toEmail: zod.string(),
+ }),
+ tag: zod.enum(['new_email']),
+ })
+ .describe('A new email has been sent to the user.'),
zod
.object({
content: zod
.object({
- commentId: zod.number().describe('the comment id'),
- documentName: zod
+ invitedBy: zod
.string()
- .describe('The name of the document.'),
- fileType: zod
+ .describe('The user who sent the invitation'),
+ role: zod
.string()
.nullish()
- .describe('The file type of the document.'),
- owner: zod
+ .describe('Role\/permission level in the team'),
+ senderProfilePictureUrl: zod
.string()
- .describe('The owner of the document.'),
- senderProfilePictureUrl: zod.string().nullish(),
- subType: zod
- .union([
- zod.null(),
- zod
- .union([
- zod.object({
- type: zod.enum(['task']),
- }),
- zod.object({
- type: zod.enum(['snippet']),
- }),
- ])
- .describe(
- 'The sub type of a document in a notification.\nSerializes as `{ \"type\": \"task\" }` matching the storage service pattern.'
- ),
- ])
- .optional(),
- text: zod
+ .nullish()
+ .describe(
+ "The sender's profile picture URL, if available."
+ ),
+ teamId: zod
+ .uuid()
+ .describe('The unique identifier of the team'),
+ teamInviteId: zod
+ .uuid()
+ .describe(
+ 'The unique identifier of the team invite'
+ ),
+ teamName: zod
.string()
- .describe('the text of the comment'),
- threadId: zod.number().describe('the thread id'),
+ .describe('The name of the team being invited to'),
})
.describe(
- 'Notification sent when someone replies to a document comment thread.'
+ 'Metadata for when a user is invited to a team.'
),
- tag: zod.enum(['replied_to_document_comment_thread']),
+ tag: zod.enum(['invite_to_team']),
})
- .describe(
- 'Someone replied to a document comment thread the user participated in.'
- ),
+ .describe('A user was invited to a team.'),
zod
.object({
content: zod
.object({
- commentId: zod.number().describe('the comment id'),
- documentName: zod
- .string()
- .describe('The name of the document.'),
- fileType: zod
- .string()
- .nullish()
- .describe('The file type of the document.'),
- owner: zod
+ assignedBy: zod
.string()
- .describe('The owner of the document.'),
+ .describe('The user who assigned the task'),
senderProfilePictureUrl: zod.string().nullish(),
subType: zod
.union([
@@ -1732,251 +2805,444 @@ export const getTypedNotificationsByEventItemIdResponse = zod
),
])
.optional(),
- text: zod
+ taskId: zod
.string()
- .describe('the text of the comment'),
- threadId: zod.number().describe('the thread id'),
+ .describe('The unique identifier of the task'),
+ taskName: zod
+ .string()
+ .nullish()
+ .describe('The name of the task (optional)'),
})
.describe(
- 'Notification sent when someone comments on a document the user owns.'
+ 'Metadata for when a user is assigned to a task'
),
- tag: zod.enum(['commented_on_document']),
+ tag: zod.enum(['task_assigned']),
})
- .describe('Someone commented on a document the user owns.'),
+ .describe('A user was assigned to a task.'),
+ zod
+ .object({
+ content: zod.object({
+ messageId: zod.string(),
+ summary: zod.string(),
+ }),
+ tag: zod.enum(['ai_response']),
+ })
+ .describe('An AI assistant responded to a chat.'),
zod
.object({
content: zod
.object({
- channelName: zod
+ displayName: zod
.string()
- .optional()
- .describe('The name of the channel'),
- invitedBy: zod
+ .describe(
+ 'A compact label suitable for display in the UI.'
+ ),
+ foreignEntityId: zod
+ .uuid()
+ .describe(
+ 'The source-specific internal foreign entity row id for this pull request.'
+ ),
+ githubKey: zod
.string()
- .describe('The user who sent the invitation'),
- messageContent: zod
+ .describe(
+ 'The external GitHub key, in `owner\/repo\/pull\/number` format.'
+ ),
+ number: zod
+ .number()
+ .min(
+ getTypedNotificationsByEventItemIdResponseItemsItemNotificationMetadataContentNumberMin
+ )
+ .describe('The GitHub pull request number.'),
+ owner: zod
+ .string()
+ .describe(
+ 'The GitHub repository owner or organization.'
+ ),
+ repo: zod
+ .string()
+ .describe('The GitHub repository name.'),
+ senderGithubAvatarUrl: zod
.string()
.nullish()
.describe(
- 'Message content to show in the invite email, when the invite was triggered by a message.'
+ 'The GitHub avatar URL for the sender, when available.'
),
- senderProfilePictureUrl: zod
+ senderGithubLogin: zod
.string()
.nullish()
.describe(
- "The sender's profile picture URL, if available."
+ 'The GitHub login for the sender, when available.'
+ ),
+ senderGithubUserId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The stable GitHub numeric user id for the sender, serialized as a string.'
+ ),
+ title: zod
+ .string()
+ .describe(
+ 'The GitHub pull request title. Falls back to `display_name` when GitHub has no title.'
+ ),
+ url: zod
+ .string()
+ .describe(
+ 'The public GitHub URL for the pull request.'
),
})
.describe(
- 'Metadata for when a user is invited to a channel.'
+ 'Fields 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.'
+ )
+ .and(
+ zod.object({
+ action: zod
+ .enum(['opened', 'reopened', 'closed'])
+ .describe(
+ 'The GitHub pull request webhook action that triggered the notification.'
+ ),
+ baseBranch: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The pull request base branch, when available.'
+ ),
+ headBranch: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The pull request head branch, when available.'
+ ),
+ mergedAt: zod.iso
+ .datetime({})
+ .nullish()
+ .describe(
+ 'When the pull request was merged, when available.'
+ ),
+ previousStatus: zod
+ .union([
+ zod.null(),
+ zod
+ .enum(['open', 'closed', 'merged'])
+ .describe(
+ 'The normalized lifecycle status for a GitHub pull request notification.'
+ ),
+ ])
+ .optional(),
+ status: zod
+ .enum(['open', 'closed', 'merged'])
+ .describe(
+ 'The normalized lifecycle status for a GitHub pull request notification.'
+ ),
+ })
+ )
+ .describe(
+ 'Metadata for a GitHub pull request lifecycle notification.'
),
- tag: zod.enum(['channel_invite']),
+ tag: zod.enum(['github_pr_status_changed']),
})
- .describe('The user was invited to a channel.'),
+ .describe(
+ 'A GitHub pull request changed lifecycle state.\n\nThe `github_pr_event` alias keeps rows and queue messages persisted\nbefore the rename deserializable.'
+ ),
zod
.object({
content: zod
.object({
- channelName: zod.string().optional(),
- channelType: zod.enum([
- 'public',
- 'private',
- 'directMessage',
- 'team',
- ]),
+ displayName: zod
+ .string()
+ .describe(
+ 'A compact label suitable for display in the UI.'
+ ),
+ foreignEntityId: zod
+ .uuid()
+ .describe(
+ 'The source-specific internal foreign entity row id for this pull request.'
+ ),
+ githubKey: zod
+ .string()
+ .describe(
+ 'The external GitHub key, in `owner\/repo\/pull\/number` format.'
+ ),
+ number: zod
+ .number()
+ .min(
+ getTypedNotificationsByEventItemIdResponseItemsItemNotificationMetadataContentNumberMinOne
+ )
+ .describe('The GitHub pull request number.'),
+ owner: zod
+ .string()
+ .describe(
+ 'The GitHub repository owner or organization.'
+ ),
+ repo: zod
+ .string()
+ .describe('The GitHub repository name.'),
+ senderGithubAvatarUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub avatar URL for the sender, when available.'
+ ),
+ senderGithubLogin: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub login for the sender, when available.'
+ ),
+ senderGithubUserId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The stable GitHub numeric user id for the sender, serialized as a string.'
+ ),
+ title: zod
+ .string()
+ .describe(
+ 'The GitHub pull request title. Falls back to `display_name` when GitHub has no title.'
+ ),
+ url: zod
+ .string()
+ .describe(
+ 'The public GitHub URL for the pull request.'
+ ),
})
.describe(
- 'Common metadata for notifications on channels'
+ 'Fields 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.'
)
.and(
zod.object({
- messageContent: zod
- .string()
- .optional()
- .describe('The content of the message'),
- messageId: zod.string().describe('The message id'),
- sender: zod
+ requestedReviewerGithubLogin: zod
.string()
.nullish()
.describe(
- 'The user who sent the message, when sent by a user'
+ 'The GitHub login of the requested reviewer, when available.'
),
- senderDisplayName: zod
+ requestedReviewerGithubUserId: zod
.string()
.nullish()
.describe(
- 'Display name for non-user senders such as bots'
+ 'The stable GitHub numeric user id of the requested reviewer, serialized as a string.'
),
- senderProfilePictureUrl: zod.string().nullish(),
})
+ )
+ .describe(
+ "Metadata for a notification that the user's review was requested on a GitHub pull request."
),
- tag: zod.enum(['channel_message_send']),
+ tag: zod.enum(['github_review_requested']),
})
- .describe('A user sent a message in a channel.'),
+ .describe(
+ "The user's review was requested on a GitHub pull request."
+ ),
zod
.object({
content: zod
.object({
- channelName: zod.string().optional(),
- channelType: zod.enum([
- 'public',
- 'private',
- 'directMessage',
- 'team',
- ]),
+ displayName: zod
+ .string()
+ .describe(
+ 'A compact label suitable for display in the UI.'
+ ),
+ foreignEntityId: zod
+ .uuid()
+ .describe(
+ 'The source-specific internal foreign entity row id for this pull request.'
+ ),
+ githubKey: zod
+ .string()
+ .describe(
+ 'The external GitHub key, in `owner\/repo\/pull\/number` format.'
+ ),
+ number: zod
+ .number()
+ .min(
+ getTypedNotificationsByEventItemIdResponseItemsItemNotificationMetadataContentNumberMinTwo
+ )
+ .describe('The GitHub pull request number.'),
+ owner: zod
+ .string()
+ .describe(
+ 'The GitHub repository owner or organization.'
+ ),
+ repo: zod
+ .string()
+ .describe('The GitHub repository name.'),
+ senderGithubAvatarUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub avatar URL for the sender, when available.'
+ ),
+ senderGithubLogin: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub login for the sender, when available.'
+ ),
+ senderGithubUserId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The stable GitHub numeric user id for the sender, serialized as a string.'
+ ),
+ title: zod
+ .string()
+ .describe(
+ 'The GitHub pull request title. Falls back to `display_name` when GitHub has no title.'
+ ),
+ url: zod
+ .string()
+ .describe(
+ 'The public GitHub URL for the pull request.'
+ ),
})
.describe(
- 'Common metadata for notifications on channels'
+ 'Fields 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.'
)
.and(
zod.object({
- messageContent: zod
- .string()
- .describe('The message content'),
- messageId: zod
- .string()
- .describe('The id of the new message'),
- senderDisplayName: zod
- .string()
+ commentGithubId: zod
+ .number()
+ .min(
+ getTypedNotificationsByEventItemIdResponseItemsItemNotificationMetadataContentCommentGithubIdMin
+ )
.nullish()
.describe(
- 'Display name for non-user senders such as bots'
+ 'The GitHub numeric id of the comment, when available.'
),
- senderProfilePictureUrl: zod.string().nullish(),
- threadId: zod
- .string()
+ commentKind: zod
+ .enum(['issue', 'review_comment'])
.describe(
- 'The id of the thread that has the reply'
+ 'The kind of GitHub comment that triggered a [`GithubPrComment`] notification.'
),
- threadParentSenderId: zod
+ commentSnippet: zod
.string()
- .nullish()
.describe(
- 'The user who sent the root message of the thread'
+ 'A truncated excerpt of the comment body.'
),
- userId: zod
+ commentUrl: zod
.string()
.nullish()
.describe(
- 'The sender id of the reply, when sent by a user'
+ 'The public GitHub URL for the comment, when available.'
),
})
+ )
+ .describe(
+ 'Metadata for a notification that a GitHub pull request was commented on.'
),
- tag: zod.enum(['channel_message_reply']),
- })
- .describe(
- 'Someone replied to a thread in a channel that the user is part of.'
- ),
- zod
- .object({
- content: zod.object({
- sender: zod.string().nullish(),
- snippet: zod.string(),
- subject: zod.string(),
- threadId: zod.string(),
- toEmail: zod.string(),
- }),
- tag: zod.enum(['new_email']),
+ tag: zod.enum(['github_pr_comment']),
})
- .describe('A new email has been sent to the user.'),
+ .describe('A GitHub pull request was commented on.'),
zod
.object({
content: zod
.object({
- invitedBy: zod
- .string()
- .describe('The user who sent the invitation'),
- role: zod
- .string()
- .nullish()
- .describe('Role\/permission level in the team'),
- senderProfilePictureUrl: zod
+ displayName: zod
.string()
- .nullish()
.describe(
- "The sender's profile picture URL, if available."
+ 'A compact label suitable for display in the UI.'
),
- teamId: zod
- .uuid()
- .describe('The unique identifier of the team'),
- teamInviteId: zod
+ foreignEntityId: zod
.uuid()
.describe(
- 'The unique identifier of the team invite'
+ 'The source-specific internal foreign entity row id for this pull request.'
),
- teamName: zod
+ githubKey: zod
.string()
- .describe('The name of the team being invited to'),
- })
- .describe(
- 'Metadata for when a user is invited to a team.'
- ),
- tag: zod.enum(['invite_to_team']),
- })
- .describe('A user was invited to a team.'),
- zod
- .object({
- content: zod
- .object({
- assignedBy: zod
+ .describe(
+ 'The external GitHub key, in `owner\/repo\/pull\/number` format.'
+ ),
+ number: zod
+ .number()
+ .min(
+ getTypedNotificationsByEventItemIdResponseItemsItemNotificationMetadataContentNumberMinThree
+ )
+ .describe('The GitHub pull request number.'),
+ owner: zod
.string()
- .describe('The user who assigned the task'),
- senderProfilePictureUrl: zod.string().nullish(),
- subType: zod
- .union([
- zod.null(),
- zod
- .union([
- zod.object({
- type: zod.enum(['task']),
- }),
- zod.object({
- type: zod.enum(['snippet']),
- }),
- ])
- .describe(
- 'The sub type of a document in a notification.\nSerializes as `{ \"type\": \"task\" }` matching the storage service pattern.'
- ),
- ])
- .optional(),
- taskId: zod
+ .describe(
+ 'The GitHub repository owner or organization.'
+ ),
+ repo: zod
.string()
- .describe('The unique identifier of the task'),
- taskName: zod
+ .describe('The GitHub repository name.'),
+ senderGithubAvatarUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub avatar URL for the sender, when available.'
+ ),
+ senderGithubLogin: zod
.string()
.nullish()
- .describe('The name of the task (optional)'),
- })
- .describe(
- 'Metadata for when a user is assigned to a task'
- ),
- tag: zod.enum(['task_assigned']),
- })
- .describe('A user was assigned to a task.'),
- zod
- .object({
- content: zod.object({
- messageId: zod.string(),
- summary: zod.string(),
- }),
- tag: zod.enum(['ai_response']),
- })
- .describe('An AI assistant responded to a chat.'),
- zod
- .object({
- content: zod
- .object({
- action: zod
- .enum(['opened', 'reopened', 'closed'])
.describe(
- 'The GitHub pull request webhook action that triggered the notification.'
+ 'The GitHub login for the sender, when available.'
),
- baseBranch: zod
+ senderGithubUserId: zod
.string()
.nullish()
.describe(
- 'The pull request base branch, when available.'
+ 'The stable GitHub numeric user id for the sender, serialized as a string.'
+ ),
+ title: zod
+ .string()
+ .describe(
+ 'The GitHub pull request title. Falls back to `display_name` when GitHub has no title.'
+ ),
+ url: zod
+ .string()
+ .describe(
+ 'The public GitHub URL for the pull request.'
),
+ })
+ .describe(
+ 'Fields 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.'
+ )
+ .and(
+ zod.object({
+ commentGithubId: zod
+ .number()
+ .min(
+ getTypedNotificationsByEventItemIdResponseItemsItemNotificationMetadataContentCommentGithubIdMinOne
+ )
+ .nullish()
+ .describe(
+ 'The GitHub numeric id of the comment or review containing the mention, when available.'
+ ),
+ commentUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The public GitHub URL for the text containing the mention, when available.'
+ ),
+ location: zod
+ .enum([
+ 'pr_body',
+ 'comment',
+ 'review',
+ 'review_comment',
+ ])
+ .describe(
+ 'Where in a GitHub pull request the user was mentioned.'
+ ),
+ textSnippet: zod
+ .string()
+ .describe(
+ 'A truncated excerpt of the text containing the mention.'
+ ),
+ })
+ )
+ .describe(
+ 'Metadata for a notification that the user was mentioned on a GitHub pull request.'
+ ),
+ tag: zod.enum(['github_pr_mention']),
+ })
+ .describe(
+ 'The user was mentioned on a GitHub pull request.'
+ ),
+ zod
+ .object({
+ content: zod
+ .object({
displayName: zod
.string()
.describe(
@@ -1992,22 +3258,10 @@ export const getTypedNotificationsByEventItemIdResponse = zod
.describe(
'The external GitHub key, in `owner\/repo\/pull\/number` format.'
),
- headBranch: zod
- .string()
- .nullish()
- .describe(
- 'The pull request head branch, when available.'
- ),
- mergedAt: zod.iso
- .datetime({})
- .nullish()
- .describe(
- 'When the pull request was merged, when available.'
- ),
number: zod
.number()
.min(
- getTypedNotificationsByEventItemIdResponseItemsItemNotificationMetadataContentNumberMin
+ getTypedNotificationsByEventItemIdResponseItemsItemNotificationMetadataContentNumberMinFour
)
.describe('The GitHub pull request number.'),
owner: zod
@@ -2015,16 +3269,6 @@ export const getTypedNotificationsByEventItemIdResponse = zod
.describe(
'The GitHub repository owner or organization.'
),
- previousStatus: zod
- .union([
- zod.null(),
- zod
- .enum(['open', 'closed', 'merged'])
- .describe(
- 'The normalized lifecycle status for a GitHub pull request notification.'
- ),
- ])
- .optional(),
repo: zod
.string()
.describe('The GitHub repository name.'),
@@ -2046,11 +3290,6 @@ export const getTypedNotificationsByEventItemIdResponse = zod
.describe(
'The stable GitHub numeric user id for the sender, serialized as a string.'
),
- status: zod
- .enum(['open', 'closed', 'merged'])
- .describe(
- 'The normalized lifecycle status for a GitHub pull request notification.'
- ),
title: zod
.string()
.describe(
@@ -2063,11 +3302,50 @@ export const getTypedNotificationsByEventItemIdResponse = zod
),
})
.describe(
- 'Metadata for a GitHub pull request lifecycle notification.'
+ 'Fields 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.'
+ )
+ .and(
+ zod.object({
+ reviewGithubId: zod
+ .number()
+ .min(
+ getTypedNotificationsByEventItemIdResponseItemsItemNotificationMetadataContentReviewGithubIdMin
+ )
+ .nullish()
+ .describe(
+ 'The GitHub numeric id of the review, when available.'
+ ),
+ reviewSnippet: zod
+ .string()
+ .nullish()
+ .describe(
+ 'A truncated excerpt of the review body, when any was written.'
+ ),
+ reviewUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The public GitHub URL for the review, when available.'
+ ),
+ state: zod
+ .enum([
+ 'approved',
+ 'changes_requested',
+ 'commented',
+ ])
+ .describe(
+ 'The state of a submitted GitHub pull request review.'
+ ),
+ })
+ )
+ .describe(
+ "Metadata for a notification that a review was submitted on the user's GitHub pull request."
),
- tag: zod.enum(['github_pr_event']),
+ tag: zod.enum(['github_pr_review']),
})
- .describe('A GitHub pull request changed lifecycle state.'),
+ .describe(
+ "A review was submitted on the user's GitHub pull request."
+ ),
])
.describe(
'Mirrors [`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.'
@@ -2138,6 +3416,20 @@ export const getTypedNotificationByIdParams = zod.object({
export const getTypedNotificationByIdResponseNotificationMetadataContentNumberMin = 0;
+export const getTypedNotificationByIdResponseNotificationMetadataContentNumberMinOne = 0;
+
+export const getTypedNotificationByIdResponseNotificationMetadataContentNumberMinTwo = 0;
+
+export const getTypedNotificationByIdResponseNotificationMetadataContentCommentGithubIdMin = 0;
+
+export const getTypedNotificationByIdResponseNotificationMetadataContentNumberMinThree = 0;
+
+export const getTypedNotificationByIdResponseNotificationMetadataContentCommentGithubIdMinOne = 0;
+
+export const getTypedNotificationByIdResponseNotificationMetadataContentNumberMinFour = 0;
+
+export const getTypedNotificationByIdResponseNotificationMetadataContentReviewGithubIdMin = 0;
+
export const getTypedNotificationByIdResponse = zod
.object({
entity_id: zod.string().describe('The id of that entity'),
@@ -2325,62 +3617,255 @@ export const getTypedNotificationByIdResponse = zod
),
tag: zod.enum(['mentioned_in_document_comment']),
})
- .describe('User was mentioned in a comment in a document'),
+ .describe('User was mentioned in a comment in a document'),
+ zod
+ .object({
+ content: zod
+ .object({
+ commentId: zod.number().describe('the comment id'),
+ documentName: zod
+ .string()
+ .describe('The name of the document.'),
+ fileType: zod
+ .string()
+ .nullish()
+ .describe('The file type of the document.'),
+ owner: zod.string().describe('The owner of the document.'),
+ senderProfilePictureUrl: zod.string().nullish(),
+ subType: zod
+ .union([
+ zod.null(),
+ zod
+ .union([
+ zod.object({
+ type: zod.enum(['task']),
+ }),
+ zod.object({
+ type: zod.enum(['snippet']),
+ }),
+ ])
+ .describe(
+ 'The sub type of a document in a notification.\nSerializes as `{ \"type\": \"task\" }` matching the storage service pattern.'
+ ),
+ ])
+ .optional(),
+ text: zod.string().describe('the text of the comment'),
+ threadId: zod.number().describe('the thread id'),
+ })
+ .describe(
+ 'Notification sent when someone replies to a document comment thread.'
+ ),
+ tag: zod.enum(['replied_to_document_comment_thread']),
+ })
+ .describe(
+ 'Someone replied to a document comment thread the user participated in.'
+ ),
+ zod
+ .object({
+ content: zod
+ .object({
+ commentId: zod.number().describe('the comment id'),
+ documentName: zod
+ .string()
+ .describe('The name of the document.'),
+ fileType: zod
+ .string()
+ .nullish()
+ .describe('The file type of the document.'),
+ owner: zod.string().describe('The owner of the document.'),
+ senderProfilePictureUrl: zod.string().nullish(),
+ subType: zod
+ .union([
+ zod.null(),
+ zod
+ .union([
+ zod.object({
+ type: zod.enum(['task']),
+ }),
+ zod.object({
+ type: zod.enum(['snippet']),
+ }),
+ ])
+ .describe(
+ 'The sub type of a document in a notification.\nSerializes as `{ \"type\": \"task\" }` matching the storage service pattern.'
+ ),
+ ])
+ .optional(),
+ text: zod.string().describe('the text of the comment'),
+ threadId: zod.number().describe('the thread id'),
+ })
+ .describe(
+ 'Notification sent when someone comments on a document the user owns.'
+ ),
+ tag: zod.enum(['commented_on_document']),
+ })
+ .describe('Someone commented on a document the user owns.'),
+ zod
+ .object({
+ content: zod
+ .object({
+ channelName: zod
+ .string()
+ .optional()
+ .describe('The name of the channel'),
+ invitedBy: zod
+ .string()
+ .describe('The user who sent the invitation'),
+ messageContent: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Message content to show in the invite email, when the invite was triggered by a message.'
+ ),
+ senderProfilePictureUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ "The sender's profile picture URL, if available."
+ ),
+ })
+ .describe('Metadata for when a user is invited to a channel.'),
+ tag: zod.enum(['channel_invite']),
+ })
+ .describe('The user was invited to a channel.'),
+ zod
+ .object({
+ content: zod
+ .object({
+ channelName: zod.string().optional(),
+ channelType: zod.enum([
+ 'public',
+ 'private',
+ 'directMessage',
+ 'team',
+ ]),
+ })
+ .describe('Common metadata for notifications on channels')
+ .and(
+ zod.object({
+ messageContent: zod
+ .string()
+ .optional()
+ .describe('The content of the message'),
+ messageId: zod.string().describe('The message id'),
+ sender: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The user who sent the message, when sent by a user'
+ ),
+ senderDisplayName: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Display name for non-user senders such as bots'
+ ),
+ senderProfilePictureUrl: zod.string().nullish(),
+ })
+ ),
+ tag: zod.enum(['channel_message_send']),
+ })
+ .describe('A user sent a message in a channel.'),
+ zod
+ .object({
+ content: zod
+ .object({
+ channelName: zod.string().optional(),
+ channelType: zod.enum([
+ 'public',
+ 'private',
+ 'directMessage',
+ 'team',
+ ]),
+ })
+ .describe('Common metadata for notifications on channels')
+ .and(
+ zod.object({
+ messageContent: zod
+ .string()
+ .describe('The message content'),
+ messageId: zod
+ .string()
+ .describe('The id of the new message'),
+ senderDisplayName: zod
+ .string()
+ .nullish()
+ .describe(
+ 'Display name for non-user senders such as bots'
+ ),
+ senderProfilePictureUrl: zod.string().nullish(),
+ threadId: zod
+ .string()
+ .describe('The id of the thread that has the reply'),
+ threadParentSenderId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The user who sent the root message of the thread'
+ ),
+ userId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The sender id of the reply, when sent by a user'
+ ),
+ })
+ ),
+ tag: zod.enum(['channel_message_reply']),
+ })
+ .describe(
+ 'Someone replied to a thread in a channel that the user is part of.'
+ ),
+ zod
+ .object({
+ content: zod.object({
+ sender: zod.string().nullish(),
+ snippet: zod.string(),
+ subject: zod.string(),
+ threadId: zod.string(),
+ toEmail: zod.string(),
+ }),
+ tag: zod.enum(['new_email']),
+ })
+ .describe('A new email has been sent to the user.'),
zod
.object({
content: zod
.object({
- commentId: zod.number().describe('the comment id'),
- documentName: zod
+ invitedBy: zod
.string()
- .describe('The name of the document.'),
- fileType: zod
+ .describe('The user who sent the invitation'),
+ role: zod
.string()
.nullish()
- .describe('The file type of the document.'),
- owner: zod.string().describe('The owner of the document.'),
- senderProfilePictureUrl: zod.string().nullish(),
- subType: zod
- .union([
- zod.null(),
- zod
- .union([
- zod.object({
- type: zod.enum(['task']),
- }),
- zod.object({
- type: zod.enum(['snippet']),
- }),
- ])
- .describe(
- 'The sub type of a document in a notification.\nSerializes as `{ \"type\": \"task\" }` matching the storage service pattern.'
- ),
- ])
- .optional(),
- text: zod.string().describe('the text of the comment'),
- threadId: zod.number().describe('the thread id'),
+ .describe('Role\/permission level in the team'),
+ senderProfilePictureUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ "The sender's profile picture URL, if available."
+ ),
+ teamId: zod
+ .uuid()
+ .describe('The unique identifier of the team'),
+ teamInviteId: zod
+ .uuid()
+ .describe('The unique identifier of the team invite'),
+ teamName: zod
+ .string()
+ .describe('The name of the team being invited to'),
})
- .describe(
- 'Notification sent when someone replies to a document comment thread.'
- ),
- tag: zod.enum(['replied_to_document_comment_thread']),
+ .describe('Metadata for when a user is invited to a team.'),
+ tag: zod.enum(['invite_to_team']),
})
- .describe(
- 'Someone replied to a document comment thread the user participated in.'
- ),
+ .describe('A user was invited to a team.'),
zod
.object({
content: zod
.object({
- commentId: zod.number().describe('the comment id'),
- documentName: zod
- .string()
- .describe('The name of the document.'),
- fileType: zod
+ assignedBy: zod
.string()
- .nullish()
- .describe('The file type of the document.'),
- owner: zod.string().describe('The owner of the document.'),
+ .describe('The user who assigned the task'),
senderProfilePictureUrl: zod.string().nullish(),
subType: zod
.union([
@@ -2399,233 +3884,409 @@ export const getTypedNotificationByIdResponse = zod
),
])
.optional(),
- text: zod.string().describe('the text of the comment'),
- threadId: zod.number().describe('the thread id'),
+ taskId: zod
+ .string()
+ .describe('The unique identifier of the task'),
+ taskName: zod
+ .string()
+ .nullish()
+ .describe('The name of the task (optional)'),
})
- .describe(
- 'Notification sent when someone comments on a document the user owns.'
- ),
- tag: zod.enum(['commented_on_document']),
+ .describe('Metadata for when a user is assigned to a task'),
+ tag: zod.enum(['task_assigned']),
})
- .describe('Someone commented on a document the user owns.'),
+ .describe('A user was assigned to a task.'),
+ zod
+ .object({
+ content: zod.object({
+ messageId: zod.string(),
+ summary: zod.string(),
+ }),
+ tag: zod.enum(['ai_response']),
+ })
+ .describe('An AI assistant responded to a chat.'),
zod
.object({
content: zod
.object({
- channelName: zod
+ displayName: zod
.string()
- .optional()
- .describe('The name of the channel'),
- invitedBy: zod
+ .describe(
+ 'A compact label suitable for display in the UI.'
+ ),
+ foreignEntityId: zod
+ .uuid()
+ .describe(
+ 'The source-specific internal foreign entity row id for this pull request.'
+ ),
+ githubKey: zod
.string()
- .describe('The user who sent the invitation'),
- messageContent: zod
+ .describe(
+ 'The external GitHub key, in `owner\/repo\/pull\/number` format.'
+ ),
+ number: zod
+ .number()
+ .min(
+ getTypedNotificationByIdResponseNotificationMetadataContentNumberMin
+ )
+ .describe('The GitHub pull request number.'),
+ owner: zod
+ .string()
+ .describe('The GitHub repository owner or organization.'),
+ repo: zod.string().describe('The GitHub repository name.'),
+ senderGithubAvatarUrl: zod
.string()
.nullish()
.describe(
- 'Message content to show in the invite email, when the invite was triggered by a message.'
+ 'The GitHub avatar URL for the sender, when available.'
),
- senderProfilePictureUrl: zod
+ senderGithubLogin: zod
.string()
.nullish()
.describe(
- "The sender's profile picture URL, if available."
+ 'The GitHub login for the sender, when available.'
),
+ senderGithubUserId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The stable GitHub numeric user id for the sender, serialized as a string.'
+ ),
+ title: zod
+ .string()
+ .describe(
+ 'The GitHub pull request title. Falls back to `display_name` when GitHub has no title.'
+ ),
+ url: zod
+ .string()
+ .describe('The public GitHub URL for the pull request.'),
})
- .describe('Metadata for when a user is invited to a channel.'),
- tag: zod.enum(['channel_invite']),
- })
- .describe('The user was invited to a channel.'),
- zod
- .object({
- content: zod
- .object({
- channelName: zod.string().optional(),
- channelType: zod.enum([
- 'public',
- 'private',
- 'directMessage',
- 'team',
- ]),
- })
- .describe('Common metadata for notifications on channels')
+ .describe(
+ 'Fields 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.'
+ )
.and(
zod.object({
- messageContent: zod
- .string()
- .optional()
- .describe('The content of the message'),
- messageId: zod.string().describe('The message id'),
- sender: zod
+ action: zod
+ .enum(['opened', 'reopened', 'closed'])
+ .describe(
+ 'The GitHub pull request webhook action that triggered the notification.'
+ ),
+ baseBranch: zod
.string()
.nullish()
.describe(
- 'The user who sent the message, when sent by a user'
+ 'The pull request base branch, when available.'
),
- senderDisplayName: zod
+ headBranch: zod
.string()
.nullish()
.describe(
- 'Display name for non-user senders such as bots'
+ 'The pull request head branch, when available.'
+ ),
+ mergedAt: zod.iso
+ .datetime({})
+ .nullish()
+ .describe(
+ 'When the pull request was merged, when available.'
+ ),
+ previousStatus: zod
+ .union([
+ zod.null(),
+ zod
+ .enum(['open', 'closed', 'merged'])
+ .describe(
+ 'The normalized lifecycle status for a GitHub pull request notification.'
+ ),
+ ])
+ .optional(),
+ status: zod
+ .enum(['open', 'closed', 'merged'])
+ .describe(
+ 'The normalized lifecycle status for a GitHub pull request notification.'
),
- senderProfilePictureUrl: zod.string().nullish(),
})
+ )
+ .describe(
+ 'Metadata for a GitHub pull request lifecycle notification.'
),
- tag: zod.enum(['channel_message_send']),
+ tag: zod.enum(['github_pr_status_changed']),
})
- .describe('A user sent a message in a channel.'),
+ .describe(
+ 'A GitHub pull request changed lifecycle state.\n\nThe `github_pr_event` alias keeps rows and queue messages persisted\nbefore the rename deserializable.'
+ ),
zod
.object({
content: zod
.object({
- channelName: zod.string().optional(),
- channelType: zod.enum([
- 'public',
- 'private',
- 'directMessage',
- 'team',
- ]),
+ displayName: zod
+ .string()
+ .describe(
+ 'A compact label suitable for display in the UI.'
+ ),
+ foreignEntityId: zod
+ .uuid()
+ .describe(
+ 'The source-specific internal foreign entity row id for this pull request.'
+ ),
+ githubKey: zod
+ .string()
+ .describe(
+ 'The external GitHub key, in `owner\/repo\/pull\/number` format.'
+ ),
+ number: zod
+ .number()
+ .min(
+ getTypedNotificationByIdResponseNotificationMetadataContentNumberMinOne
+ )
+ .describe('The GitHub pull request number.'),
+ owner: zod
+ .string()
+ .describe('The GitHub repository owner or organization.'),
+ repo: zod.string().describe('The GitHub repository name.'),
+ senderGithubAvatarUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub avatar URL for the sender, when available.'
+ ),
+ senderGithubLogin: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub login for the sender, when available.'
+ ),
+ senderGithubUserId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The stable GitHub numeric user id for the sender, serialized as a string.'
+ ),
+ title: zod
+ .string()
+ .describe(
+ 'The GitHub pull request title. Falls back to `display_name` when GitHub has no title.'
+ ),
+ url: zod
+ .string()
+ .describe('The public GitHub URL for the pull request.'),
})
- .describe('Common metadata for notifications on channels')
+ .describe(
+ 'Fields 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.'
+ )
.and(
zod.object({
- messageContent: zod
- .string()
- .describe('The message content'),
- messageId: zod
- .string()
- .describe('The id of the new message'),
- senderDisplayName: zod
- .string()
- .nullish()
- .describe(
- 'Display name for non-user senders such as bots'
- ),
- senderProfilePictureUrl: zod.string().nullish(),
- threadId: zod
- .string()
- .describe('The id of the thread that has the reply'),
- threadParentSenderId: zod
+ requestedReviewerGithubLogin: zod
.string()
.nullish()
.describe(
- 'The user who sent the root message of the thread'
+ 'The GitHub login of the requested reviewer, when available.'
),
- userId: zod
+ requestedReviewerGithubUserId: zod
.string()
.nullish()
.describe(
- 'The sender id of the reply, when sent by a user'
+ 'The stable GitHub numeric user id of the requested reviewer, serialized as a string.'
),
})
+ )
+ .describe(
+ "Metadata for a notification that the user's review was requested on a GitHub pull request."
),
- tag: zod.enum(['channel_message_reply']),
+ tag: zod.enum(['github_review_requested']),
})
.describe(
- 'Someone replied to a thread in a channel that the user is part of.'
+ "The user's review was requested on a GitHub pull request."
),
- zod
- .object({
- content: zod.object({
- sender: zod.string().nullish(),
- snippet: zod.string(),
- subject: zod.string(),
- threadId: zod.string(),
- toEmail: zod.string(),
- }),
- tag: zod.enum(['new_email']),
- })
- .describe('A new email has been sent to the user.'),
zod
.object({
content: zod
.object({
- invitedBy: zod
+ displayName: zod
.string()
- .describe('The user who sent the invitation'),
- role: zod
+ .describe(
+ 'A compact label suitable for display in the UI.'
+ ),
+ foreignEntityId: zod
+ .uuid()
+ .describe(
+ 'The source-specific internal foreign entity row id for this pull request.'
+ ),
+ githubKey: zod
+ .string()
+ .describe(
+ 'The external GitHub key, in `owner\/repo\/pull\/number` format.'
+ ),
+ number: zod
+ .number()
+ .min(
+ getTypedNotificationByIdResponseNotificationMetadataContentNumberMinTwo
+ )
+ .describe('The GitHub pull request number.'),
+ owner: zod
+ .string()
+ .describe('The GitHub repository owner or organization.'),
+ repo: zod.string().describe('The GitHub repository name.'),
+ senderGithubAvatarUrl: zod
.string()
.nullish()
- .describe('Role\/permission level in the team'),
- senderProfilePictureUrl: zod
+ .describe(
+ 'The GitHub avatar URL for the sender, when available.'
+ ),
+ senderGithubLogin: zod
.string()
.nullish()
.describe(
- "The sender's profile picture URL, if available."
+ 'The GitHub login for the sender, when available.'
),
- teamId: zod
- .uuid()
- .describe('The unique identifier of the team'),
- teamInviteId: zod
- .uuid()
- .describe('The unique identifier of the team invite'),
- teamName: zod
+ senderGithubUserId: zod
.string()
- .describe('The name of the team being invited to'),
+ .nullish()
+ .describe(
+ 'The stable GitHub numeric user id for the sender, serialized as a string.'
+ ),
+ title: zod
+ .string()
+ .describe(
+ 'The GitHub pull request title. Falls back to `display_name` when GitHub has no title.'
+ ),
+ url: zod
+ .string()
+ .describe('The public GitHub URL for the pull request.'),
})
- .describe('Metadata for when a user is invited to a team.'),
- tag: zod.enum(['invite_to_team']),
+ .describe(
+ 'Fields 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.'
+ )
+ .and(
+ zod.object({
+ commentGithubId: zod
+ .number()
+ .min(
+ getTypedNotificationByIdResponseNotificationMetadataContentCommentGithubIdMin
+ )
+ .nullish()
+ .describe(
+ 'The GitHub numeric id of the comment, when available.'
+ ),
+ commentKind: zod
+ .enum(['issue', 'review_comment'])
+ .describe(
+ 'The kind of GitHub comment that triggered a [`GithubPrComment`] notification.'
+ ),
+ commentSnippet: zod
+ .string()
+ .describe('A truncated excerpt of the comment body.'),
+ commentUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The public GitHub URL for the comment, when available.'
+ ),
+ })
+ )
+ .describe(
+ 'Metadata for a notification that a GitHub pull request was commented on.'
+ ),
+ tag: zod.enum(['github_pr_comment']),
})
- .describe('A user was invited to a team.'),
+ .describe('A GitHub pull request was commented on.'),
zod
.object({
content: zod
.object({
- assignedBy: zod
+ displayName: zod
.string()
- .describe('The user who assigned the task'),
- senderProfilePictureUrl: zod.string().nullish(),
- subType: zod
- .union([
- zod.null(),
- zod
- .union([
- zod.object({
- type: zod.enum(['task']),
- }),
- zod.object({
- type: zod.enum(['snippet']),
- }),
- ])
- .describe(
- 'The sub type of a document in a notification.\nSerializes as `{ \"type\": \"task\" }` matching the storage service pattern.'
- ),
- ])
- .optional(),
- taskId: zod
+ .describe(
+ 'A compact label suitable for display in the UI.'
+ ),
+ foreignEntityId: zod
+ .uuid()
+ .describe(
+ 'The source-specific internal foreign entity row id for this pull request.'
+ ),
+ githubKey: zod
.string()
- .describe('The unique identifier of the task'),
- taskName: zod
+ .describe(
+ 'The external GitHub key, in `owner\/repo\/pull\/number` format.'
+ ),
+ number: zod
+ .number()
+ .min(
+ getTypedNotificationByIdResponseNotificationMetadataContentNumberMinThree
+ )
+ .describe('The GitHub pull request number.'),
+ owner: zod
+ .string()
+ .describe('The GitHub repository owner or organization.'),
+ repo: zod.string().describe('The GitHub repository name.'),
+ senderGithubAvatarUrl: zod
.string()
.nullish()
- .describe('The name of the task (optional)'),
+ .describe(
+ 'The GitHub avatar URL for the sender, when available.'
+ ),
+ senderGithubLogin: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The GitHub login for the sender, when available.'
+ ),
+ senderGithubUserId: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The stable GitHub numeric user id for the sender, serialized as a string.'
+ ),
+ title: zod
+ .string()
+ .describe(
+ 'The GitHub pull request title. Falls back to `display_name` when GitHub has no title.'
+ ),
+ url: zod
+ .string()
+ .describe('The public GitHub URL for the pull request.'),
})
- .describe('Metadata for when a user is assigned to a task'),
- tag: zod.enum(['task_assigned']),
- })
- .describe('A user was assigned to a task.'),
- zod
- .object({
- content: zod.object({
- messageId: zod.string(),
- summary: zod.string(),
- }),
- tag: zod.enum(['ai_response']),
+ .describe(
+ 'Fields 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.'
+ )
+ .and(
+ zod.object({
+ commentGithubId: zod
+ .number()
+ .min(
+ getTypedNotificationByIdResponseNotificationMetadataContentCommentGithubIdMinOne
+ )
+ .nullish()
+ .describe(
+ 'The GitHub numeric id of the comment or review containing the mention, when available.'
+ ),
+ commentUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The public GitHub URL for the text containing the mention, when available.'
+ ),
+ location: zod
+ .enum(['pr_body', 'comment', 'review', 'review_comment'])
+ .describe(
+ 'Where in a GitHub pull request the user was mentioned.'
+ ),
+ textSnippet: zod
+ .string()
+ .describe(
+ 'A truncated excerpt of the text containing the mention.'
+ ),
+ })
+ )
+ .describe(
+ 'Metadata for a notification that the user was mentioned on a GitHub pull request.'
+ ),
+ tag: zod.enum(['github_pr_mention']),
})
- .describe('An AI assistant responded to a chat.'),
+ .describe('The user was mentioned on a GitHub pull request.'),
zod
.object({
content: zod
.object({
- action: zod
- .enum(['opened', 'reopened', 'closed'])
- .describe(
- 'The GitHub pull request webhook action that triggered the notification.'
- ),
- baseBranch: zod
- .string()
- .nullish()
- .describe('The pull request base branch, when available.'),
displayName: zod
.string()
.describe(
@@ -2641,35 +4302,15 @@ export const getTypedNotificationByIdResponse = zod
.describe(
'The external GitHub key, in `owner\/repo\/pull\/number` format.'
),
- headBranch: zod
- .string()
- .nullish()
- .describe('The pull request head branch, when available.'),
- mergedAt: zod.iso
- .datetime({})
- .nullish()
- .describe(
- 'When the pull request was merged, when available.'
- ),
number: zod
.number()
.min(
- getTypedNotificationByIdResponseNotificationMetadataContentNumberMin
+ getTypedNotificationByIdResponseNotificationMetadataContentNumberMinFour
)
.describe('The GitHub pull request number.'),
owner: zod
.string()
.describe('The GitHub repository owner or organization.'),
- previousStatus: zod
- .union([
- zod.null(),
- zod
- .enum(['open', 'closed', 'merged'])
- .describe(
- 'The normalized lifecycle status for a GitHub pull request notification.'
- ),
- ])
- .optional(),
repo: zod.string().describe('The GitHub repository name.'),
senderGithubAvatarUrl: zod
.string()
@@ -2689,11 +4330,6 @@ export const getTypedNotificationByIdResponse = zod
.describe(
'The stable GitHub numeric user id for the sender, serialized as a string.'
),
- status: zod
- .enum(['open', 'closed', 'merged'])
- .describe(
- 'The normalized lifecycle status for a GitHub pull request notification.'
- ),
title: zod
.string()
.describe(
@@ -2704,11 +4340,46 @@ export const getTypedNotificationByIdResponse = zod
.describe('The public GitHub URL for the pull request.'),
})
.describe(
- 'Metadata for a GitHub pull request lifecycle notification.'
+ 'Fields 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.'
+ )
+ .and(
+ zod.object({
+ reviewGithubId: zod
+ .number()
+ .min(
+ getTypedNotificationByIdResponseNotificationMetadataContentReviewGithubIdMin
+ )
+ .nullish()
+ .describe(
+ 'The GitHub numeric id of the review, when available.'
+ ),
+ reviewSnippet: zod
+ .string()
+ .nullish()
+ .describe(
+ 'A truncated excerpt of the review body, when any was written.'
+ ),
+ reviewUrl: zod
+ .string()
+ .nullish()
+ .describe(
+ 'The public GitHub URL for the review, when available.'
+ ),
+ state: zod
+ .enum(['approved', 'changes_requested', 'commented'])
+ .describe(
+ 'The state of a submitted GitHub pull request review.'
+ ),
+ })
+ )
+ .describe(
+ "Metadata for a notification that a review was submitted on the user's GitHub pull request."
),
- tag: zod.enum(['github_pr_event']),
+ tag: zod.enum(['github_pr_review']),
})
- .describe('A GitHub pull request changed lifecycle state.'),
+ .describe(
+ "A review was submitted on the user's GitHub pull request."
+ ),
])
.describe(
'Mirrors [`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.'
diff --git a/js/app/packages/service-clients/service-notification/openapi.json b/js/app/packages/service-clients/service-notification/openapi.json
index edc3baaa6d..469e70e43b 100644
--- a/js/app/packages/service-clients/service-notification/openapi.json
+++ b/js/app/packages/service-clients/service-notification/openapi.json
@@ -1534,9 +1534,95 @@
}
}
},
- "GithubPrEvent": {
+ "GithubPrComment": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/GithubPrNotificationCommon",
+ "description": "Fields shared with the other GitHub pull request notifications."
+ },
+ {
+ "type": "object",
+ "required": ["commentKind", "commentSnippet"],
+ "properties": {
+ "commentGithubId": {
+ "type": ["integer", "null"],
+ "format": "int64",
+ "description": "The GitHub numeric id of the comment, when available.",
+ "minimum": 0
+ },
+ "commentKind": {
+ "$ref": "#/components/schemas/GithubPrCommentKind",
+ "description": "The kind of comment that was posted."
+ },
+ "commentSnippet": {
+ "type": "string",
+ "description": "A truncated excerpt of the comment body."
+ },
+ "commentUrl": {
+ "type": ["string", "null"],
+ "description": "The public GitHub URL for the comment, when available."
+ }
+ }
+ }
+ ],
+ "description": "Metadata for a notification that a GitHub pull request was commented on."
+ },
+ "GithubPrCommentKind": {
+ "type": "string",
+ "description": "The kind of GitHub comment that triggered a [`GithubPrComment`] notification.",
+ "enum": ["issue", "review_comment"]
+ },
+ "GithubPrEventAction": {
+ "type": "string",
+ "description": "The GitHub pull request webhook action that triggered the notification.",
+ "enum": ["opened", "reopened", "closed"]
+ },
+ "GithubPrEventStatus": {
+ "type": "string",
+ "description": "The normalized lifecycle status for a GitHub pull request notification.",
+ "enum": ["open", "closed", "merged"]
+ },
+ "GithubPrMention": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/GithubPrNotificationCommon",
+ "description": "Fields shared with the other GitHub pull request notifications."
+ },
+ {
+ "type": "object",
+ "required": ["location", "textSnippet"],
+ "properties": {
+ "commentGithubId": {
+ "type": ["integer", "null"],
+ "format": "int64",
+ "description": "The GitHub numeric id of the comment or review containing the mention, when available.",
+ "minimum": 0
+ },
+ "commentUrl": {
+ "type": ["string", "null"],
+ "description": "The public GitHub URL for the text containing the mention, when available."
+ },
+ "location": {
+ "$ref": "#/components/schemas/GithubPrMentionLocation",
+ "description": "Where the mention appeared."
+ },
+ "textSnippet": {
+ "type": "string",
+ "description": "A truncated excerpt of the text containing the mention."
+ }
+ }
+ }
+ ],
+ "description": "Metadata for a notification that the user was mentioned on a GitHub pull request."
+ },
+ "GithubPrMentionLocation": {
+ "type": "string",
+ "description": "Where in a GitHub pull request the user was mentioned.",
+ "enum": ["pr_body", "comment", "review", "review_comment"]
+ },
+ "GithubPrNotificationCommon": {
"type": "object",
- "description": "Metadata for a GitHub pull request lifecycle notification.",
+ "description": "Fields 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.",
"required": [
"foreignEntityId",
"githubKey",
@@ -1545,19 +1631,9 @@
"number",
"url",
"displayName",
- "title",
- "status",
- "action"
+ "title"
],
"properties": {
- "action": {
- "$ref": "#/components/schemas/GithubPrEventAction",
- "description": "The webhook action that triggered this notification."
- },
- "baseBranch": {
- "type": ["string", "null"],
- "description": "The pull request base branch, when available."
- },
"displayName": {
"type": "string",
"description": "A compact label suitable for display in the UI."
@@ -1571,15 +1647,6 @@
"type": "string",
"description": "The external GitHub key, in `owner/repo/pull/number` format."
},
- "headBranch": {
- "type": ["string", "null"],
- "description": "The pull request head branch, when available."
- },
- "mergedAt": {
- "type": ["string", "null"],
- "format": "date-time",
- "description": "When the pull request was merged, when available."
- },
"number": {
"type": "integer",
"format": "int64",
@@ -1590,17 +1657,6 @@
"type": "string",
"description": "The GitHub repository owner or organization."
},
- "previousStatus": {
- "oneOf": [
- {
- "type": "null"
- },
- {
- "$ref": "#/components/schemas/GithubPrEventStatus",
- "description": "The prior normalized pull request status, when known."
- }
- ]
- },
"repo": {
"type": "string",
"description": "The GitHub repository name."
@@ -1617,10 +1673,6 @@
"type": ["string", "null"],
"description": "The stable GitHub numeric user id for the sender, serialized as a string."
},
- "status": {
- "$ref": "#/components/schemas/GithubPrEventStatus",
- "description": "The current normalized pull request status."
- },
"title": {
"type": "string",
"description": "The GitHub pull request title. Falls back to `display_name` when GitHub has no title."
@@ -1631,15 +1683,112 @@
}
}
},
- "GithubPrEventAction": {
- "type": "string",
- "description": "The GitHub pull request webhook action that triggered the notification.",
- "enum": ["opened", "reopened", "closed"]
+ "GithubPrReview": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/GithubPrNotificationCommon",
+ "description": "Fields shared with the other GitHub pull request notifications."
+ },
+ {
+ "type": "object",
+ "required": ["state"],
+ "properties": {
+ "reviewGithubId": {
+ "type": ["integer", "null"],
+ "format": "int64",
+ "description": "The GitHub numeric id of the review, when available.",
+ "minimum": 0
+ },
+ "reviewSnippet": {
+ "type": ["string", "null"],
+ "description": "A truncated excerpt of the review body, when any was written."
+ },
+ "reviewUrl": {
+ "type": ["string", "null"],
+ "description": "The public GitHub URL for the review, when available."
+ },
+ "state": {
+ "$ref": "#/components/schemas/GithubPrReviewState",
+ "description": "The review decision state."
+ }
+ }
+ }
+ ],
+ "description": "Metadata for a notification that a review was submitted on the user's GitHub pull request."
},
- "GithubPrEventStatus": {
+ "GithubPrReviewState": {
"type": "string",
- "description": "The normalized lifecycle status for a GitHub pull request notification.",
- "enum": ["open", "closed", "merged"]
+ "description": "The state of a submitted GitHub pull request review.",
+ "enum": ["approved", "changes_requested", "commented"]
+ },
+ "GithubPrStatusChanged": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/GithubPrNotificationCommon",
+ "description": "Fields shared with the other GitHub pull request notifications."
+ },
+ {
+ "type": "object",
+ "required": ["status", "action"],
+ "properties": {
+ "action": {
+ "$ref": "#/components/schemas/GithubPrEventAction",
+ "description": "The webhook action that triggered this notification."
+ },
+ "baseBranch": {
+ "type": ["string", "null"],
+ "description": "The pull request base branch, when available."
+ },
+ "headBranch": {
+ "type": ["string", "null"],
+ "description": "The pull request head branch, when available."
+ },
+ "mergedAt": {
+ "type": ["string", "null"],
+ "format": "date-time",
+ "description": "When the pull request was merged, when available."
+ },
+ "previousStatus": {
+ "oneOf": [
+ {
+ "type": "null"
+ },
+ {
+ "$ref": "#/components/schemas/GithubPrEventStatus",
+ "description": "The prior normalized pull request status, when known."
+ }
+ ]
+ },
+ "status": {
+ "$ref": "#/components/schemas/GithubPrEventStatus",
+ "description": "The current normalized pull request status."
+ }
+ }
+ }
+ ],
+ "description": "Metadata for a GitHub pull request lifecycle notification."
+ },
+ "GithubReviewRequested": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/GithubPrNotificationCommon",
+ "description": "Fields shared with the other GitHub pull request notifications."
+ },
+ {
+ "type": "object",
+ "properties": {
+ "requestedReviewerGithubLogin": {
+ "type": ["string", "null"],
+ "description": "The GitHub login of the requested reviewer, when available."
+ },
+ "requestedReviewerGithubUserId": {
+ "type": ["string", "null"],
+ "description": "The stable GitHub numeric user id of the requested reviewer, serialized as a string."
+ }
+ }
+ }
+ ],
+ "description": "Metadata for a notification that the user's review was requested on a GitHub pull request."
},
"InviteToTeamMetadata": {
"type": "object",
@@ -1973,16 +2122,76 @@
},
{
"type": "object",
- "description": "A GitHub pull request changed lifecycle state.",
+ "description": "A GitHub pull request changed lifecycle state.\n\nThe `github_pr_event` alias keeps rows and queue messages persisted\nbefore the rename deserializable.",
+ "required": ["content", "tag"],
+ "properties": {
+ "content": {
+ "$ref": "#/components/schemas/GithubPrStatusChanged",
+ "description": "A GitHub pull request changed lifecycle state.\n\nThe `github_pr_event` alias keeps rows and queue messages persisted\nbefore the rename deserializable."
+ },
+ "tag": {
+ "type": "string",
+ "enum": ["github_pr_status_changed"]
+ }
+ }
+ },
+ {
+ "type": "object",
+ "description": "The user's review was requested on a GitHub pull request.",
+ "required": ["content", "tag"],
+ "properties": {
+ "content": {
+ "$ref": "#/components/schemas/GithubReviewRequested",
+ "description": "The user's review was requested on a GitHub pull request."
+ },
+ "tag": {
+ "type": "string",
+ "enum": ["github_review_requested"]
+ }
+ }
+ },
+ {
+ "type": "object",
+ "description": "A GitHub pull request was commented on.",
+ "required": ["content", "tag"],
+ "properties": {
+ "content": {
+ "$ref": "#/components/schemas/GithubPrComment",
+ "description": "A GitHub pull request was commented on."
+ },
+ "tag": {
+ "type": "string",
+ "enum": ["github_pr_comment"]
+ }
+ }
+ },
+ {
+ "type": "object",
+ "description": "The user was mentioned on a GitHub pull request.",
+ "required": ["content", "tag"],
+ "properties": {
+ "content": {
+ "$ref": "#/components/schemas/GithubPrMention",
+ "description": "The user was mentioned on a GitHub pull request."
+ },
+ "tag": {
+ "type": "string",
+ "enum": ["github_pr_mention"]
+ }
+ }
+ },
+ {
+ "type": "object",
+ "description": "A review was submitted on the user's GitHub pull request.",
"required": ["content", "tag"],
"properties": {
"content": {
- "$ref": "#/components/schemas/GithubPrEvent",
- "description": "A GitHub pull request changed lifecycle state."
+ "$ref": "#/components/schemas/GithubPrReview",
+ "description": "A review was submitted on the user's GitHub pull request."
},
"tag": {
"type": "string",
- "enum": ["github_pr_event"]
+ "enum": ["github_pr_review"]
}
}
}
diff --git a/rust/cloud-storage/.sqlx/query-a58238d0cc05bf49e32ef051e805fe4d60036e280f59a7c9aefca86d1bf695fa.json b/rust/cloud-storage/.sqlx/query-a58238d0cc05bf49e32ef051e805fe4d60036e280f59a7c9aefca86d1bf695fa.json
new file mode 100644
index 0000000000..588cb01f26
--- /dev/null
+++ b/rust/cloud-storage/.sqlx/query-a58238d0cc05bf49e32ef051e805fe4d60036e280f59a7c9aefca86d1bf695fa.json
@@ -0,0 +1,28 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT LOWER(github_username) AS \"login!\", macro_id\n FROM github_links\n WHERE LOWER(github_username) = ANY($1::text[])\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "login!",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 1,
+ "name": "macro_id",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "TextArray"
+ ]
+ },
+ "nullable": [
+ null,
+ false
+ ]
+ },
+ "hash": "a58238d0cc05bf49e32ef051e805fe4d60036e280f59a7c9aefca86d1bf695fa"
+}
diff --git a/rust/cloud-storage/github/src/domain/models/mod.rs b/rust/cloud-storage/github/src/domain/models/mod.rs
index 08637b45ae..45c9d23d96 100644
--- a/rust/cloud-storage/github/src/domain/models/mod.rs
+++ b/rust/cloud-storage/github/src/domain/models/mod.rs
@@ -16,7 +16,7 @@ pub use pull_request::{
};
pub use sync::{
GithubAppInstallationSource, GithubInstallationAccessToken, GithubKey, GithubWebhookEventType,
- MacroTaskId, TeamTaskReference, ValidatedGithubWebhookEvent,
+ MacroTaskId, TeamTaskReference, ValidatedGithubWebhookEvent, extract_github_mentions,
};
/// Errors that can occur during github operations.
#[derive(Debug, thiserror::Error)]
diff --git a/rust/cloud-storage/github/src/domain/models/sync.rs b/rust/cloud-storage/github/src/domain/models/sync.rs
index 0da55454cb..bc7f7b2e2c 100644
--- a/rust/cloud-storage/github/src/domain/models/sync.rs
+++ b/rust/cloud-storage/github/src/domain/models/sync.rs
@@ -361,6 +361,28 @@ static TEAM_TASK_REFERENCE_RE: LazyLock<Regex> = LazyLock::new(|| {
.expect("valid regex")
});
+/// Regex matching GitHub `@login` mentions in markdown-ish text.
+///
+/// The leading guard requires the `@` to start the text or follow a
+/// non-login character, which also rejects email addresses (`[email protected]`).
+/// The login follows GitHub's username grammar: 1-39 alphanumerics or
+/// non-leading/non-trailing hyphens. Code spans are not treated specially.
+static GITHUB_MENTION_RE: LazyLock<Regex> = LazyLock::new(|| {
+ Regex::new(r"(?i)(?:^|[^a-z0-9-])@([a-z0-9](?:-?[a-z0-9]){0,38})").expect("valid regex")
+});
+
+/// Extract unique GitHub `@login` mentions from text, normalized to lowercase.
+///
+/// Results are sorted for determinism.
+pub fn extract_github_mentions(text: &str) -> Vec<String> {
+ let logins: std::collections::BTreeSet<String> = GITHUB_MENTION_RE
+ .captures_iter(text)
+ .map(|caps| caps[1].to_lowercase())
+ .collect();
+
+ logins.into_iter().collect()
+}
+
/// A team-scoped task reference in the form `{team_slug}-{team_task_id}`.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TeamTaskReference {
diff --git a/rust/cloud-storage/github/src/domain/models/test.rs b/rust/cloud-storage/github/src/domain/models/test.rs
index 3bef48ff45..53b62238ca 100644
--- a/rust/cloud-storage/github/src/domain/models/test.rs
+++ b/rust/cloud-storage/github/src/domain/models/test.rs
@@ -931,3 +931,33 @@ fn pr_context_empty_for_unknown_event() {
let event = ValidatedGithubWebhookEvent::new("ping".to_string(), payload);
assert!(event.extract_pr_context_text().is_empty());
}
+
+// ---------------------------------------------------------------------------
+// extract_github_mentions
+// ---------------------------------------------------------------------------
+
+#[test]
+fn github_mentions_extracts_unique_lowercased_logins() {
+ let mentions = extract_github_mentions(
+ "@Alice please review, cc @bob-smith and @alice again.\n@carol99: thoughts?",
+ );
+ assert_eq!(mentions, vec!["alice", "bob-smith", "carol99"]);
+}
+
+#[test]
+fn github_mentions_ignores_emails_and_bare_at_signs() {
+ let mentions = extract_github_mentions("contact me at [email protected] or @ (nothing)");
+ assert!(mentions.is_empty());
+}
+
+#[test]
+fn github_mentions_matches_at_start_and_after_punctuation() {
+ let mentions = extract_github_mentions("@lead-dev: see (@helper) and [@docs-team]");
+ assert_eq!(mentions, vec!["docs-team", "helper", "lead-dev"]);
+}
+
+#[test]
+fn github_mentions_does_not_capture_trailing_hyphen() {
+ let mentions = extract_github_mentions("ping @user- and @-nobody");
+ assert_eq!(mentions, vec!["user"]);
+}
diff --git a/rust/cloud-storage/github/src/domain/ports/sync.rs b/rust/cloud-storage/github/src/domain/ports/sync.rs
index 72be8b3ced..6defb0770b 100644
--- a/rust/cloud-storage/github/src/domain/ports/sync.rs
+++ b/rust/cloud-storage/github/src/domain/ports/sync.rs
@@ -58,6 +58,16 @@ pub trait GithubSyncRepo: Send + Sync + 'static {
github_user_id: &str,
) -> impl Future<Output = Result<Option<String>, Self::Err>> + Send;
+ /// Maps GitHub logins to the Macro user IDs linked to them via the `github_links` table.
+ ///
+ /// Logins are matched case-insensitively and returned lowercased. A login absent
+ /// from the result has no link; a login may map to multiple Macro users because
+ /// `github_links.github_username` is not unique.
+ fn get_macro_ids_by_github_logins(
+ &self,
+ github_logins: &[String],
+ ) -> impl Future<Output = Result<std::collections::HashMap<String, Vec<String>>, Self::Err>> + Send;
+
/// Returns all team IDs the given macro user belongs to.
fn get_user_team_ids(
&self,
diff --git a/rust/cloud-storage/github/src/domain/service/sync/mod.rs b/rust/cloud-storage/github/src/domain/service/sync/mod.rs
index 1fa688bef4..047fb1b6f3 100644
--- a/rust/cloud-storage/github/src/domain/service/sync/mod.rs
+++ b/rust/cloud-storage/github/src/domain/service/sync/mod.rs
@@ -7,6 +7,7 @@ mod handle_comment;
mod handle_installation;
mod handle_pr;
mod notify_pr;
+mod notify_pr_activity;
use crate::domain::{
models::{
@@ -833,6 +834,17 @@ impl<
if let Some((pull_request, upserts)) = &upsert_result {
self.notify_pr_status_transitions(webhook_event, pull_request, upserts)
.await;
+ match action {
+ Some("review_requested") => {
+ self.notify_review_requested(webhook_event, pull_request, upserts)
+ .await;
+ }
+ Some("opened" | "edited") => {
+ self.notify_pr_body_mentions(webhook_event, pull_request, upserts)
+ .await;
+ }
+ _ => {}
+ }
}
match action {
@@ -848,10 +860,30 @@ impl<
GithubWebhookEventType::IssueComment
| GithubWebhookEventType::PullRequestReview
| GithubWebhookEventType::PullRequestReviewComment => {
- if webhook_event.is_associated_with_pull_request() {
- let _ = self
+ if webhook_event.is_associated_with_pull_request()
+ && let Some((pull_request, upserts)) = self
.upsert_pull_request_foreign_entities(webhook_event)
- .await;
+ .await
+ {
+ match (webhook_event.parsed_event_type(), action) {
+ (
+ GithubWebhookEventType::IssueComment
+ | GithubWebhookEventType::PullRequestReviewComment,
+ Some("created"),
+ ) => {
+ self.notify_pr_comment_and_mentions(
+ webhook_event,
+ &pull_request,
+ &upserts,
+ )
+ .await;
+ }
+ (GithubWebhookEventType::PullRequestReview, Some("submitted")) => {
+ self.notify_pr_review(webhook_event, &pull_request, &upserts)
+ .await;
+ }
+ _ => {}
+ }
}
self.handle_comment_event(webhook_event).await
diff --git a/rust/cloud-storage/github/src/domain/service/sync/notify_pr.rs b/rust/cloud-storage/github/src/domain/service/sync/notify_pr.rs
index 467195143c..701065127e 100644
--- a/rust/cloud-storage/github/src/domain/service/sync/notify_pr.rs
+++ b/rust/cloud-storage/github/src/domain/service/sync/notify_pr.rs
@@ -7,8 +7,13 @@ use documents::domain::ports::DocumentService;
use foreign_entity::domain::ports::ForeignEntityService;
use macro_user_id::user_id::MacroUserIdStr;
use model_entity::EntityType;
-use model_notifications::{GithubPrEvent, GithubPrEventAction, GithubPrEventStatus};
-use notification::domain::{models::SendNotificationRequestBuilder, service::NotificationIngress};
+use model_notifications::{
+ GithubPrEventAction, GithubPrEventStatus, GithubPrNotificationCommon, GithubPrStatusChanged,
+};
+use notification::domain::{
+ models::{Notification, SendNotificationRequestBuilder},
+ service::NotificationIngress,
+};
use crate::domain::{
models::{
@@ -66,36 +71,60 @@ impl<
continue;
}
- let notification = Self::github_pr_event(
+ let notification = Self::github_pr_status_changed(
event,
pull_request,
upsert.foreign_entity_id,
action,
transition,
);
- let notification_entity =
- EntityType::ForeignEntity.with_entity_string(upsert.foreign_entity_id.to_string());
- let request = SendNotificationRequestBuilder {
- notification_entity,
+ self.send_github_notification(
notification,
- sender_id: sender_id.clone(),
+ upsert.foreign_entity_id,
+ sender_id.clone(),
recipient_ids,
- }
- .into_request()
- .with_conn_gateway();
+ )
+ .await;
+ }
+ }
- if let Err(error) = self.notification_ingress.send_notification(request).await {
- tracing::error!(
- error=?error,
- source_id=%upsert.source.source_id(),
- source_type=%upsert.source.source_type(),
- foreign_entity_id=%upsert.foreign_entity_id,
- "failed to send GitHub PR notification"
- );
- }
+ /// Send a GitHub pull request notification over the connection gateway,
+ /// logging (rather than propagating) delivery failures.
+ pub(super) async fn send_github_notification<T: Notification + Clone + 'static>(
+ &self,
+ notification: T,
+ foreign_entity_id: uuid::Uuid,
+ sender_id: Option<MacroUserIdStr<'static>>,
+ recipient_ids: HashSet<MacroUserIdStr<'static>>,
+ ) {
+ let notification_entity =
+ EntityType::ForeignEntity.with_entity_string(foreign_entity_id.to_string());
+ let request = SendNotificationRequestBuilder {
+ notification_entity,
+ notification,
+ sender_id,
+ recipient_ids,
+ }
+ .into_request()
+ .with_conn_gateway();
+
+ if let Err(error) = self.notification_ingress.send_notification(request).await {
+ tracing::error!(
+ error=?error,
+ notification_type=%T::TYPE_NAME,
+ foreign_entity_id=%foreign_entity_id,
+ "failed to send GitHub PR notification"
+ );
}
}
+ /// Whether the webhook event was triggered by a bot account (including the
+ /// Macro GitHub App itself, whose task-link comments echo back as
+ /// `issue_comment` webhooks).
+ pub(super) fn is_bot_sender(event: &ValidatedGithubWebhookEvent) -> bool {
+ Self::payload_string(&event.payload, &["sender", "type"]).as_deref() == Some("Bot")
+ }
+
fn status_transition(
upsert: &PullRequestForeignEntityUpsert,
) -> Option<PullRequestStatusTransition> {
@@ -110,7 +139,7 @@ impl<
})
}
- async fn notification_recipient_ids(
+ pub(super) async fn notification_recipient_ids(
&self,
source: &GithubAppInstallationSource,
) -> HashSet<MacroUserIdStr<'static>> {
@@ -146,7 +175,7 @@ impl<
}
}
- async fn notification_sender_id(
+ pub(super) async fn notification_sender_id(
&self,
event: &ValidatedGithubWebhookEvent,
) -> Option<MacroUserIdStr<'static>> {
@@ -182,14 +211,13 @@ impl<
}
}
- fn github_pr_event(
+ /// Build the metadata fields shared by every GitHub pull request notification type.
+ pub(super) fn github_pr_common(
event: &ValidatedGithubWebhookEvent,
pull_request: &EnrichedGithubPullRequest,
foreign_entity_id: uuid::Uuid,
- action: GithubPrEventAction,
- transition: PullRequestStatusTransition,
- ) -> GithubPrEvent {
- GithubPrEvent {
+ ) -> GithubPrNotificationCommon {
+ GithubPrNotificationCommon {
foreign_entity_id,
github_key: pull_request.github_key.clone(),
owner: pull_request.owner.clone(),
@@ -197,19 +225,31 @@ impl<
number: pull_request.number,
url: pull_request.url.clone(),
display_name: pull_request.display_name.clone(),
- title: GithubPrEvent::title_or_display_name(
+ title: GithubPrNotificationCommon::title_or_display_name(
pull_request.name.clone(),
&pull_request.display_name,
),
- status: Self::github_pr_event_status(transition.status),
- action,
- previous_status: transition.previous_status.map(Self::github_pr_event_status),
sender_github_login: Self::payload_string(&event.payload, &["sender", "login"]),
sender_github_user_id: event.sender_github_user_id(),
sender_github_avatar_url: Self::payload_string(
&event.payload,
&["sender", "avatar_url"],
),
+ }
+ }
+
+ fn github_pr_status_changed(
+ event: &ValidatedGithubWebhookEvent,
+ pull_request: &EnrichedGithubPullRequest,
+ foreign_entity_id: uuid::Uuid,
+ action: GithubPrEventAction,
+ transition: PullRequestStatusTransition,
+ ) -> GithubPrStatusChanged {
+ GithubPrStatusChanged {
+ common: Self::github_pr_common(event, pull_request, foreign_entity_id),
+ status: Self::github_pr_event_status(transition.status),
+ action,
+ previous_status: transition.previous_status.map(Self::github_pr_event_status),
head_branch: Self::payload_string(&event.payload, &["pull_request", "head", "ref"]),
base_branch: Self::payload_string(&event.payload, &["pull_request", "base", "ref"]),
merged_at: Self::pull_request_merged_at(event),
@@ -233,7 +273,7 @@ impl<
}
}
- fn payload_string(payload: &serde_json::Value, path: &[&str]) -> Option<String> {
+ pub(super) fn payload_string(payload: &serde_json::Value, path: &[&str]) -> Option<String> {
let mut value = payload;
for key in path {
value = value.get(*key)?;
diff --git a/rust/cloud-storage/github/src/domain/service/sync/notify_pr_activity.rs b/rust/cloud-storage/github/src/domain/service/sync/notify_pr_activity.rs
new file mode 100644
index 0000000000..0f70c7abae
--- /dev/null
+++ b/rust/cloud-storage/github/src/domain/service/sync/notify_pr_activity.rs
@@ -0,0 +1,482 @@
+//! GitHub pull request activity notification emitters: review requests,
+//! comments, mentions, and reviews.
+//!
+//! All emitters follow the same shape as `notify_pr_status_transitions`:
+//! one notification per installation-source upsert, errors logged rather
+//! than propagated, and targeted recipients intersected with the source's
+//! recipient set so users are only notified through installations they
+//! belong to.
+
+use std::collections::HashSet;
+
+use documents::domain::ports::DocumentService;
+use foreign_entity::domain::ports::ForeignEntityService;
+use macro_user_id::user_id::MacroUserIdStr;
+use model_notifications::{
+ GithubPrComment, GithubPrCommentKind, GithubPrMention, GithubPrMentionLocation,
+ GithubPrNotificationCommon, GithubPrReview, GithubPrReviewState, GithubReviewRequested,
+};
+use notification::domain::service::NotificationIngress;
+
+use crate::domain::{
+ models::{
+ EnrichedGithubPullRequest, GithubWebhookEventType, ValidatedGithubWebhookEvent,
+ extract_github_mentions,
+ },
+ ports::{GithubSyncClient, GithubSyncRepo},
+};
+
+use super::{GithubSyncServiceImpl, PullRequestForeignEntityUpsert};
+
+impl<
+ D: DocumentService,
+ R: GithubSyncRepo,
+ C: GithubSyncClient,
+ F: ForeignEntityService,
+ N: NotificationIngress,
+> GithubSyncServiceImpl<D, R, C, F, N>
+{
+ /// Notify the requested reviewer that their review was requested on a
+ /// pull request.
+ ///
+ /// Fires for `pull_request` events with action `review_requested`. The
+ /// notification goes only to the requested reviewer, and only through
+ /// sources whose recipients include them. Team review requests
+ /// (`requested_team`) and reviewers without a `github_links` mapping are
+ /// skipped.
+ pub(super) async fn notify_review_requested(
+ &self,
+ event: &ValidatedGithubWebhookEvent,
+ pull_request: &EnrichedGithubPullRequest,
+ upserts: &[PullRequestForeignEntityUpsert],
+ ) {
+ let Some(reviewer_github_user_id) = event
+ .payload
+ .get("requested_reviewer")
+ .and_then(|reviewer| reviewer.get("id"))
+ .and_then(|id| id.as_u64())
+ .map(|id| id.to_string())
+ else {
+ tracing::trace!(
+ "skipping review-requested notification without a requested_reviewer user"
+ );
+ return;
+ };
+
+ let reviewer_macro_id = match self
+ .repo
+ .get_macro_id_by_github_user_id(&reviewer_github_user_id)
+ .await
+ {
+ Ok(Some(macro_id)) => macro_id,
+ Ok(None) => {
+ tracing::trace!(
+ reviewer_github_user_id=%reviewer_github_user_id,
+ "skipping review-requested notification for unmapped reviewer"
+ );
+ return;
+ }
+ Err(error) => {
+ tracing::warn!(
+ error=?error,
+ reviewer_github_user_id=%reviewer_github_user_id,
+ "failed to map review-requested reviewer"
+ );
+ return;
+ }
+ };
+ let reviewer = match MacroUserIdStr::try_from(reviewer_macro_id.clone()) {
+ Ok(reviewer) => reviewer,
+ Err(error) => {
+ tracing::warn!(
+ error=?error,
+ macro_id=%reviewer_macro_id,
+ "review-requested reviewer mapping is not a valid Macro user ID"
+ );
+ return;
+ }
+ };
+
+ let reviewer_login = Self::payload_string(&event.payload, &["requested_reviewer", "login"]);
+ let sender_id = self.notification_sender_id(event).await;
+ for upsert in upserts {
+ let recipients = self.notification_recipient_ids(&upsert.source).await;
+ if !recipients.contains(&reviewer) {
+ tracing::trace!(
+ source_id=%upsert.source.source_id(),
+ source_type=%upsert.source.source_type(),
+ foreign_entity_id=%upsert.foreign_entity_id,
+ "skipping review-requested notification for reviewer outside source recipients"
+ );
+ continue;
+ }
+
+ let notification = GithubReviewRequested {
+ common: Self::github_pr_common(event, pull_request, upsert.foreign_entity_id),
+ requested_reviewer_github_login: reviewer_login.clone(),
+ requested_reviewer_github_user_id: Some(reviewer_github_user_id.clone()),
+ };
+ self.send_github_notification(
+ notification,
+ upsert.foreign_entity_id,
+ sender_id.clone(),
+ HashSet::from([reviewer.clone()]),
+ )
+ .await;
+ }
+ }
+
+ /// Notify recipients that a pull request was commented on, and notify
+ /// @mentioned users separately.
+ ///
+ /// Fires for `issue_comment` and `pull_request_review_comment` events with
+ /// action `created`. Mentioned users receive only the more specific
+ /// `github_pr_mention` notification; everyone else in the source receives
+ /// `github_pr_comment`. Bot-authored comments (including the Macro app's
+ /// own task-link comments) are skipped entirely.
+ pub(super) async fn notify_pr_comment_and_mentions(
+ &self,
+ event: &ValidatedGithubWebhookEvent,
+ pull_request: &EnrichedGithubPullRequest,
+ upserts: &[PullRequestForeignEntityUpsert],
+ ) {
+ if Self::is_bot_sender(event) {
+ tracing::trace!("skipping comment notification from bot sender");
+ return;
+ }
+
+ let body = Self::payload_string(&event.payload, &["comment", "body"]).unwrap_or_default();
+ let comment_github_id = event
+ .payload
+ .get("comment")
+ .and_then(|comment| comment.get("id"))
+ .and_then(|id| id.as_u64());
+ let comment_url = Self::payload_string(&event.payload, &["comment", "html_url"]);
+ let (comment_kind, mention_location) = match event.parsed_event_type() {
+ GithubWebhookEventType::PullRequestReviewComment => (
+ GithubPrCommentKind::ReviewComment,
+ GithubPrMentionLocation::ReviewComment,
+ ),
+ _ => (GithubPrCommentKind::Issue, GithubPrMentionLocation::Comment),
+ };
+
+ let mentioned_users = self.mentioned_macro_users(&body).await;
+ let snippet = GithubPrNotificationCommon::snippet(&body);
+ let sender_id = self.notification_sender_id(event).await;
+ for upsert in upserts {
+ let recipients = self.notification_recipient_ids(&upsert.source).await;
+
+ // Mention wins: mentioned users get only github_pr_mention.
+ let mention_recipients: HashSet<_> =
+ recipients.intersection(&mentioned_users).cloned().collect();
+ let comment_recipients: HashSet<_> = recipients
+ .difference(&mention_recipients)
+ .cloned()
+ .collect();
+
+ if !mention_recipients.is_empty() {
+ let notification = GithubPrMention {
+ common: Self::github_pr_common(event, pull_request, upsert.foreign_entity_id),
+ location: mention_location,
+ comment_github_id,
+ comment_url: comment_url.clone(),
+ text_snippet: snippet.clone(),
+ };
+ self.send_github_notification(
+ notification,
+ upsert.foreign_entity_id,
+ sender_id.clone(),
+ mention_recipients,
+ )
+ .await;
+ }
+
+ if !comment_recipients.is_empty() {
+ let notification = GithubPrComment {
+ common: Self::github_pr_common(event, pull_request, upsert.foreign_entity_id),
+ comment_kind,
+ comment_github_id,
+ comment_url: comment_url.clone(),
+ comment_snippet: snippet.clone(),
+ };
+ self.send_github_notification(
+ notification,
+ upsert.foreign_entity_id,
+ sender_id.clone(),
+ comment_recipients,
+ )
+ .await;
+ }
+ }
+ }
+
+ /// Notify the pull request author that a review was submitted, and notify
+ /// users @mentioned in the review body.
+ ///
+ /// Fires for `pull_request_review` events with action `submitted`. The
+ /// `github_pr_review` notification goes only to the PR author; mentioned
+ /// users receive `github_pr_mention` (the author gets only the review
+ /// notification when both apply). Bot reviews are skipped, as are empty
+ /// `commented` reviews, which GitHub also fires alongside every
+ /// `pull_request_review_comment` event.
+ pub(super) async fn notify_pr_review(
+ &self,
+ event: &ValidatedGithubWebhookEvent,
+ pull_request: &EnrichedGithubPullRequest,
+ upserts: &[PullRequestForeignEntityUpsert],
+ ) {
+ if Self::is_bot_sender(event) {
+ tracing::trace!("skipping review notification from bot sender");
+ return;
+ }
+
+ let state = Self::payload_string(&event.payload, &["review", "state"]).unwrap_or_default();
+ let body = Self::payload_string(&event.payload, &["review", "body"]).unwrap_or_default();
+ let state = match state.as_str() {
+ "approved" => GithubPrReviewState::Approved,
+ "changes_requested" => GithubPrReviewState::ChangesRequested,
+ "commented" if body.trim().is_empty() => {
+ // GitHub submits an empty "commented" review with every inline
+ // review comment; the comment itself already notifies.
+ tracing::trace!("skipping empty commented review");
+ return;
+ }
+ "commented" => GithubPrReviewState::Commented,
+ other => {
+ tracing::trace!(state=%other, "skipping review with unhandled state");
+ return;
+ }
+ };
+
+ let author = self.pull_request_author_macro_user(event).await;
+ let review_github_id = event
+ .payload
+ .get("review")
+ .and_then(|review| review.get("id"))
+ .and_then(|id| id.as_u64());
+ let review_url = Self::payload_string(&event.payload, &["review", "html_url"]);
+ let review_snippet =
+ (!body.trim().is_empty()).then(|| GithubPrNotificationCommon::snippet(&body));
+
+ let mentioned_users = self.mentioned_macro_users(&body).await;
+ let sender_id = self.notification_sender_id(event).await;
+ for upsert in upserts {
+ let recipients = self.notification_recipient_ids(&upsert.source).await;
+
+ let review_recipient = author
+ .as_ref()
+ .filter(|author| recipients.contains(*author))
+ .cloned();
+ if let Some(review_recipient) = &review_recipient {
+ let notification = GithubPrReview {
+ common: Self::github_pr_common(event, pull_request, upsert.foreign_entity_id),
+ review_github_id,
+ review_url: review_url.clone(),
+ state,
+ review_snippet: review_snippet.clone(),
+ };
+ self.send_github_notification(
+ notification,
+ upsert.foreign_entity_id,
+ sender_id.clone(),
+ HashSet::from([review_recipient.clone()]),
+ )
+ .await;
+ }
+
+ // Review wins for the author: drop them from the mention fan-out.
+ let mut mention_recipients: HashSet<_> =
+ recipients.intersection(&mentioned_users).cloned().collect();
+ if let Some(review_recipient) = &review_recipient {
+ mention_recipients.remove(review_recipient);
+ }
+ if !mention_recipients.is_empty() {
+ let notification = GithubPrMention {
+ common: Self::github_pr_common(event, pull_request, upsert.foreign_entity_id),
+ location: GithubPrMentionLocation::Review,
+ comment_github_id: review_github_id,
+ comment_url: review_url.clone(),
+ text_snippet: GithubPrNotificationCommon::snippet(&body),
+ };
+ self.send_github_notification(
+ notification,
+ upsert.foreign_entity_id,
+ sender_id.clone(),
+ mention_recipients,
+ )
+ .await;
+ }
+ }
+ }
+
+ /// Notify users @mentioned in a pull request description.
+ ///
+ /// Fires for `pull_request` events with actions `opened` and `edited`.
+ /// On `edited`, only mentions added relative to the previous body
+ /// (`changes.body.from`) are notified, so re-editing a description does
+ /// not re-notify existing mentions; an edit without a body change carries
+ /// no `changes.body.from` and notifies nobody. Bot-authored bodies are
+ /// skipped.
+ pub(super) async fn notify_pr_body_mentions(
+ &self,
+ event: &ValidatedGithubWebhookEvent,
+ pull_request: &EnrichedGithubPullRequest,
+ upserts: &[PullRequestForeignEntityUpsert],
+ ) {
+ if Self::is_bot_sender(event) {
+ tracing::trace!("skipping PR body mention notification from bot sender");
+ return;
+ }
+
+ let body =
+ Self::payload_string(&event.payload, &["pull_request", "body"]).unwrap_or_default();
+ let mut logins = extract_github_mentions(&body);
+ if event.action() == Some("edited") {
+ // Key presence matters: an absent `changes.body.from` means the body
+ // was not part of this edit, while a present-but-empty (or null) one
+ // means the description was previously blank and every current
+ // mention is new.
+ let Some(previous_body) = event
+ .payload
+ .get("changes")
+ .and_then(|changes| changes.get("body"))
+ .and_then(|body| body.get("from"))
+ .map(|from| from.as_str().unwrap_or_default())
+ else {
+ return;
+ };
+ let previous_logins: HashSet<String> =
+ extract_github_mentions(previous_body).into_iter().collect();
+ logins.retain(|login| !previous_logins.contains(login));
+ }
+ if logins.is_empty() {
+ return;
+ }
+
+ let mentioned_users = self.macro_users_for_logins(&logins).await;
+ if mentioned_users.is_empty() {
+ return;
+ }
+
+ let comment_url = Self::payload_string(&event.payload, &["pull_request", "html_url"]);
+ let snippet = GithubPrNotificationCommon::snippet(&body);
+ let sender_id = self.notification_sender_id(event).await;
+ for upsert in upserts {
+ let recipients = self.notification_recipient_ids(&upsert.source).await;
+ let mention_recipients: HashSet<_> =
+ recipients.intersection(&mentioned_users).cloned().collect();
+ if mention_recipients.is_empty() {
+ continue;
+ }
+
+ let notification = GithubPrMention {
+ common: Self::github_pr_common(event, pull_request, upsert.foreign_entity_id),
+ location: GithubPrMentionLocation::PrBody,
+ comment_github_id: None,
+ comment_url: comment_url.clone(),
+ text_snippet: snippet.clone(),
+ };
+ self.send_github_notification(
+ notification,
+ upsert.foreign_entity_id,
+ sender_id.clone(),
+ mention_recipients,
+ )
+ .await;
+ }
+ }
+
+ /// Resolve the pull request author from `pull_request.user.id` to a Macro
+ /// user via `github_links`. Returns `None` (with a trace) when unmapped.
+ async fn pull_request_author_macro_user(
+ &self,
+ event: &ValidatedGithubWebhookEvent,
+ ) -> Option<MacroUserIdStr<'static>> {
+ let author_github_user_id = event
+ .payload
+ .get("pull_request")
+ .and_then(|pull_request| pull_request.get("user"))
+ .and_then(|user| user.get("id"))
+ .and_then(|id| id.as_u64())
+ .map(|id| id.to_string())?;
+
+ let macro_id = match self
+ .repo
+ .get_macro_id_by_github_user_id(&author_github_user_id)
+ .await
+ {
+ Ok(Some(macro_id)) => macro_id,
+ Ok(None) => {
+ tracing::trace!(
+ author_github_user_id=%author_github_user_id,
+ "pull request author has no Macro mapping"
+ );
+ return None;
+ }
+ Err(error) => {
+ tracing::warn!(
+ error=?error,
+ author_github_user_id=%author_github_user_id,
+ "failed to map pull request author"
+ );
+ return None;
+ }
+ };
+
+ match MacroUserIdStr::try_from(macro_id.clone()) {
+ Ok(author) => Some(author),
+ Err(error) => {
+ tracing::warn!(
+ error=?error,
+ macro_id=%macro_id,
+ "pull request author mapping is not a valid Macro user ID"
+ );
+ None
+ }
+ }
+ }
+
+ /// Resolve the Macro users @mentioned in `text` via their `github_links`
+ /// login mappings. Unmapped logins and invalid Macro IDs are skipped.
+ async fn mentioned_macro_users(&self, text: &str) -> HashSet<MacroUserIdStr<'static>> {
+ self.macro_users_for_logins(&extract_github_mentions(text))
+ .await
+ }
+
+ /// Resolve GitHub logins to Macro users via their `github_links` login
+ /// mappings. Unmapped logins and invalid Macro IDs are skipped.
+ async fn macro_users_for_logins(&self, logins: &[String]) -> HashSet<MacroUserIdStr<'static>> {
+ if logins.is_empty() {
+ return HashSet::new();
+ }
+
+ let links = match self.repo.get_macro_ids_by_github_logins(logins).await {
+ Ok(links) => links,
+ Err(error) => {
+ tracing::warn!(
+ error=?error,
+ "failed to map GitHub mention logins to Macro users"
+ );
+ return HashSet::new();
+ }
+ };
+
+ links
+ .into_values()
+ .flatten()
+ .filter_map(
+ |macro_id| match MacroUserIdStr::try_from(macro_id.clone()) {
+ Ok(user_id) => Some(user_id),
+ Err(error) => {
+ tracing::warn!(
+ error=?error,
+ macro_id=%macro_id,
+ "GitHub mention mapping is not a valid Macro user ID"
+ );
+ None
+ }
+ },
+ )
+ .collect()
+ }
+}
diff --git a/rust/cloud-storage/github/src/domain/service/sync/test.rs b/rust/cloud-storage/github/src/domain/service/sync/test.rs
index 9c46d59869..8b4e9846d3 100644
--- a/rust/cloud-storage/github/src/domain/service/sync/test.rs
+++ b/rust/cloud-storage/github/src/domain/service/sync/test.rs
@@ -289,6 +289,8 @@ struct StubSyncRepo {
team_task_references: Mutex<HashMap<(String, String, i32), MacroTaskId>>,
/// Maps github_user_id -> macro_id for installation event lookups.
github_links: Mutex<HashMap<String, String>>,
+ /// Maps lowercase github login -> macro_ids for mention lookups.
+ github_login_links: Mutex<HashMap<String, Vec<String>>>,
/// Maps macro_id -> team_ids for installation event lookups.
user_teams: Mutex<HashMap<String, Vec<uuid::Uuid>>>,
/// Maps team_id -> Macro user IDs for notification recipient lookups.
@@ -305,6 +307,7 @@ impl StubSyncRepo {
tasks: Mutex::new(HashMap::new()),
team_task_references: Mutex::new(HashMap::new()),
github_links: Mutex::new(HashMap::new()),
+ github_login_links: Mutex::new(HashMap::new()),
user_teams: Mutex::new(HashMap::new()),
team_members: Mutex::new(HashMap::new()),
installation_source_rows: Mutex::new(HashMap::new()),
@@ -320,6 +323,16 @@ impl StubSyncRepo {
self
}
+ fn with_github_login_link(self, github_login: &str, macro_id: &str) -> Self {
+ self.github_login_links
+ .lock()
+ .unwrap()
+ .entry(github_login.to_lowercase())
+ .or_default()
+ .push(macro_id.to_string());
+ self
+ }
+
fn with_user_teams(self, macro_id: &str, team_ids: Vec<uuid::Uuid>) -> Self {
self.user_teams
.lock()
@@ -460,6 +473,21 @@ impl GithubSyncRepo for StubSyncRepo {
.cloned())
}
+ async fn get_macro_ids_by_github_logins(
+ &self,
+ github_logins: &[String],
+ ) -> Result<HashMap<String, Vec<String>>, Self::Err> {
+ let links = self.github_login_links.lock().unwrap();
+ Ok(github_logins
+ .iter()
+ .filter_map(|login| {
+ let login = login.to_lowercase();
+ let macro_ids = links.get(&login)?.clone();
+ Some((login, macro_ids))
+ })
+ .collect())
+ }
+
async fn get_user_team_ids(&self, macro_id: &str) -> Result<Vec<uuid::Uuid>, Self::Err> {
Ok(self
.user_teams
@@ -1021,11 +1049,18 @@ fn notification_request_recipients(request: &serde_json::Value) -> Vec<String> {
}
fn assert_github_pr_notification_realtime_enabled_apns_disabled(request: &serde_json::Value) {
+ assert_github_notification_realtime_enabled_apns_disabled(request, "github_pr_status_changed");
+}
+
+fn assert_github_notification_realtime_enabled_apns_disabled(
+ request: &serde_json::Value,
+ tag: &str,
+) {
assert_eq!(
request
.pointer("/req/notification/tag")
.and_then(|value| value.as_str()),
- Some("github_pr_event")
+ Some(tag)
);
assert_eq!(
request
@@ -1964,7 +1999,7 @@ async fn pr_opened_upserts_foreign_entity_for_user_installation_source() {
}
#[tokio::test]
-async fn github_pr_event_opened_team_source_notifies_team_members() {
+async fn github_pr_status_changed_opened_team_source_notifies_team_members() {
let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
let repo = StubSyncRepo::new()
.with_installation_sources("12345", vec![GithubAppInstallationSource::Team(team_id)])
@@ -2089,7 +2124,7 @@ async fn github_pr_event_opened_team_source_notifies_team_members() {
}
#[tokio::test]
-async fn github_pr_event_merged_user_source_notifies_user() {
+async fn github_pr_status_changed_merged_user_source_notifies_user() {
let repo = StubSyncRepo::new()
.with_installation_sources(
"12345",
@@ -2179,7 +2214,7 @@ async fn github_pr_event_merged_user_source_notifies_user() {
}
#[tokio::test]
-async fn github_pr_event_edited_does_not_notify() {
+async fn github_pr_status_changed_edited_does_not_notify() {
let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
let repo = StubSyncRepo::new()
.with_installation_sources("12345", vec![GithubAppInstallationSource::Team(team_id)])
@@ -2202,7 +2237,7 @@ async fn github_pr_event_edited_does_not_notify() {
}
#[tokio::test]
-async fn github_pr_event_installation_backfill_does_not_notify() {
+async fn github_pr_status_changed_installation_backfill_does_not_notify() {
let repo = StubSyncRepo::new().with_github_link("12345", "macro|[email protected]");
let service = make_sync_service_with_repo(repo);
service
@@ -2217,7 +2252,7 @@ async fn github_pr_event_installation_backfill_does_not_notify() {
}
#[tokio::test]
-async fn github_pr_event_unchanged_status_does_not_notify() {
+async fn github_pr_status_changed_unchanged_status_does_not_notify() {
let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
let repo = StubSyncRepo::new()
.with_installation_sources("12345", vec![GithubAppInstallationSource::Team(team_id)])
@@ -2242,7 +2277,7 @@ async fn github_pr_event_unchanged_status_does_not_notify() {
}
#[tokio::test]
-async fn github_pr_event_send_failure_does_not_fail_webhook_processing() {
+async fn github_pr_status_changed_send_failure_does_not_fail_webhook_processing() {
let repo = StubSyncRepo::new().with_installation_sources(
"12345",
vec![GithubAppInstallationSource::User(
@@ -3305,3 +3340,874 @@ async fn installation_deleted_is_skipped() {
assert!(service.repo.installation_sources().is_empty());
}
+
+// ---------------------------------------------------------------------------
+// notify_review_requested
+// ---------------------------------------------------------------------------
+
+fn notification_review_requested_event(
+ reviewer: Option<(u64, &str)>,
+ sender_id: u64,
+ sender_login: &str,
+) -> ValidatedGithubWebhookEvent {
+ let mut payload = serde_json::json!({
+ "action": "review_requested",
+ "pull_request": {
+ "number": 42,
+ "title": "Add GitHub notifications",
+ "body": null,
+ "head": { "ref": "feature/some-branch" },
+ "base": { "ref": "main" },
+ "state": "open",
+ "merged": false,
+ "merged_at": null,
+ "additions": 10,
+ "deletions": 2
+ },
+ "repository": {
+ "name": "my-repo",
+ "owner": { "login": "my-org" }
+ },
+ "installation": { "id": 12345 },
+ "sender": {
+ "login": sender_login,
+ "id": sender_id,
+ "avatar_url": format!("https://avatars.example/{sender_login}.png")
+ }
+ });
+ match reviewer {
+ Some((reviewer_id, reviewer_login)) => {
+ payload["requested_reviewer"] = serde_json::json!({
+ "id": reviewer_id,
+ "login": reviewer_login,
+ });
+ }
+ None => {
+ payload["requested_team"] = serde_json::json!({
+ "id": 9000,
+ "slug": "platform",
+ });
+ }
+ }
+
+ ValidatedGithubWebhookEvent::new("pull_request".to_string(), payload)
+}
+
+#[tokio::test]
+async fn review_requested_notifies_only_mapped_reviewer_in_team() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo = StubSyncRepo::new()
+ .with_installation_sources("12345", vec![GithubAppInstallationSource::Team(team_id)])
+ .with_team_members(
+ team_id,
+ vec![
+ ],
+ )
+ .with_github_link("222", "macro|[email protected]")
+ .with_github_link("333", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ let event = notification_review_requested_event(Some((333, "bob-gh")), 222, "octocat");
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ let foreign_entity_id = service.foreign_entity_service.foreign_entities()[0].id;
+ let requests = service.notification_ingress.requests();
+ assert_eq!(
+ requests.len(),
+ 1,
+ "expected only the review-requested notification"
+ );
+
+ let request = &requests[0];
+ assert_github_notification_realtime_enabled_apns_disabled(request, "github_review_requested");
+ assert_eq!(
+ notification_request_recipients(request),
+ vec!["macro|[email protected]".to_string()]
+ );
+ assert_eq!(
+ request
+ .pointer("/req/sender_id")
+ .and_then(|value| value.as_str()),
+ Some("macro|[email protected]")
+ );
+
+ let content = notification_request_content(request);
+ assert_eq!(
+ content
+ .get("foreignEntityId")
+ .and_then(|value| value.as_str()),
+ Some(foreign_entity_id.to_string().as_str())
+ );
+ assert_eq!(
+ content
+ .get("requestedReviewerGithubLogin")
+ .and_then(|value| value.as_str()),
+ Some("bob-gh")
+ );
+ assert_eq!(
+ content
+ .get("requestedReviewerGithubUserId")
+ .and_then(|value| value.as_str()),
+ Some("333")
+ );
+ assert_eq!(
+ content.get("displayName").and_then(|value| value.as_str()),
+ Some("my-org/my-repo#42")
+ );
+}
+
+#[tokio::test]
+async fn review_requested_unmapped_reviewer_does_not_notify() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo = StubSyncRepo::new()
+ .with_installation_sources("12345", vec![GithubAppInstallationSource::Team(team_id)])
+ .with_team_members(team_id, vec!["macro|[email protected]"]);
+ let service = make_sync_service_with_repo(repo);
+ let event = notification_review_requested_event(Some((999, "stranger")), 222, "octocat");
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ assert!(service.notification_ingress.requests().is_empty());
+}
+
+#[tokio::test]
+async fn review_requested_reviewer_outside_source_recipients_does_not_notify() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo = StubSyncRepo::new()
+ .with_installation_sources("12345", vec![GithubAppInstallationSource::Team(team_id)])
+ .with_team_members(team_id, vec!["macro|[email protected]"])
+ .with_github_link("333", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ let event = notification_review_requested_event(Some((333, "bob-gh")), 222, "octocat");
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ assert!(service.notification_ingress.requests().is_empty());
+}
+
+#[tokio::test]
+async fn review_requested_team_reviewer_does_not_notify() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo = StubSyncRepo::new()
+ .with_installation_sources("12345", vec![GithubAppInstallationSource::Team(team_id)])
+ .with_team_members(team_id, vec!["macro|[email protected]"]);
+ let service = make_sync_service_with_repo(repo);
+ let event = notification_review_requested_event(None, 222, "octocat");
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ assert!(service.notification_ingress.requests().is_empty());
+}
+
+#[tokio::test]
+async fn review_requested_user_source_notifies_installed_reviewer() {
+ let repo = StubSyncRepo::new()
+ .with_installation_sources(
+ "12345",
+ vec![GithubAppInstallationSource::User(
+ "macro|[email protected]".to_string(),
+ )],
+ )
+ .with_github_link("333", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ let event = notification_review_requested_event(Some((333, "solo-gh")), 222, "octocat");
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ let requests = service.notification_ingress.requests();
+ assert_eq!(requests.len(), 1);
+ assert_github_notification_realtime_enabled_apns_disabled(
+ &requests[0],
+ "github_review_requested",
+ );
+ assert_eq!(
+ notification_request_recipients(&requests[0]),
+ vec!["macro|[email protected]".to_string()]
+ );
+}
+
+// ---------------------------------------------------------------------------
+// notify_pr_comment_and_mentions
+// ---------------------------------------------------------------------------
+
+fn notification_comment_event(
+ event_type: &str,
+ action: &str,
+ comment_body: &str,
+ sender_login: &str,
+ sender_type: &str,
+) -> ValidatedGithubWebhookEvent {
+ let mut payload = serde_json::json!({
+ "action": action,
+ "comment": {
+ "id": 555,
+ "body": comment_body,
+ "html_url": "https://github.com/my-org/my-repo/pull/42#issuecomment-555"
+ },
+ "repository": {
+ "name": "my-repo",
+ "owner": { "login": "my-org" }
+ },
+ "installation": { "id": 12345 },
+ "sender": {
+ "login": sender_login,
+ "id": 222,
+ "type": sender_type,
+ "avatar_url": format!("https://avatars.example/{sender_login}.png")
+ }
+ });
+ if event_type == "issue_comment" {
+ payload["issue"] = serde_json::json!({
+ "number": 42,
+ "state": "open",
+ "pull_request": { "url": "https://api.github.com/repos/my-org/my-repo/pulls/42" }
+ });
+ } else {
+ payload["pull_request"] = serde_json::json!({
+ "number": 42,
+ "title": "Add GitHub notifications",
+ "state": "open",
+ "merged": false
+ });
+ }
+
+ ValidatedGithubWebhookEvent::new(event_type.to_string(), payload)
+}
+
+fn comment_team_repo(team_id: uuid::Uuid) -> StubSyncRepo {
+ StubSyncRepo::new()
+ .with_installation_sources("12345", vec![GithubAppInstallationSource::Team(team_id)])
+ .with_team_members(
+ team_id,
+ vec![
+ ],
+ )
+ .with_github_link("222", "macro|[email protected]")
+}
+
+fn requests_with_tag(requests: &[serde_json::Value], tag: &str) -> Vec<serde_json::Value> {
+ requests
+ .iter()
+ .filter(|request| {
+ request
+ .pointer("/req/notification/tag")
+ .and_then(|value| value.as_str())
+ == Some(tag)
+ })
+ .cloned()
+ .collect()
+}
+
+#[tokio::test]
+async fn issue_comment_notifies_team_without_mentions() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let service = make_sync_service_with_repo(comment_team_repo(team_id));
+ let event = notification_comment_event(
+ "issue_comment",
+ "created",
+ "Looks good overall",
+ "octocat",
+ "User",
+ );
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ let requests = service.notification_ingress.requests();
+ assert_eq!(requests.len(), 1);
+
+ let request = &requests[0];
+ assert_github_notification_realtime_enabled_apns_disabled(request, "github_pr_comment");
+ assert_eq!(
+ notification_request_recipients(request),
+ vec![
+ "macro|[email protected]".to_string(),
+ "macro|[email protected]".to_string(),
+ "macro|[email protected]".to_string(),
+ ]
+ );
+
+ let content = notification_request_content(request);
+ assert_eq!(
+ content.get("commentKind").and_then(|value| value.as_str()),
+ Some("issue")
+ );
+ assert_eq!(
+ content
+ .get("commentSnippet")
+ .and_then(|value| value.as_str()),
+ Some("Looks good overall")
+ );
+ assert_eq!(
+ content
+ .get("commentGithubId")
+ .and_then(|value| value.as_u64()),
+ Some(555)
+ );
+ assert_eq!(
+ content.get("commentUrl").and_then(|value| value.as_str()),
+ Some("https://github.com/my-org/my-repo/pull/42#issuecomment-555")
+ );
+ assert_eq!(
+ content.get("displayName").and_then(|value| value.as_str()),
+ Some("my-org/my-repo#42")
+ );
+}
+
+#[tokio::test]
+async fn issue_comment_mentioned_member_gets_mention_not_comment() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo = comment_team_repo(team_id).with_github_login_link("bob-gh", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ let event = notification_comment_event(
+ "issue_comment",
+ "created",
+ "@bob-gh can you take a look?",
+ "octocat",
+ "User",
+ );
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ let requests = service.notification_ingress.requests();
+ assert_eq!(requests.len(), 2);
+
+ let mentions = requests_with_tag(&requests, "github_pr_mention");
+ assert_eq!(mentions.len(), 1);
+ assert_eq!(
+ notification_request_recipients(&mentions[0]),
+ vec!["macro|[email protected]".to_string()]
+ );
+ let mention_content = notification_request_content(&mentions[0]);
+ assert_eq!(
+ mention_content
+ .get("location")
+ .and_then(|value| value.as_str()),
+ Some("comment")
+ );
+ assert_eq!(
+ mention_content
+ .get("textSnippet")
+ .and_then(|value| value.as_str()),
+ Some("@bob-gh can you take a look?")
+ );
+
+ let comments = requests_with_tag(&requests, "github_pr_comment");
+ assert_eq!(comments.len(), 1);
+ assert_eq!(
+ notification_request_recipients(&comments[0]),
+ vec![
+ "macro|[email protected]".to_string(),
+ "macro|[email protected]".to_string(),
+ ]
+ );
+}
+
+#[tokio::test]
+async fn review_comment_uses_review_comment_kind_and_location() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo = comment_team_repo(team_id).with_github_login_link("bob-gh", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ let event = notification_comment_event(
+ "pull_request_review_comment",
+ "created",
+ "@bob-gh this line is wrong",
+ "octocat",
+ "User",
+ );
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ let requests = service.notification_ingress.requests();
+ let mentions = requests_with_tag(&requests, "github_pr_mention");
+ let comments = requests_with_tag(&requests, "github_pr_comment");
+ assert_eq!(mentions.len(), 1);
+ assert_eq!(comments.len(), 1);
+ assert_eq!(
+ notification_request_content(&mentions[0])
+ .get("location")
+ .and_then(|value| value.as_str()),
+ Some("review_comment")
+ );
+ assert_eq!(
+ notification_request_content(&comments[0])
+ .get("commentKind")
+ .and_then(|value| value.as_str()),
+ Some("review_comment")
+ );
+}
+
+#[tokio::test]
+async fn bot_comment_does_not_notify() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let service = make_sync_service_with_repo(comment_team_repo(team_id));
+ let event = notification_comment_event(
+ "issue_comment",
+ "created",
+ "Linked task: MACRO-abc123",
+ "macro-app[bot]",
+ "Bot",
+ );
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ assert!(service.notification_ingress.requests().is_empty());
+}
+
+#[tokio::test]
+async fn edited_comment_does_not_notify() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let service = make_sync_service_with_repo(comment_team_repo(team_id));
+ let event = notification_comment_event(
+ "issue_comment",
+ "edited",
+ "Looks good overall (edited)",
+ "octocat",
+ "User",
+ );
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ assert!(service.notification_ingress.requests().is_empty());
+}
+
+#[tokio::test]
+async fn mention_of_unlinked_login_falls_back_to_comment_for_all() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let service = make_sync_service_with_repo(comment_team_repo(team_id));
+ let event = notification_comment_event(
+ "issue_comment",
+ "created",
+ "@stranger can you take a look?",
+ "octocat",
+ "User",
+ );
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ let requests = service.notification_ingress.requests();
+ assert_eq!(requests.len(), 1);
+ assert_github_notification_realtime_enabled_apns_disabled(&requests[0], "github_pr_comment");
+ assert_eq!(notification_request_recipients(&requests[0]).len(), 3);
+}
+
+#[tokio::test]
+async fn mention_login_linked_to_multiple_users_notifies_all_in_team() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo = comment_team_repo(team_id)
+ .with_github_login_link("shared-gh", "macro|[email protected]")
+ .with_github_login_link("shared-gh", "macro|[email protected]")
+ .with_github_login_link("shared-gh", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ let event = notification_comment_event(
+ "issue_comment",
+ "created",
+ "@Shared-GH ping",
+ "octocat",
+ "User",
+ );
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ let requests = service.notification_ingress.requests();
+ let mentions = requests_with_tag(&requests, "github_pr_mention");
+ let comments = requests_with_tag(&requests, "github_pr_comment");
+ assert_eq!(mentions.len(), 1);
+ assert_eq!(
+ notification_request_recipients(&mentions[0]),
+ vec![
+ "macro|[email protected]".to_string(),
+ "macro|[email protected]".to_string(),
+ ]
+ );
+ assert_eq!(comments.len(), 1);
+ assert_eq!(
+ notification_request_recipients(&comments[0]),
+ vec!["macro|[email protected]".to_string()]
+ );
+}
+
+// ---------------------------------------------------------------------------
+// notify_pr_review
+// ---------------------------------------------------------------------------
+
+fn notification_review_event(
+ action: &str,
+ state: &str,
+ body: Option<&str>,
+ author_github_id: u64,
+ sender_login: &str,
+ sender_type: &str,
+) -> ValidatedGithubWebhookEvent {
+ ValidatedGithubWebhookEvent::new(
+ "pull_request_review".to_string(),
+ serde_json::json!({
+ "action": action,
+ "review": {
+ "id": 888,
+ "state": state,
+ "body": body,
+ "html_url": "https://github.com/my-org/my-repo/pull/42#pullrequestreview-888"
+ },
+ "pull_request": {
+ "number": 42,
+ "title": "Add GitHub notifications",
+ "state": "open",
+ "merged": false,
+ "user": { "id": author_github_id, "login": "pr-author" }
+ },
+ "repository": {
+ "name": "my-repo",
+ "owner": { "login": "my-org" }
+ },
+ "installation": { "id": 12345 },
+ "sender": {
+ "login": sender_login,
+ "id": 222,
+ "type": sender_type,
+ "avatar_url": format!("https://avatars.example/{sender_login}.png")
+ }
+ }),
+ )
+}
+
+#[tokio::test]
+async fn approved_review_notifies_author_only() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo = comment_team_repo(team_id).with_github_link("444", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ let event = notification_review_event("submitted", "approved", None, 444, "octocat", "User");
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ let requests = service.notification_ingress.requests();
+ assert_eq!(requests.len(), 1);
+
+ let request = &requests[0];
+ assert_github_notification_realtime_enabled_apns_disabled(request, "github_pr_review");
+ assert_eq!(
+ notification_request_recipients(request),
+ vec!["macro|[email protected]".to_string()]
+ );
+ assert_eq!(
+ request
+ .pointer("/req/sender_id")
+ .and_then(|value| value.as_str()),
+ Some("macro|[email protected]")
+ );
+
+ let content = notification_request_content(request);
+ assert_eq!(
+ content.get("state").and_then(|value| value.as_str()),
+ Some("approved")
+ );
+ assert_eq!(
+ content
+ .get("reviewGithubId")
+ .and_then(|value| value.as_u64()),
+ Some(888)
+ );
+ assert_eq!(
+ content.get("reviewUrl").and_then(|value| value.as_str()),
+ Some("https://github.com/my-org/my-repo/pull/42#pullrequestreview-888")
+ );
+ assert!(content.get("reviewSnippet").unwrap().is_null());
+}
+
+#[tokio::test]
+async fn changes_requested_review_carries_snippet() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo = comment_team_repo(team_id).with_github_link("444", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ let event = notification_review_event(
+ "submitted",
+ "changes_requested",
+ Some("Please add tests"),
+ 444,
+ "octocat",
+ "User",
+ );
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ let requests = service.notification_ingress.requests();
+ assert_eq!(requests.len(), 1);
+ let content = notification_request_content(&requests[0]);
+ assert_eq!(
+ content.get("state").and_then(|value| value.as_str()),
+ Some("changes_requested")
+ );
+ assert_eq!(
+ content
+ .get("reviewSnippet")
+ .and_then(|value| value.as_str()),
+ Some("Please add tests")
+ );
+}
+
+#[tokio::test]
+async fn unmapped_author_review_still_notifies_mentions() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo =
+ comment_team_repo(team_id).with_github_login_link("carol-gh", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ let event = notification_review_event(
+ "submitted",
+ "approved",
+ Some("@carol-gh should double-check the migration"),
+ 999,
+ "octocat",
+ "User",
+ );
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ let requests = service.notification_ingress.requests();
+ assert_eq!(requests.len(), 1);
+ assert_github_notification_realtime_enabled_apns_disabled(&requests[0], "github_pr_mention");
+ assert_eq!(
+ notification_request_recipients(&requests[0]),
+ vec!["macro|[email protected]".to_string()]
+ );
+ let content = notification_request_content(&requests[0]);
+ assert_eq!(
+ content.get("location").and_then(|value| value.as_str()),
+ Some("review")
+ );
+}
+
+#[tokio::test]
+async fn empty_commented_review_does_not_notify() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo = comment_team_repo(team_id).with_github_link("444", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ let event = notification_review_event("submitted", "commented", None, 444, "octocat", "User");
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ assert!(service.notification_ingress.requests().is_empty());
+}
+
+#[tokio::test]
+async fn author_mentioned_in_review_gets_review_only() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo = comment_team_repo(team_id)
+ .with_github_link("444", "macro|[email protected]")
+ .with_github_login_link("bob-gh", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ let event = notification_review_event(
+ "submitted",
+ "commented",
+ Some("@bob-gh nice work overall"),
+ 444,
+ "octocat",
+ "User",
+ );
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ let requests = service.notification_ingress.requests();
+ assert_eq!(requests.len(), 1);
+ assert_github_notification_realtime_enabled_apns_disabled(&requests[0], "github_pr_review");
+ assert_eq!(
+ notification_request_recipients(&requests[0]),
+ vec!["macro|[email protected]".to_string()]
+ );
+}
+
+#[tokio::test]
+async fn bot_review_does_not_notify() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo = comment_team_repo(team_id).with_github_link("444", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ let event =
+ notification_review_event("submitted", "approved", None, 444, "review-bot[bot]", "Bot");
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ assert!(service.notification_ingress.requests().is_empty());
+}
+
+#[tokio::test]
+async fn dismissed_review_action_does_not_notify() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo = comment_team_repo(team_id).with_github_link("444", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ let event = notification_review_event("dismissed", "dismissed", None, 444, "octocat", "User");
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ assert!(service.notification_ingress.requests().is_empty());
+}
+
+// ---------------------------------------------------------------------------
+// notify_pr_body_mentions
+// ---------------------------------------------------------------------------
+
+fn notification_pr_body_event(
+ action: &str,
+ body: Option<&str>,
+ previous_body: Option<&str>,
+ sender_type: &str,
+) -> ValidatedGithubWebhookEvent {
+ let mut payload = serde_json::json!({
+ "action": action,
+ "pull_request": {
+ "number": 42,
+ "title": "Add GitHub notifications",
+ "body": body,
+ "html_url": "https://github.com/my-org/my-repo/pull/42",
+ "head": { "ref": "feature/some-branch" },
+ "base": { "ref": "main" },
+ "state": "open",
+ "merged": false
+ },
+ "repository": {
+ "name": "my-repo",
+ "owner": { "login": "my-org" }
+ },
+ "installation": { "id": 12345 },
+ "sender": {
+ "login": "octocat",
+ "id": 222,
+ "type": sender_type,
+ "avatar_url": "https://avatars.example/octocat.png"
+ }
+ });
+ if let Some(previous_body) = previous_body {
+ payload["changes"] = serde_json::json!({ "body": { "from": previous_body } });
+ }
+
+ ValidatedGithubWebhookEvent::new("pull_request".to_string(), payload)
+}
+
+#[tokio::test]
+async fn opened_pr_body_mention_notifies_mentioned_member() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo = comment_team_repo(team_id).with_github_login_link("bob-gh", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ let event = notification_pr_body_event(
+ "opened",
+ Some("Implements the thing. @bob-gh please review the approach."),
+ None,
+ "User",
+ );
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ let requests = service.notification_ingress.requests();
+ assert_eq!(requests.len(), 2, "expected status-changed and mention");
+ assert_eq!(
+ requests_with_tag(&requests, "github_pr_status_changed").len(),
+ 1
+ );
+
+ let mentions = requests_with_tag(&requests, "github_pr_mention");
+ assert_eq!(mentions.len(), 1);
+ assert_eq!(
+ notification_request_recipients(&mentions[0]),
+ vec!["macro|[email protected]".to_string()]
+ );
+ let content = notification_request_content(&mentions[0]);
+ assert_eq!(
+ content.get("location").and_then(|value| value.as_str()),
+ Some("pr_body")
+ );
+ assert!(content.get("commentGithubId").unwrap().is_null());
+ assert_eq!(
+ content.get("commentUrl").and_then(|value| value.as_str()),
+ Some("https://github.com/my-org/my-repo/pull/42")
+ );
+}
+
+#[tokio::test]
+async fn edited_pr_body_notifies_only_newly_added_mentions() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo = comment_team_repo(team_id)
+ .with_github_login_link("bob-gh", "macro|[email protected]")
+ .with_github_login_link("carol-gh", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ let event = notification_pr_body_event(
+ "edited",
+ Some("cc @bob-gh and now also @carol-gh"),
+ Some("cc @bob-gh"),
+ "User",
+ );
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ let requests = service.notification_ingress.requests();
+ assert_eq!(requests.len(), 1);
+ assert_github_notification_realtime_enabled_apns_disabled(&requests[0], "github_pr_mention");
+ assert_eq!(
+ notification_request_recipients(&requests[0]),
+ vec!["macro|[email protected]".to_string()]
+ );
+}
+
+#[tokio::test]
+async fn edited_pr_body_with_unchanged_mentions_does_not_notify() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo = comment_team_repo(team_id).with_github_login_link("bob-gh", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ let event = notification_pr_body_event(
+ "edited",
+ Some("cc @bob-gh (reworded description)"),
+ Some("cc @bob-gh"),
+ "User",
+ );
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ assert!(service.notification_ingress.requests().is_empty());
+}
+
+#[tokio::test]
+async fn edited_pr_without_body_change_does_not_notify() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo = comment_team_repo(team_id).with_github_login_link("bob-gh", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ // Title-only edit: no changes.body.from in the payload.
+ let event = notification_pr_body_event("edited", Some("cc @bob-gh"), None, "User");
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ assert!(service.notification_ingress.requests().is_empty());
+}
+
+#[tokio::test]
+async fn edited_pr_with_previously_blank_body_notifies_new_mentions() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo = comment_team_repo(team_id).with_github_login_link("bob-gh", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ // The PR had no description; the edit adds one containing a mention.
+ let event = notification_pr_body_event("edited", Some("cc @bob-gh"), Some(""), "User");
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ let requests = service.notification_ingress.requests();
+ assert_eq!(requests.len(), 1);
+ assert_github_notification_realtime_enabled_apns_disabled(&requests[0], "github_pr_mention");
+ assert_eq!(
+ notification_request_recipients(&requests[0]),
+ vec!["macro|[email protected]".to_string()]
+ );
+}
+
+#[tokio::test]
+async fn bot_opened_pr_body_mention_does_not_notify_mention() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo = comment_team_repo(team_id).with_github_login_link("bob-gh", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ let event = notification_pr_body_event("opened", Some("automated PR cc @bob-gh"), None, "Bot");
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ let requests = service.notification_ingress.requests();
+ assert!(requests_with_tag(&requests, "github_pr_mention").is_empty());
+}
diff --git a/rust/cloud-storage/github/src/outbound/pg_github_sync_repo.rs b/rust/cloud-storage/github/src/outbound/pg_github_sync_repo.rs
index 1e88465648..922fe623f7 100644
--- a/rust/cloud-storage/github/src/outbound/pg_github_sync_repo.rs
+++ b/rust/cloud-storage/github/src/outbound/pg_github_sync_repo.rs
@@ -178,6 +178,39 @@ impl GithubSyncRepo for PgGithubSyncRepo {
Ok(macro_id)
}
+ #[tracing::instrument(skip(self), err)]
+ async fn get_macro_ids_by_github_logins(
+ &self,
+ github_logins: &[String],
+ ) -> Result<std::collections::HashMap<String, Vec<String>>, Self::Err> {
+ if github_logins.is_empty() {
+ return Ok(std::collections::HashMap::new());
+ }
+
+ let lowercased: Vec<String> = github_logins
+ .iter()
+ .map(|login| login.to_lowercase())
+ .collect();
+ let rows = sqlx::query!(
+ r#"
+ SELECT LOWER(github_username) AS "login!", macro_id
+ FROM github_links
+ WHERE LOWER(github_username) = ANY($1::text[])
+ "#,
+ &lowercased,
+ )
+ .fetch_all(&self.pool)
+ .await?;
+
+ let mut links: std::collections::HashMap<String, Vec<String>> =
+ std::collections::HashMap::new();
+ for row in rows {
+ links.entry(row.login).or_default().push(row.macro_id);
+ }
+
+ Ok(links)
+ }
+
#[tracing::instrument(skip(self), err)]
async fn get_user_team_ids(&self, macro_id: &str) -> Result<Vec<uuid::Uuid>, Self::Err> {
let team_ids = sqlx::query_scalar!(
diff --git a/rust/cloud-storage/github/src/outbound/pg_github_sync_repo/test.rs b/rust/cloud-storage/github/src/outbound/pg_github_sync_repo/test.rs
index 55d869976b..4a8c125e07 100644
--- a/rust/cloud-storage/github/src/outbound/pg_github_sync_repo/test.rs
+++ b/rust/cloud-storage/github/src/outbound/pg_github_sync_repo/test.rs
@@ -324,6 +324,62 @@ async fn test_get_macro_id_by_github_user_id_not_found(pool: Pool<Postgres>) {
assert!(macro_id.is_none());
}
+// ---------------------------------------------------------------------------
+// get_macro_ids_by_github_logins
+// ---------------------------------------------------------------------------
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("github_installation_test_data"))
+)]
+async fn test_get_macro_ids_by_github_logins_matches_case_insensitively(pool: Pool<Postgres>) {
+ // A second link sharing the 'testuser' login (github_username is not unique).
+ sqlx::query!(
+ r#"
+ INSERT INTO github_links (id, macro_id, fusionauth_user_id, github_username, github_user_id)
+ VALUES ('11111111-2222-3333-4444-555555555555'::uuid, 'macro|[email protected]', 'cccccccc-cccc-cccc-cccc-cccccccccccc'::uuid, 'TestUser', '54321')
+ "#
+ )
+ .execute(&pool)
+ .await
+ .unwrap();
+ let repo = PgGithubSyncRepo::new(pool);
+
+ let links = repo
+ .get_macro_ids_by_github_logins(&[
+ "TESTUSER".to_string(),
+ "solo".to_string(),
+ "unlinked".to_string(),
+ ])
+ .await
+ .unwrap();
+
+ assert_eq!(links.len(), 2);
+ let mut testuser_ids = links.get("testuser").cloned().unwrap_or_default();
+ testuser_ids.sort();
+ assert_eq!(
+ testuser_ids,
+ vec![
+ "macro|[email protected]".to_string(),
+ "macro|[email protected]".to_string()
+ ]
+ );
+ assert_eq!(
+ links.get("solo"),
+ Some(&vec!["macro|[email protected]".to_string()])
+ );
+ assert!(!links.contains_key("unlinked"));
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn test_get_macro_ids_by_github_logins_empty_input(pool: Pool<Postgres>) {
+ let repo = PgGithubSyncRepo::new(pool);
+
+ let links = repo.get_macro_ids_by_github_logins(&[]).await.unwrap();
+
+ assert!(links.is_empty());
+}
+
// ---------------------------------------------------------------------------
// get_user_team_ids
// ---------------------------------------------------------------------------
diff --git a/rust/cloud-storage/macro_db_client/migrations/20260612123918_rename_github_pr_event_notification_type.sql b/rust/cloud-storage/macro_db_client/migrations/20260612123918_rename_github_pr_event_notification_type.sql
new file mode 100644
index 0000000000..f29c776db2
--- /dev/null
+++ b/rust/cloud-storage/macro_db_client/migrations/20260612123918_rename_github_pr_event_notification_type.sql
@@ -0,0 +1,10 @@
+-- The github_pr_event notification type was renamed to github_pr_status_changed.
+-- Rewrite persisted rows so stored notifications and per-type preferences keep
+-- working under the new tag.
+UPDATE notification
+SET notification_event_type = 'github_pr_status_changed'
+WHERE notification_event_type = 'github_pr_event';
+
+UPDATE user_notification_type_preference
+SET notification_event_type = 'github_pr_status_changed'
+WHERE notification_event_type = 'github_pr_event';
diff --git a/rust/cloud-storage/model_notifications/src/lib.rs b/rust/cloud-storage/model_notifications/src/lib.rs
index 52dbdc6ee2..51f338470d 100644
--- a/rust/cloud-storage/model_notifications/src/lib.rs
+++ b/rust/cloud-storage/model_notifications/src/lib.rs
@@ -12,7 +12,9 @@ pub use device::DeviceType;
pub use metadata::{
AiResponseMetadata, ChannelInviteMetadata, ChannelMentionMetadata, ChannelMessageSendMetadata,
ChannelReplyMetadata, ChannelType, CommentedOnDocumentMetadata, CommonChannelMetadata,
- DocumentMentionMetadata, GithubPrEvent, GithubPrEventAction, GithubPrEventStatus,
+ DocumentMentionMetadata, GithubPrComment, GithubPrCommentKind, GithubPrEventAction,
+ GithubPrEventStatus, GithubPrMention, GithubPrMentionLocation, GithubPrNotificationCommon,
+ GithubPrReview, GithubPrReviewState, GithubPrStatusChanged, GithubReviewRequested,
InviteToTeamMetadata, ItemSharedMetadata, MentionedInDocumentCommentMetadata, NewEmailMetadata,
NotificationDocumentSubType, NotificationTitle, RepliedToDocumentCommentThreadMetadata,
TaskAssignedMetadata,
@@ -203,7 +205,23 @@ define_notif_event!(
AiResponse(AiResponseMetadata),
/// A GitHub pull request changed lifecycle state.
- GithubPrEvent(GithubPrEvent),
+ ///
+ /// The `github_pr_event` alias keeps rows and queue messages persisted
+ /// before the rename deserializable.
+ #[serde(alias = "github_pr_event")]
+ GithubPrStatusChanged(GithubPrStatusChanged),
+
+ /// The user's review was requested on a GitHub pull request.
+ GithubReviewRequested(GithubReviewRequested),
+
+ /// A GitHub pull request was commented on.
+ GithubPrComment(GithubPrComment),
+
+ /// The user was mentioned on a GitHub pull request.
+ GithubPrMention(GithubPrMention),
+
+ /// A review was submitted on the user's GitHub pull request.
+ GithubPrReview(GithubPrReview),
}
);
@@ -239,7 +257,21 @@ impl NotificationTitle for NotifEvent {
NotifEvent::AiResponse(ai_response_metadata) => {
ai_response_metadata.format_title(sender_id)
}
- NotifEvent::GithubPrEvent(github_pr_event) => github_pr_event.format_title(sender_id),
+ NotifEvent::GithubPrStatusChanged(github_pr_status_changed) => {
+ github_pr_status_changed.format_title(sender_id)
+ }
+ NotifEvent::GithubReviewRequested(github_review_requested) => {
+ github_review_requested.format_title(sender_id)
+ }
+ NotifEvent::GithubPrComment(github_pr_comment) => {
+ github_pr_comment.format_title(sender_id)
+ }
+ NotifEvent::GithubPrMention(github_pr_mention) => {
+ github_pr_mention.format_title(sender_id)
+ }
+ NotifEvent::GithubPrReview(github_pr_review) => {
+ github_pr_review.format_title(sender_id)
+ }
}
}
@@ -274,7 +306,19 @@ impl NotificationTitle for NotifEvent {
NotifEvent::AiResponse(ai_response_metadata) => {
ai_response_metadata.format_body(sender_id)
}
- NotifEvent::GithubPrEvent(github_pr_event) => github_pr_event.format_body(sender_id),
+ NotifEvent::GithubPrStatusChanged(github_pr_status_changed) => {
+ github_pr_status_changed.format_body(sender_id)
+ }
+ NotifEvent::GithubReviewRequested(github_review_requested) => {
+ github_review_requested.format_body(sender_id)
+ }
+ NotifEvent::GithubPrComment(github_pr_comment) => {
+ github_pr_comment.format_body(sender_id)
+ }
+ NotifEvent::GithubPrMention(github_pr_mention) => {
+ github_pr_mention.format_body(sender_id)
+ }
+ NotifEvent::GithubPrReview(github_pr_review) => github_pr_review.format_body(sender_id),
}
}
}
diff --git a/rust/cloud-storage/model_notifications/src/metadata.rs b/rust/cloud-storage/model_notifications/src/metadata.rs
index 29de0743d2..833f80f69a 100644
--- a/rust/cloud-storage/model_notifications/src/metadata.rs
+++ b/rust/cloud-storage/model_notifications/src/metadata.rs
@@ -51,10 +51,16 @@ pub enum GithubPrEventAction {
Closed,
}
-/// Metadata for a GitHub pull request lifecycle notification.
+/// The maximum number of characters kept by [`GithubPrNotificationCommon::snippet`].
+const GITHUB_SNIPPET_MAX_CHARS: usize = 280;
+
+/// Fields shared by every GitHub pull request notification type.
+///
+/// Embedded with `#[serde(flatten)]` so the wire shape keeps these keys at the
+/// top level of the metadata object.
#[derive(Debug, Clone, PartialEq, Eq, ToSchema, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
-pub struct GithubPrEvent {
+pub struct GithubPrNotificationCommon {
/// The source-specific internal foreign entity row id for this pull request.
pub foreign_entity_id: Uuid,
/// The external GitHub key, in `owner/repo/pull/number` format.
@@ -71,27 +77,15 @@ pub struct GithubPrEvent {
pub display_name: String,
/// The GitHub pull request title. Falls back to `display_name` when GitHub has no title.
pub title: String,
- /// The current normalized pull request status.
- pub status: GithubPrEventStatus,
- /// The webhook action that triggered this notification.
- pub action: GithubPrEventAction,
- /// The prior normalized pull request status, when known.
- pub previous_status: Option<GithubPrEventStatus>,
/// The GitHub login for the sender, when available.
pub sender_github_login: Option<String>,
/// The stable GitHub numeric user id for the sender, serialized as a string.
pub sender_github_user_id: Option<String>,
/// The GitHub avatar URL for the sender, when available.
pub sender_github_avatar_url: Option<String>,
- /// The pull request head branch, when available.
- pub head_branch: Option<String>,
- /// The pull request base branch, when available.
- pub base_branch: Option<String>,
- /// When the pull request was merged, when available.
- pub merged_at: Option<DateTime<Utc>>,
}
-impl GithubPrEvent {
+impl GithubPrNotificationCommon {
/// Build a required title value, falling back to the display name when GitHub has no title.
pub fn title_or_display_name(title: Option<String>, display_name: &str) -> String {
match title {
@@ -100,6 +94,68 @@ impl GithubPrEvent {
}
}
+ /// Trim and truncate free-form GitHub text (comment or review bodies) to a
+ /// display-friendly snippet, keeping character boundaries intact.
+ pub fn snippet(text: &str) -> String {
+ let trimmed = text.trim();
+ if trimmed.chars().count() <= GITHUB_SNIPPET_MAX_CHARS {
+ return trimmed.to_string();
+ }
+
+ let mut snippet: String = trimmed.chars().take(GITHUB_SNIPPET_MAX_CHARS).collect();
+ snippet.push('…');
+ snippet
+ }
+
+ fn actor_name(&self, sender_id: Option<MacroUserIdStr<'_>>) -> Option<String> {
+ sender_id
+ .map(|sender| sender.email_part().local_part().to_string())
+ .or_else(|| self.sender_github_login.clone())
+ }
+
+ /// The shared body format: the compact PR label, plus the PR title when it
+ /// adds information beyond the label.
+ fn format_body(&self) -> String {
+ if self.title == self.display_name {
+ return self.display_name.clone();
+ }
+
+ format!("{}: {}", self.display_name, self.title)
+ }
+
+ /// The shared body format with free-form text (a comment or review
+ /// snippet) in place of the PR title, when any is present.
+ fn format_body_with_text(&self, text: &str) -> String {
+ if text.trim().is_empty() {
+ return self.format_body();
+ }
+
+ format!("{}: {}", self.display_name, text.trim())
+ }
+}
+
+/// Metadata for a GitHub pull request lifecycle notification.
+#[derive(Debug, Clone, PartialEq, Eq, ToSchema, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct GithubPrStatusChanged {
+ /// Fields shared with the other GitHub pull request notifications.
+ #[serde(flatten)]
+ pub common: GithubPrNotificationCommon,
+ /// The current normalized pull request status.
+ pub status: GithubPrEventStatus,
+ /// The webhook action that triggered this notification.
+ pub action: GithubPrEventAction,
+ /// The prior normalized pull request status, when known.
+ pub previous_status: Option<GithubPrEventStatus>,
+ /// The pull request head branch, when available.
+ pub head_branch: Option<String>,
+ /// The pull request base branch, when available.
+ pub base_branch: Option<String>,
+ /// When the pull request was merged, when available.
+ pub merged_at: Option<DateTime<Utc>>,
+}
+
+impl GithubPrStatusChanged {
fn action_verb(&self) -> &'static str {
if self.status == GithubPrEventStatus::Merged {
return "merged";
@@ -111,25 +167,19 @@ impl GithubPrEvent {
GithubPrEventAction::Closed => "closed",
}
}
-
- fn actor_name(&self, sender_id: Option<MacroUserIdStr<'_>>) -> Option<String> {
- sender_id
- .map(|sender| sender.email_part().local_part().to_string())
- .or_else(|| self.sender_github_login.clone())
- }
}
-impl Notification for GithubPrEvent {
- const TYPE_NAME: &'static str = "github_pr_event";
+impl Notification for GithubPrStatusChanged {
+ const TYPE_NAME: &'static str = "github_pr_status_changed";
}
-impl NotificationTitle for GithubPrEvent {
+impl NotificationTitle for GithubPrStatusChanged {
fn format_title(
&self,
sender_id: Option<MacroUserIdStr<'_>>,
) -> Result<String, rootcause::Report> {
let verb = self.action_verb();
- let title = match self.actor_name(sender_id) {
+ let title = match self.common.actor_name(sender_id) {
Some(actor) => format!("{actor} {verb} a pull request"),
None => format!("Pull request {verb}"),
};
@@ -141,11 +191,222 @@ impl NotificationTitle for GithubPrEvent {
&self,
_sender_id: Option<MacroUserIdStr<'_>>,
) -> Result<String, rootcause::Report> {
- if self.title == self.display_name {
- return Ok(self.display_name.clone());
- }
+ Ok(self.common.format_body())
+ }
+}
+
+/// Metadata for a notification that the user's review was requested on a GitHub pull request.
+#[derive(Debug, Clone, PartialEq, Eq, ToSchema, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct GithubReviewRequested {
+ /// Fields shared with the other GitHub pull request notifications.
+ #[serde(flatten)]
+ pub common: GithubPrNotificationCommon,
+ /// The GitHub login of the requested reviewer, when available.
+ pub requested_reviewer_github_login: Option<String>,
+ /// The stable GitHub numeric user id of the requested reviewer, serialized as a string.
+ pub requested_reviewer_github_user_id: Option<String>,
+}
+
+impl Notification for GithubReviewRequested {
+ const TYPE_NAME: &'static str = "github_review_requested";
+}
+
+impl NotificationTitle for GithubReviewRequested {
+ fn format_title(
+ &self,
+ sender_id: Option<MacroUserIdStr<'_>>,
+ ) -> Result<String, rootcause::Report> {
+ let title = match self.common.actor_name(sender_id) {
+ Some(actor) => format!("{actor} requested your review"),
+ None => "Your review was requested".to_string(),
+ };
+
+ Ok(title)
+ }
+
+ fn format_body(
+ &self,
+ _sender_id: Option<MacroUserIdStr<'_>>,
+ ) -> Result<String, rootcause::Report> {
+ Ok(self.common.format_body())
+ }
+}
+
+/// The kind of GitHub comment that triggered a [`GithubPrComment`] notification.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, ToSchema, Serialize, Deserialize)]
+#[serde(rename_all = "snake_case")]
+pub enum GithubPrCommentKind {
+ /// A top-level conversation comment (GitHub `issue_comment`).
+ Issue,
+ /// An inline code review comment (GitHub `pull_request_review_comment`).
+ ReviewComment,
+}
+
+/// Metadata for a notification that a GitHub pull request was commented on.
+#[derive(Debug, Clone, PartialEq, Eq, ToSchema, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct GithubPrComment {
+ /// Fields shared with the other GitHub pull request notifications.
+ #[serde(flatten)]
+ pub common: GithubPrNotificationCommon,
+ /// The kind of comment that was posted.
+ pub comment_kind: GithubPrCommentKind,
+ /// The GitHub numeric id of the comment, when available.
+ pub comment_github_id: Option<u64>,
+ /// The public GitHub URL for the comment, when available.
+ pub comment_url: Option<String>,
+ /// A truncated excerpt of the comment body.
+ pub comment_snippet: String,
+}
+
+impl Notification for GithubPrComment {
+ const TYPE_NAME: &'static str = "github_pr_comment";
+}
+
+impl NotificationTitle for GithubPrComment {
+ fn format_title(
+ &self,
+ sender_id: Option<MacroUserIdStr<'_>>,
+ ) -> Result<String, rootcause::Report> {
+ let title = match self.common.actor_name(sender_id) {
+ Some(actor) => format!("{actor} commented on a pull request"),
+ None => "New comment on a pull request".to_string(),
+ };
+
+ Ok(title)
+ }
+
+ fn format_body(
+ &self,
+ _sender_id: Option<MacroUserIdStr<'_>>,
+ ) -> Result<String, rootcause::Report> {
+ Ok(self.common.format_body_with_text(&self.comment_snippet))
+ }
+}
+
+/// Where in a GitHub pull request the user was mentioned.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, ToSchema, Serialize, Deserialize)]
+#[serde(rename_all = "snake_case")]
+pub enum GithubPrMentionLocation {
+ /// The pull request description.
+ PrBody,
+ /// A top-level conversation comment.
+ Comment,
+ /// A review summary body.
+ Review,
+ /// An inline code review comment.
+ ReviewComment,
+}
+
+/// Metadata for a notification that the user was mentioned on a GitHub pull request.
+#[derive(Debug, Clone, PartialEq, Eq, ToSchema, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct GithubPrMention {
+ /// Fields shared with the other GitHub pull request notifications.
+ #[serde(flatten)]
+ pub common: GithubPrNotificationCommon,
+ /// Where the mention appeared.
+ pub location: GithubPrMentionLocation,
+ /// The GitHub numeric id of the comment or review containing the mention, when available.
+ pub comment_github_id: Option<u64>,
+ /// The public GitHub URL for the text containing the mention, when available.
+ pub comment_url: Option<String>,
+ /// A truncated excerpt of the text containing the mention.
+ pub text_snippet: String,
+}
+
+impl Notification for GithubPrMention {
+ const TYPE_NAME: &'static str = "github_pr_mention";
+}
+
+impl NotificationTitle for GithubPrMention {
+ fn format_title(
+ &self,
+ sender_id: Option<MacroUserIdStr<'_>>,
+ ) -> Result<String, rootcause::Report> {
+ let title = match self.common.actor_name(sender_id) {
+ Some(actor) => format!("{actor} mentioned you on a pull request"),
+ None => "You were mentioned on a pull request".to_string(),
+ };
- Ok(format!("{}: {}", self.display_name, self.title))
+ Ok(title)
+ }
+
+ fn format_body(
+ &self,
+ _sender_id: Option<MacroUserIdStr<'_>>,
+ ) -> Result<String, rootcause::Report> {
+ Ok(self.common.format_body_with_text(&self.text_snippet))
+ }
+}
+
+/// The state of a submitted GitHub pull request review.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, ToSchema, Serialize, Deserialize)]
+#[serde(rename_all = "snake_case")]
+pub enum GithubPrReviewState {
+ /// The reviewer approved the pull request.
+ Approved,
+ /// The reviewer requested changes.
+ ChangesRequested,
+ /// The reviewer left a comment review without an approval decision.
+ Commented,
+}
+
+/// Metadata for a notification that a review was submitted on the user's GitHub pull request.
+#[derive(Debug, Clone, PartialEq, Eq, ToSchema, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct GithubPrReview {
+ /// Fields shared with the other GitHub pull request notifications.
+ #[serde(flatten)]
+ pub common: GithubPrNotificationCommon,
+ /// The GitHub numeric id of the review, when available.
+ pub review_github_id: Option<u64>,
+ /// The public GitHub URL for the review, when available.
+ pub review_url: Option<String>,
+ /// The review decision state.
+ pub state: GithubPrReviewState,
+ /// A truncated excerpt of the review body, when any was written.
+ pub review_snippet: Option<String>,
+}
+
+impl Notification for GithubPrReview {
+ const TYPE_NAME: &'static str = "github_pr_review";
+}
+
+impl NotificationTitle for GithubPrReview {
+ fn format_title(
+ &self,
+ sender_id: Option<MacroUserIdStr<'_>>,
+ ) -> Result<String, rootcause::Report> {
+ let actor = self.common.actor_name(sender_id);
+ let title = match (self.state, actor) {
+ (GithubPrReviewState::Approved, Some(actor)) => {
+ format!("{actor} approved your pull request")
+ }
+ (GithubPrReviewState::Approved, None) => "Your pull request was approved".to_string(),
+ (GithubPrReviewState::ChangesRequested, Some(actor)) => {
+ format!("{actor} requested changes on your pull request")
+ }
+ (GithubPrReviewState::ChangesRequested, None) => {
+ "Changes were requested on your pull request".to_string()
+ }
+ (GithubPrReviewState::Commented, Some(actor)) => {
+ format!("{actor} reviewed your pull request")
+ }
+ (GithubPrReviewState::Commented, None) => "Your pull request was reviewed".to_string(),
+ };
+
+ Ok(title)
+ }
+
+ fn format_body(
+ &self,
+ _sender_id: Option<MacroUserIdStr<'_>>,
+ ) -> Result<String, rootcause::Report> {
+ Ok(self
+ .common
+ .format_body_with_text(self.review_snippet.as_deref().unwrap_or_default()))
}
}
diff --git a/rust/cloud-storage/model_notifications/src/metadata/test.rs b/rust/cloud-storage/model_notifications/src/metadata/test.rs
index 95b2ff2a5c..f67ee8d79b 100644
--- a/rust/cloud-storage/model_notifications/src/metadata/test.rs
+++ b/rust/cloud-storage/model_notifications/src/metadata/test.rs
@@ -10,8 +10,8 @@ fn utc_datetime(value: &str) -> DateTime<Utc> {
.with_timezone(&Utc)
}
-fn github_pr_event() -> GithubPrEvent {
- GithubPrEvent {
+fn github_pr_common() -> GithubPrNotificationCommon {
+ GithubPrNotificationCommon {
foreign_entity_id: Uuid::parse_str("11111111-1111-4111-8111-111111111111").unwrap(),
github_key: "macro/app/pull/42".to_string(),
owner: "macro".to_string(),
@@ -20,14 +20,20 @@ fn github_pr_event() -> GithubPrEvent {
url: "https://github.com/macro/app/pull/42".to_string(),
display_name: "macro/app#42".to_string(),
title: "Add GitHub PR notifications".to_string(),
- status: GithubPrEventStatus::Merged,
- action: GithubPrEventAction::Closed,
- previous_status: Some(GithubPrEventStatus::Open),
sender_github_login: Some("octocat".to_string()),
sender_github_user_id: Some("12345".to_string()),
sender_github_avatar_url: Some(
"https://avatars.githubusercontent.com/u/12345?v=4".to_string(),
),
+ }
+}
+
+fn github_pr_status_changed() -> GithubPrStatusChanged {
+ GithubPrStatusChanged {
+ common: github_pr_common(),
+ status: GithubPrEventStatus::Merged,
+ action: GithubPrEventAction::Closed,
+ previous_status: Some(GithubPrEventStatus::Open),
head_branch: Some("feature/github-pr-notifications".to_string()),
base_branch: Some("main".to_string()),
merged_at: Some(utc_datetime("2026-05-25T18:54:21Z")),
@@ -35,8 +41,8 @@ fn github_pr_event() -> GithubPrEvent {
}
#[test]
-fn github_pr_event_serializes_with_camel_case_fields_and_lowercase_enums() {
- let event = github_pr_event();
+fn github_pr_status_changed_serializes_with_camel_case_fields_and_lowercase_enums() {
+ let event = github_pr_status_changed();
let value = serde_json::to_value(&event).unwrap();
@@ -65,14 +71,14 @@ fn github_pr_event_serializes_with_camel_case_fields_and_lowercase_enums() {
}
#[test]
-fn github_pr_event_tagged_content_serializes_with_type_name() {
- let event = github_pr_event();
- let foreign_entity_id = event.foreign_entity_id.to_string();
+fn github_pr_status_changed_tagged_content_serializes_with_type_name() {
+ let event = github_pr_status_changed();
+ let foreign_entity_id = event.common.foreign_entity_id.to_string();
let value =
serde_json::to_value(notification::domain::models::TaggedContent::new(event)).unwrap();
- assert_eq!(value["tag"], "github_pr_event");
+ assert_eq!(value["tag"], "github_pr_status_changed");
assert_eq!(
value["content"]["foreignEntityId"],
serde_json::json!(foreign_entity_id)
@@ -80,8 +86,8 @@ fn github_pr_event_tagged_content_serializes_with_type_name() {
}
#[test]
-fn github_pr_event_formats_title_and_body() {
- let event = github_pr_event();
+fn github_pr_status_changed_formats_title_and_body() {
+ let event = github_pr_status_changed();
let title = event
.format_title(Some(uid("macro|[email protected]")))
@@ -93,34 +99,35 @@ fn github_pr_event_formats_title_and_body() {
}
#[test]
-fn github_pr_event_title_falls_back_to_display_name() {
+fn github_pr_status_changed_title_falls_back_to_display_name() {
assert_eq!(
- GithubPrEvent::title_or_display_name(None, "macro/app#42"),
+ GithubPrNotificationCommon::title_or_display_name(None, "macro/app#42"),
"macro/app#42"
);
assert_eq!(
- GithubPrEvent::title_or_display_name(Some(String::new()), "macro/app#42"),
+ GithubPrNotificationCommon::title_or_display_name(Some(String::new()), "macro/app#42"),
"macro/app#42"
);
assert_eq!(
- GithubPrEvent::title_or_display_name(
+ GithubPrNotificationCommon::title_or_display_name(
Some("Add GitHub PR notifications".to_string()),
"macro/app#42"
),
"Add GitHub PR notifications"
);
- let mut event = github_pr_event();
- event.title = GithubPrEvent::title_or_display_name(None, &event.display_name);
+ let mut event = github_pr_status_changed();
+ event.common.title =
+ GithubPrNotificationCommon::title_or_display_name(None, &event.common.display_name);
assert_eq!(event.format_body(None).unwrap(), "macro/app#42");
}
#[test]
-fn github_pr_event_notif_event_deserializes_and_renders_in_app() {
- let expected = github_pr_event();
+fn github_pr_status_changed_notif_event_deserializes_and_renders_in_app() {
+ let expected = github_pr_status_changed();
let value = serde_json::json!({
- "tag": "github_pr_event",
+ "tag": "github_pr_status_changed",
"content": serde_json::to_value(&expected).unwrap(),
});
@@ -137,12 +144,198 @@ fn github_pr_event_notif_event_deserializes_and_renders_in_app() {
"macro/app#42: Add GitHub PR notifications"
);
- let crate::NotifEvent::GithubPrEvent(actual) = event else {
- panic!("expected github_pr_event variant");
+ let crate::NotifEvent::GithubPrStatusChanged(actual) = event else {
+ panic!("expected github_pr_status_changed variant");
};
assert_eq!(actual, expected);
}
+#[test]
+fn github_pr_status_changed_deserializes_from_legacy_github_pr_event_tag() {
+ let expected = github_pr_status_changed();
+ let value = serde_json::json!({
+ "tag": "github_pr_event",
+ "content": serde_json::to_value(&expected).unwrap(),
+ });
+
+ let event: crate::NotifEvent = serde_json::from_value(value).unwrap();
+
+ let crate::NotifEvent::GithubPrStatusChanged(actual) = event else {
+ panic!("expected github_pr_status_changed variant");
+ };
+ assert_eq!(actual, expected);
+}
+
+#[test]
+fn github_review_requested_serializes_flat_and_formats() {
+ let notification = GithubReviewRequested {
+ common: github_pr_common(),
+ requested_reviewer_github_login: Some("hubot".to_string()),
+ requested_reviewer_github_user_id: Some("67890".to_string()),
+ };
+
+ let value = serde_json::to_value(&notification).unwrap();
+ // The flattened common fields stay at the top level of the wire shape.
+ assert_eq!(value["githubKey"], "macro/app/pull/42");
+ assert_eq!(value["requestedReviewerGithubLogin"], "hubot");
+
+ let tagged = serde_json::to_value(notification::domain::models::TaggedContent::new(
+ notification,
+ ))
+ .unwrap();
+ assert_eq!(tagged["tag"], "github_review_requested");
+
+ let notification: GithubReviewRequested =
+ serde_json::from_value(tagged["content"].clone()).unwrap();
+ assert_eq!(
+ notification
+ .format_title(Some(uid("macro|[email protected]")))
+ .unwrap(),
+ "pr.sender requested your review"
+ );
+ assert_eq!(
+ notification.format_title(None).unwrap(),
+ "octocat requested your review"
+ );
+ assert_eq!(
+ notification.format_body(None).unwrap(),
+ "macro/app#42: Add GitHub PR notifications"
+ );
+}
+
+#[test]
+fn github_pr_comment_serializes_and_formats_with_snippet() {
+ let notification = GithubPrComment {
+ common: github_pr_common(),
+ comment_kind: GithubPrCommentKind::Issue,
+ comment_github_id: Some(555),
+ comment_url: Some("https://github.com/macro/app/pull/42#issuecomment-555".to_string()),
+ comment_snippet: "Looks good overall".to_string(),
+ };
+
+ let value = serde_json::to_value(&notification).unwrap();
+ assert_eq!(value["commentKind"], "issue");
+ assert_eq!(value["displayName"], "macro/app#42");
+
+ assert_eq!(
+ serde_json::to_value(notification::domain::models::TaggedContent::new(
+ notification.clone()
+ ))
+ .unwrap()["tag"],
+ "github_pr_comment"
+ );
+ assert_eq!(
+ notification
+ .format_title(Some(uid("macro|[email protected]")))
+ .unwrap(),
+ "pr.sender commented on a pull request"
+ );
+ assert_eq!(
+ notification.format_body(None).unwrap(),
+ "macro/app#42: Looks good overall"
+ );
+
+ let empty_snippet = GithubPrComment {
+ comment_snippet: String::new(),
+ ..notification
+ };
+ assert_eq!(
+ empty_snippet.format_body(None).unwrap(),
+ "macro/app#42: Add GitHub PR notifications"
+ );
+}
+
+#[test]
+fn github_pr_mention_serializes_and_formats() {
+ let notification = GithubPrMention {
+ common: github_pr_common(),
+ location: GithubPrMentionLocation::ReviewComment,
+ comment_github_id: Some(777),
+ comment_url: Some("https://github.com/macro/app/pull/42#discussion_r777".to_string()),
+ text_snippet: "@dev.user can you take a look?".to_string(),
+ };
+
+ let value = serde_json::to_value(&notification).unwrap();
+ assert_eq!(value["location"], "review_comment");
+
+ assert_eq!(
+ serde_json::to_value(notification::domain::models::TaggedContent::new(
+ notification.clone()
+ ))
+ .unwrap()["tag"],
+ "github_pr_mention"
+ );
+ assert_eq!(
+ notification
+ .format_title(Some(uid("macro|[email protected]")))
+ .unwrap(),
+ "pr.sender mentioned you on a pull request"
+ );
+ assert_eq!(
+ notification.format_body(None).unwrap(),
+ "macro/app#42: @dev.user can you take a look?"
+ );
+}
+
+#[test]
+fn github_pr_review_serializes_and_formats_by_state() {
+ let notification = GithubPrReview {
+ common: github_pr_common(),
+ review_github_id: Some(888),
+ review_url: Some("https://github.com/macro/app/pull/42#pullrequestreview-888".to_string()),
+ state: GithubPrReviewState::ChangesRequested,
+ review_snippet: Some("Please add tests".to_string()),
+ };
+
+ let value = serde_json::to_value(&notification).unwrap();
+ assert_eq!(value["state"], "changes_requested");
+
+ assert_eq!(
+ serde_json::to_value(notification::domain::models::TaggedContent::new(
+ notification.clone()
+ ))
+ .unwrap()["tag"],
+ "github_pr_review"
+ );
+ assert_eq!(
+ notification
+ .format_title(Some(uid("macro|[email protected]")))
+ .unwrap(),
+ "pr.sender requested changes on your pull request"
+ );
+ assert_eq!(
+ notification.format_body(None).unwrap(),
+ "macro/app#42: Please add tests"
+ );
+
+ let approved = GithubPrReview {
+ state: GithubPrReviewState::Approved,
+ review_snippet: None,
+ ..notification
+ };
+ assert_eq!(
+ approved.format_title(None).unwrap(),
+ "octocat approved your pull request"
+ );
+ assert_eq!(
+ approved.format_body(None).unwrap(),
+ "macro/app#42: Add GitHub PR notifications"
+ );
+}
+
+#[test]
+fn github_snippet_trims_and_truncates_on_char_boundary() {
+ assert_eq!(
+ GithubPrNotificationCommon::snippet(" hello world "),
+ "hello world"
+ );
+
+ let long = "é".repeat(400);
+ let snippet = GithubPrNotificationCommon::snippet(&long);
+ assert_eq!(snippet.chars().count(), 281);
+ assert!(snippet.ends_with('…'));
+}
+
#[test]
fn channel_reply_title_uses_reply_sender_from_metadata() {
let notification = ChannelReplyMetadata {
diff --git a/rust/cloud-storage/notification/src/outbound/repository.rs b/rust/cloud-storage/notification/src/outbound/repository.rs
index 3847d28fa7..0d9625495d 100644
--- a/rust/cloud-storage/notification/src/outbound/repository.rs
+++ b/rust/cloud-storage/notification/src/outbound/repository.rs
@@ -129,6 +129,11 @@ fn push_notification_status_filters(
}
}
+/// SQL fragment matching every GitHub notification event type. Keep in sync with
+/// the `Notification::TYPE_NAME`s of the GitHub metadata types in `model_notifications`
+/// (this crate sits below `model_notifications`, so it cannot reference them directly).
+const GITHUB_EVENT_TYPES_SQL: &str = "n.notification_event_type IN ('github_pr_status_changed', 'github_review_requested', 'github_pr_comment', 'github_pr_mention', 'github_pr_review')";
+
fn push_include_types_filter(builder: &mut QueryBuilder<'_, Postgres>, include_types: &[String]) {
if !include_types.is_empty() {
builder.push(" AND (");
@@ -170,7 +175,7 @@ fn push_include_types_filter(builder: &mut QueryBuilder<'_, Postgres>, include_t
include_types
.iter()
.any(|t| t == "github")
- .then_some("n.notification_event_type = 'github_pr_event'"),
+ .then_some(GITHUB_EVENT_TYPES_SQL),
]
.into_iter()
.flatten()
@@ -219,7 +224,9 @@ fn push_entities_filter<'a>(builder: &mut QueryBuilder<'a, Postgres>, entity_tok
builder.push_bind(entity_tokens);
builder.push(")) OR ");
- builder.push("(n.event_item_type = 'foreign_entity' AND n.notification_event_type = 'github_pr_event' AND 'github:' || n.event_item_id = ANY(");
+ builder.push("(n.event_item_type = 'foreign_entity' AND ");
+ builder.push(GITHUB_EVENT_TYPES_SQL);
+ builder.push(" AND 'github:' || n.event_item_id = ANY(");
builder.push_bind(entity_tokens);
builder.push(")) OR ");
diff --git a/rust/cloud-storage/notification/src/outbound/repository/test.rs b/rust/cloud-storage/notification/src/outbound/repository/test.rs
index 0604abd966..ea8eeacc22 100644
--- a/rust/cloud-storage/notification/src/outbound/repository/test.rs
+++ b/rust/cloud-storage/notification/src/outbound/repository/test.rs
@@ -26,7 +26,7 @@ struct TestGithubNotification {
}
impl Notification for TestGithubNotification {
- const TYPE_NAME: &'static str = "github_pr_event";
+ const TYPE_NAME: &'static str = "github_pr_status_changed";
}
fn test_user(email: &str) -> MacroUserIdStr<'static> {
@@ -537,7 +537,7 @@ async fn test_get_user_notifications_filters_github_type_and_entity(pool: Pool<P
);
assert_eq!(
github_type_results[0].notification_event_type,
- "github_pr_event"
+ "github_pr_status_changed"
);
assert_eq!(
github_type_results[0].entity.entity_type,
diff --git a/rust/cloud-storage/notification_service/src/api/swagger.rs b/rust/cloud-storage/notification_service/src/api/swagger.rs
index aa5ca0bf79..21f755f2c7 100644
--- a/rust/cloud-storage/notification_service/src/api/swagger.rs
+++ b/rust/cloud-storage/notification_service/src/api/swagger.rs
@@ -8,7 +8,9 @@ use model::{
use model_notifications::{
ChannelInviteMetadata, ChannelMentionMetadata, ChannelMessageSendMetadata,
ChannelReplyMetadata, CommentedOnDocumentMetadata, CommonChannelMetadata, DeviceType,
- DocumentMentionMetadata, GithubPrEvent, GithubPrEventAction, GithubPrEventStatus,
+ DocumentMentionMetadata, GithubPrComment, GithubPrCommentKind, GithubPrEventAction,
+ GithubPrEventStatus, GithubPrMention, GithubPrMentionLocation, GithubPrNotificationCommon,
+ GithubPrReview, GithubPrReviewState, GithubPrStatusChanged, GithubReviewRequested,
InviteToTeamMetadata, ItemSharedMetadata, NewEmailMetadata,
RepliedToDocumentCommentThreadMetadata, UserUnsubscribe,
};
@@ -82,9 +84,17 @@ use crate::{
DocumentMentionMetadata,
RepliedToDocumentCommentThreadMetadata,
CommentedOnDocumentMetadata,
- GithubPrEvent,
+ GithubPrNotificationCommon,
+ GithubPrStatusChanged,
GithubPrEventStatus,
GithubPrEventAction,
+ GithubReviewRequested,
+ GithubPrComment,
+ GithubPrCommentKind,
+ GithubPrMention,
+ GithubPrMentionLocation,
+ GithubPrReview,
+ GithubPrReviewState,
// v2 typed notifications
model_notifications::NotifEvent,
diff --git a/rust/cloud-storage/notification_service/src/api/user_notification.rs b/rust/cloud-storage/notification_service/src/api/user_notification.rs
index 82190e1623..f703740858 100644
--- a/rust/cloud-storage/notification_service/src/api/user_notification.rs
+++ b/rust/cloud-storage/notification_service/src/api/user_notification.rs
@@ -10,7 +10,8 @@ use model_entity::Entity;
use model_error_response::ErrorResponse;
use model_notifications::{
AiResponseMetadata, ChannelMentionMetadata, ChannelMessageSendMetadata, ChannelReplyMetadata,
- CommentedOnDocumentMetadata, DocumentMentionMetadata, GithubPrEvent,
+ CommentedOnDocumentMetadata, DocumentMentionMetadata, GithubPrComment, GithubPrMention,
+ GithubPrReview, GithubPrStatusChanged, GithubReviewRequested,
MentionedInDocumentCommentMetadata, NewEmailMetadata, NotifEvent,
RepliedToDocumentCommentThreadMetadata, TaskAssignedMetadata,
};
@@ -32,7 +33,11 @@ pub(crate) static BLOCKABLE_NOTIFICATIONS: LazyLock<HashSet<&'static str>> = Laz
ChannelMentionMetadata::TYPE_NAME,
ChannelReplyMetadata::TYPE_NAME,
DocumentMentionMetadata::TYPE_NAME,
- GithubPrEvent::TYPE_NAME,
+ GithubPrStatusChanged::TYPE_NAME,
+ GithubReviewRequested::TYPE_NAME,
+ GithubPrComment::TYPE_NAME,
+ GithubPrMention::TYPE_NAME,
+ GithubPrReview::TYPE_NAME,
TaskAssignedMetadata::TYPE_NAME,
MentionedInDocumentCommentMetadata::TYPE_NAME,
RepliedToDocumentCommentThreadMetadata::TYPE_NAME,
diff --git a/rust/cloud-storage/notification_service/src/api/user_notification/test.rs b/rust/cloud-storage/notification_service/src/api/user_notification/test.rs
index fc2d6f0fa6..ba729b6ea7 100644
--- a/rust/cloud-storage/notification_service/src/api/user_notification/test.rs
+++ b/rust/cloud-storage/notification_service/src/api/user_notification/test.rs
@@ -166,7 +166,7 @@ fn to_typed_row_task_assigned() {
}
#[test]
-fn to_typed_row_github_pr_event() {
+fn to_typed_row_github_pr_status_changed() {
let foreign_entity_id = uuid::Uuid::parse_str("550e8400-e29b-41d4-a716-446655440000")
.expect("valid foreign entity id");
let metadata = serde_json::json!({
@@ -189,20 +189,20 @@ fn to_typed_row_github_pr_event() {
"mergedAt": "2026-06-01T16:00:00Z"
});
- let mut row = make_row("github_pr_event", metadata);
+ let mut row = make_row("github_pr_status_changed", metadata);
row.entity = EntityType::ForeignEntity.with_entity_string(foreign_entity_id.to_string());
- let typed = to_typed_row(row).expect("should deserialize github_pr_event");
+ let typed = to_typed_row(row).expect("should deserialize github_pr_status_changed");
match typed.notification_metadata {
- NotifEvent::GithubPrEvent(event) => {
- assert_eq!(event.foreign_entity_id, foreign_entity_id);
- assert_eq!(event.github_key, "macro/repo/pull/42");
+ NotifEvent::GithubPrStatusChanged(event) => {
+ assert_eq!(event.common.foreign_entity_id, foreign_entity_id);
+ assert_eq!(event.common.github_key, "macro/repo/pull/42");
assert_eq!(event.status, GithubPrEventStatus::Merged);
assert_eq!(event.action, GithubPrEventAction::Closed);
assert_eq!(event.previous_status, Some(GithubPrEventStatus::Open));
}
- other => panic!("expected GithubPrEvent variant, got {other:?}"),
+ other => panic!("expected GithubPrStatusChanged variant, got {other:?}"),
}
}