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): only notify people who are participants in the pr (#4080)

Will Hutchinson985a52b5bc10
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 a7e23df803..23d224832f 100644
--- a/rust/cloud-storage/github/src/domain/service/sync/mod.rs
+++ b/rust/cloud-storage/github/src/domain/service/sync/mod.rs
@@ -118,6 +118,8 @@ struct PullRequestForeignEntityUpsert {
previous_status: Option<GithubPullRequestStatus>,
/// The newly persisted normalized PR status for this source, when known.
status: Option<GithubPullRequestStatus>,
+ /// Stable numeric GitHub user IDs for PR participants after metadata merge.
+ participant_github_user_ids: Vec<String>,
}
impl<
@@ -501,6 +503,8 @@ impl<
return Vec::new();
}
};
+ let participant_github_user_ids =
+ Self::participant_github_user_ids_from_metadata(&metadata);
let foreign_entity = if let Some(entity) = existing_entity {
self.patch_pull_request_foreign_entity(
@@ -530,6 +534,7 @@ impl<
foreign_entity_id: foreign_entity.id,
previous_status,
status: pull_request.status,
+ participant_github_user_ids,
});
}
@@ -601,6 +606,19 @@ impl<
.and_then(|status| serde_json::from_value(status.clone()).ok())
}
+ fn participant_github_user_ids_from_metadata(metadata: &serde_json::Value) -> Vec<String> {
+ let Some(ids) = metadata
+ .get("participantGithubUserIds")
+ .and_then(|value| value.as_array())
+ else {
+ return Vec::new();
+ };
+
+ ids.iter()
+ .filter_map(|value| value.as_str().map(str::to_string))
+ .collect()
+ }
+
/// Extract both legacy `MACRO-{short_uuid}` IDs and team-scoped
/// `{team_slug}-{team_task_id}` references from text.
#[tracing::instrument(skip(self, event, text))]
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 701065127e..60b2a412f3 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
@@ -58,15 +58,24 @@ impl<
return;
}
+ let participant_user_ids = self
+ .pull_request_participant_macro_user_ids(pull_request, upserts)
+ .await;
+ if participant_user_ids.is_empty() {
+ return;
+ }
+
let sender_id = self.notification_sender_id(event).await;
for (upsert, transition) in transitions {
- let recipient_ids = self.notification_recipient_ids(&upsert.source).await;
+ let recipient_ids = self
+ .participant_scoped_recipient_ids(&upsert.source, &participant_user_ids)
+ .await;
if recipient_ids.is_empty() {
tracing::trace!(
source_id=%upsert.source.source_id(),
source_type=%upsert.source.source_type(),
foreign_entity_id=%upsert.foreign_entity_id,
- "skipping GitHub PR notification without recipients"
+ "skipping GitHub PR status notification without participant-scoped recipients"
);
continue;
}
@@ -139,6 +148,115 @@ impl<
})
}
+ pub(super) async fn pull_request_participant_macro_user_ids(
+ &self,
+ pull_request: &EnrichedGithubPullRequest,
+ upserts: &[PullRequestForeignEntityUpsert],
+ ) -> HashSet<MacroUserIdStr<'static>> {
+ let github_user_ids = Self::pull_request_participant_github_user_ids(pull_request, upserts);
+ if github_user_ids.is_empty() {
+ tracing::trace!("skipping GitHub PR notification without participant GitHub user IDs");
+ return HashSet::new();
+ }
+
+ let user_ids = self.macro_users_for_github_user_ids(&github_user_ids).await;
+ if user_ids.is_empty() {
+ tracing::trace!(
+ participant_github_user_count = github_user_ids.len(),
+ "skipping GitHub PR notification without mapped participant users"
+ );
+ }
+
+ user_ids
+ }
+
+ fn pull_request_participant_github_user_ids(
+ pull_request: &EnrichedGithubPullRequest,
+ upserts: &[PullRequestForeignEntityUpsert],
+ ) -> HashSet<String> {
+ let mut github_user_ids = HashSet::new();
+
+ if let Some(ids) = &pull_request.participant_github_user_ids {
+ github_user_ids.extend(ids.iter().filter(|id| !id.is_empty()).cloned());
+ }
+
+ for upsert in upserts {
+ github_user_ids.extend(
+ upsert
+ .participant_github_user_ids
+ .iter()
+ .filter(|id| !id.is_empty())
+ .cloned(),
+ );
+ }
+
+ github_user_ids
+ }
+
+ async fn macro_users_for_github_user_ids(
+ &self,
+ github_user_ids: &HashSet<String>,
+ ) -> HashSet<MacroUserIdStr<'static>> {
+ let mut user_ids = HashSet::new();
+
+ for github_user_id in github_user_ids {
+ let macro_id = match self
+ .repo
+ .get_macro_id_by_github_user_id(github_user_id)
+ .await
+ {
+ Ok(Some(macro_id)) => macro_id,
+ Ok(None) => {
+ tracing::trace!(
+ participant_github_user_id=%github_user_id,
+ "GitHub PR participant has no Macro user mapping"
+ );
+ continue;
+ }
+ Err(error) => {
+ tracing::warn!(
+ error=?error,
+ participant_github_user_id=%github_user_id,
+ "failed to map GitHub PR participant"
+ );
+ continue;
+ }
+ };
+
+ match MacroUserIdStr::try_from(macro_id.clone()) {
+ Ok(user_id) => {
+ user_ids.insert(user_id);
+ }
+ Err(error) => {
+ tracing::warn!(
+ error=?error,
+ macro_id=%macro_id,
+ participant_github_user_id=%github_user_id,
+ "GitHub PR participant mapping is not a valid Macro user ID"
+ );
+ }
+ }
+ }
+
+ user_ids
+ }
+
+ pub(super) async fn participant_scoped_recipient_ids(
+ &self,
+ source: &GithubAppInstallationSource,
+ participant_user_ids: &HashSet<MacroUserIdStr<'static>>,
+ ) -> HashSet<MacroUserIdStr<'static>> {
+ if participant_user_ids.is_empty() {
+ return HashSet::new();
+ }
+
+ self.notification_recipient_ids(source)
+ .await
+ .intersection(participant_user_ids)
+ .cloned()
+ .collect()
+ }
+
pub(super) async fn notification_recipient_ids(
&self,
source: &GithubAppInstallationSource,
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
index 0f70c7abae..5f26fa80d8 100644
--- 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
@@ -5,7 +5,8 @@
//! 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.
+//! belong to. Broad comment fan-out is participant-scoped; review requests
+//! and mentions stay explicitly targeted.
use std::collections::HashSet;
@@ -131,9 +132,9 @@ impl<
///
/// 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.
+ /// `github_pr_mention` notification; non-mentioned PR participants in the
+ /// source receive `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,
@@ -161,18 +162,24 @@ impl<
};
let mentioned_users = self.mentioned_macro_users(&body).await;
+ let participant_users = self
+ .pull_request_participant_macro_user_ids(pull_request, upserts)
+ .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;
+ let source_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)
+ let mention_recipients: HashSet<_> = source_recipients
+ .intersection(&mentioned_users)
+ .cloned()
+ .collect();
+ let mut comment_recipients: HashSet<_> = source_recipients
+ .intersection(&participant_users)
.cloned()
.collect();
+ comment_recipients.retain(|recipient| !mention_recipients.contains(recipient));
if !mention_recipients.is_empty() {
let notification = GithubPrMention {
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 c55e4fa840..70ab66a54b 100644
--- a/rust/cloud-storage/github/src/domain/service/sync/test.rs
+++ b/rust/cloud-storage/github/src/domain/service/sync/test.rs
@@ -1079,6 +1079,35 @@ fn assert_github_notification_realtime_enabled_apns_disabled(
);
}
+struct PullRequestWebhookParticipants<'a> {
+ author: Option<(u64, &'a str)>,
+ requested_reviewers: &'a [(u64, &'a str)],
+ assignees: &'a [(u64, &'a str)],
+}
+
+impl<'a> PullRequestWebhookParticipants<'a> {
+ fn empty() -> Self {
+ Self {
+ author: None,
+ requested_reviewers: &[],
+ assignees: &[],
+ }
+ }
+}
+
+fn github_webhook_user(id: u64, login: &str) -> serde_json::Value {
+ serde_json::json!({ "id": id, "login": login })
+}
+
+fn github_webhook_users(users: &[(u64, &str)]) -> serde_json::Value {
+ serde_json::Value::Array(
+ users
+ .iter()
+ .map(|(id, login)| github_webhook_user(*id, *login))
+ .collect(),
+ )
+}
+
fn notification_pull_request_event(
action: &str,
title: &str,
@@ -1088,22 +1117,57 @@ fn notification_pull_request_event(
sender_id: u64,
sender_login: &str,
) -> ValidatedGithubWebhookEvent {
+ notification_pull_request_event_with_participants(
+ action,
+ title,
+ state,
+ merged,
+ merged_at,
+ sender_id,
+ sender_login,
+ PullRequestWebhookParticipants::empty(),
+ )
+}
+
+fn notification_pull_request_event_with_participants(
+ action: &str,
+ title: &str,
+ state: &str,
+ merged: bool,
+ merged_at: Option<&str>,
+ sender_id: u64,
+ sender_login: &str,
+ participants: PullRequestWebhookParticipants<'_>,
+) -> ValidatedGithubWebhookEvent {
+ let mut pull_request = serde_json::json!({
+ "number": 42,
+ "title": title,
+ "body": null,
+ "head": { "ref": "feature/some-branch" },
+ "base": { "ref": "main" },
+ "state": state,
+ "merged": merged,
+ "merged_at": merged_at,
+ "additions": 10,
+ "deletions": 2
+ });
+
+ if let Some((id, login)) = participants.author {
+ pull_request["user"] = github_webhook_user(id, login);
+ }
+ if !participants.requested_reviewers.is_empty() {
+ pull_request["requested_reviewers"] =
+ github_webhook_users(participants.requested_reviewers);
+ }
+ if !participants.assignees.is_empty() {
+ pull_request["assignees"] = github_webhook_users(participants.assignees);
+ }
+
ValidatedGithubWebhookEvent::new(
"pull_request".to_string(),
serde_json::json!({
"action": action,
- "pull_request": {
- "number": 42,
- "title": title,
- "body": null,
- "head": { "ref": "feature/some-branch" },
- "base": { "ref": "main" },
- "state": state,
- "merged": merged,
- "merged_at": merged_at,
- "additions": 10,
- "deletions": 2
- },
+ "pull_request": pull_request,
"repository": {
"name": "my-repo",
"owner": { "login": "my-org" }
@@ -1213,6 +1277,22 @@ fn pull_request_details(
}
}
+fn seed_pull_request_details_with_participants(
+ service: &TestGithubSyncService,
+ participant_github_user_ids: &[&str],
+) {
+ let mut details = pull_request_details("Add GitHub notifications", 10, 2, None, None);
+ details.participant_github_user_ids = Some(
+ participant_github_user_ids
+ .iter()
+ .map(|id| (*id).to_string())
+ .collect(),
+ );
+ service
+ .client
+ .set_pull_request_details("my-org", "my-repo", 42, details);
+}
+
#[tokio::test]
async fn pr_with_task_id_in_title() {
let service = make_sync_service();
@@ -2011,14 +2091,24 @@ async fn pr_opened_upserts_foreign_entity_for_user_installation_source() {
}
#[tokio::test]
-async fn github_pr_status_changed_opened_team_source_notifies_team_members() {
+async fn github_pr_status_changed_opened_team_source_notifies_participant_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)])
- .with_team_members(team_id, vec!["macro|[email protected]", "macro|[email protected]"])
- .with_github_link("222", "macro|[email protected]");
+ .with_team_members(
+ team_id,
+ vec![
+ ],
+ )
+ .with_github_link("111", "macro|[email protected]")
+ .with_github_link("222", "macro|[email protected]")
+ .with_github_link("333", "macro|[email protected]")
+ .with_github_link("444", "macro|[email protected]");
let service = make_sync_service_with_repo(repo);
- let event = notification_pull_request_event(
+ let event = notification_pull_request_event_with_participants(
"opened",
"Add GitHub notifications",
"open",
@@ -2026,6 +2116,11 @@ async fn github_pr_status_changed_opened_team_source_notifies_team_members() {
None,
222,
"octocat",
+ PullRequestWebhookParticipants {
+ author: Some((111, "author-gh")),
+ requested_reviewers: &[(222, "alice-gh")],
+ assignees: &[(333, "bob-gh")],
+ },
);
service.process_webhook_event(&event).await.unwrap();
@@ -2136,7 +2231,7 @@ async fn github_pr_status_changed_opened_team_source_notifies_team_members() {
}
#[tokio::test]
-async fn github_pr_status_changed_merged_user_source_notifies_user() {
+async fn github_pr_status_changed_merged_user_source_notifies_participant_user() {
let repo = StubSyncRepo::new()
.with_installation_sources(
"12345",
@@ -2144,9 +2239,10 @@ async fn github_pr_status_changed_merged_user_source_notifies_user() {
"macro|[email protected]".to_string(),
)],
)
- .with_github_link("333", "macro|[email protected]");
+ .with_github_link("333", "macro|[email protected]")
+ .with_github_link("444", "macro|[email protected]");
let service = make_sync_service_with_repo(repo);
- let opened_event = notification_pull_request_event(
+ let opened_event = notification_pull_request_event_with_participants(
"opened",
"Add GitHub notifications",
"open",
@@ -2154,11 +2250,16 @@ async fn github_pr_status_changed_merged_user_source_notifies_user() {
None,
333,
"monalisa",
+ PullRequestWebhookParticipants {
+ author: None,
+ requested_reviewers: &[(444, "reviewer-gh")],
+ assignees: &[],
+ },
);
service.process_webhook_event(&opened_event).await.unwrap();
service.notification_ingress.clear_requests();
- let merged_event = notification_pull_request_event(
+ let merged_event = notification_pull_request_event_with_participants(
"closed",
"Add GitHub notifications",
"closed",
@@ -2166,6 +2267,11 @@ async fn github_pr_status_changed_merged_user_source_notifies_user() {
Some("2026-05-27T19:00:00Z"),
333,
"monalisa",
+ PullRequestWebhookParticipants {
+ author: None,
+ requested_reviewers: &[(444, "reviewer-gh")],
+ assignees: &[],
+ },
);
service.process_webhook_event(&merged_event).await.unwrap();
@@ -2225,6 +2331,63 @@ async fn github_pr_status_changed_merged_user_source_notifies_user() {
);
}
+#[tokio::test]
+async fn github_pr_status_changed_user_source_does_not_notify_nonparticipant() {
+ let repo = StubSyncRepo::new()
+ .with_installation_sources(
+ "12345",
+ vec![GithubAppInstallationSource::User(
+ "macro|[email protected]".to_string(),
+ )],
+ )
+ .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_pull_request_event_with_participants(
+ "opened",
+ "Add GitHub notifications",
+ "open",
+ false,
+ None,
+ 222,
+ "octocat",
+ PullRequestWebhookParticipants {
+ author: Some((222, "octocat")),
+ requested_reviewers: &[],
+ assignees: &[],
+ },
+ );
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ assert_eq!(service.foreign_entity_service.foreign_entities().len(), 1);
+ assert!(service.notification_ingress.requests().is_empty());
+}
+
+#[tokio::test]
+async fn github_pr_status_changed_missing_participants_does_not_notify_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)])
+ .with_team_members(team_id, vec!["macro|[email protected]", "macro|[email protected]"])
+ .with_github_link("222", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ let event = notification_pull_request_event(
+ "opened",
+ "Add GitHub notifications",
+ "open",
+ false,
+ None,
+ 222,
+ "octocat",
+ );
+
+ service.process_webhook_event(&event).await.unwrap();
+
+ assert_eq!(service.foreign_entity_service.foreign_entities().len(), 1);
+ assert!(service.notification_ingress.requests().is_empty());
+}
+
#[tokio::test]
async fn github_pr_status_changed_edited_does_not_notify() {
let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
@@ -2290,17 +2453,19 @@ async fn github_pr_status_changed_unchanged_status_does_not_notify() {
#[tokio::test]
async fn github_pr_status_changed_send_failure_does_not_fail_webhook_processing() {
- let repo = StubSyncRepo::new().with_installation_sources(
- "12345",
- vec![GithubAppInstallationSource::User(
- "macro|[email protected]".to_string(),
- )],
- );
+ let repo = StubSyncRepo::new()
+ .with_installation_sources(
+ "12345",
+ vec![GithubAppInstallationSource::User(
+ "macro|[email protected]".to_string(),
+ )],
+ )
+ .with_github_link("222", "macro|[email protected]");
let service = make_sync_service_with_repo_and_notification_ingress(
repo,
StubNotificationIngress::failing(),
);
- let event = notification_pull_request_event(
+ let event = notification_pull_request_event_with_participants(
"opened",
"Add GitHub notifications",
"open",
@@ -2308,6 +2473,11 @@ async fn github_pr_status_changed_send_failure_does_not_fail_webhook_processing(
None,
222,
"octocat",
+ PullRequestWebhookParticipants {
+ author: Some((222, "octocat")),
+ requested_reviewers: &[],
+ assignees: &[],
+ },
);
let result = service.process_webhook_event(&event).await;
@@ -3617,9 +3787,13 @@ fn requests_with_tag(requests: &[serde_json::Value], tag: &str) -> Vec<serde_jso
}
#[tokio::test]
-async fn issue_comment_notifies_team_without_mentions() {
+async fn issue_comment_notifies_participants_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 repo = comment_team_repo(team_id)
+ .with_github_link("333", "macro|[email protected]")
+ .with_github_link("444", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ seed_pull_request_details_with_participants(&service, &["333", "444", "999"]);
let event = notification_comment_event(
"issue_comment",
"created",
@@ -3638,7 +3812,6 @@ async fn issue_comment_notifies_team_without_mentions() {
assert_eq!(
notification_request_recipients(request),
vec![
- "macro|[email protected]".to_string(),
"macro|[email protected]".to_string(),
"macro|[email protected]".to_string(),
]
@@ -3671,11 +3844,85 @@ async fn issue_comment_notifies_team_without_mentions() {
);
}
+#[tokio::test]
+async fn issue_comment_uses_existing_participant_metadata_when_live_details_are_missing() {
+ let team_id: uuid::Uuid = "dddddddd-dddd-dddd-dddd-dddddddddddd".parse().unwrap();
+ let repo = comment_team_repo(team_id)
+ .with_github_link("333", "macro|[email protected]")
+ .with_github_link("444", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ let opened_event = notification_pull_request_event_with_participants(
+ "opened",
+ "Add GitHub notifications",
+ "open",
+ false,
+ None,
+ 222,
+ "octocat",
+ PullRequestWebhookParticipants {
+ author: None,
+ requested_reviewers: &[(333, "bob-gh")],
+ assignees: &[(444, "carol-gh")],
+ },
+ );
+ service.process_webhook_event(&opened_event).await.unwrap();
+ service.notification_ingress.clear_requests();
+
+ let foreign_entities = service.foreign_entity_service.foreign_entities();
+ assert_eq!(foreign_entities.len(), 1);
+ assert_eq!(
+ foreign_entities[0].metadata.get("participantGithubUserIds"),
+ Some(&serde_json::json!(["333", "444"]))
+ );
+
+ let event = notification_comment_event(
+ "issue_comment",
+ "created",
+ "Live PR details were unavailable",
+ "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]),
+ vec![
+ "macro|[email protected]".to_string(),
+ "macro|[email protected]".to_string(),
+ ]
+ );
+}
+
+#[tokio::test]
+async fn issue_comment_missing_participants_does_not_notify_team_members() {
+ 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();
+
+ assert_eq!(service.foreign_entity_service.foreign_entities().len(), 1);
+ assert!(service.notification_ingress.requests().is_empty());
+}
+
#[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 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);
+ seed_pull_request_details_with_participants(&service, &["444"]);
let event = notification_comment_event(
"issue_comment",
"created",
@@ -3713,18 +3960,18 @@ async fn issue_comment_mentioned_member_gets_mention_not_comment() {
assert_eq!(comments.len(), 1);
assert_eq!(
notification_request_recipients(&comments[0]),
- vec![
- "macro|[email protected]".to_string(),
- "macro|[email protected]".to_string(),
- ]
+ vec!["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 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);
+ seed_pull_request_details_with_participants(&service, &["444"]);
let event = notification_comment_event(
"pull_request_review_comment",
"created",
@@ -3740,6 +3987,14 @@ async fn review_comment_uses_review_comment_kind_and_location() {
let comments = requests_with_tag(&requests, "github_pr_comment");
assert_eq!(mentions.len(), 1);
assert_eq!(comments.len(), 1);
+ assert_eq!(
+ notification_request_recipients(&mentions[0]),
+ vec!["macro|[email protected]".to_string()]
+ );
+ assert_eq!(
+ notification_request_recipients(&comments[0]),
+ vec!["macro|[email protected]".to_string()]
+ );
assert_eq!(
notification_request_content(&mentions[0])
.get("location")
@@ -3789,9 +4044,13 @@ async fn edited_comment_does_not_notify() {
}
#[tokio::test]
-async fn mention_of_unlinked_login_falls_back_to_comment_for_all() {
+async fn mention_of_unlinked_login_falls_back_to_comment_for_participants() {
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 repo = comment_team_repo(team_id)
+ .with_github_link("333", "macro|[email protected]")
+ .with_github_link("444", "macro|[email protected]");
+ let service = make_sync_service_with_repo(repo);
+ seed_pull_request_details_with_participants(&service, &["333", "444"]);
let event = notification_comment_event(
"issue_comment",
"created",
@@ -3805,7 +4064,13 @@ async fn mention_of_unlinked_login_falls_back_to_comment_for_all() {
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);
+ assert_eq!(
+ notification_request_recipients(&requests[0]),
+ vec![
+ "macro|[email protected]".to_string(),
+ "macro|[email protected]".to_string(),
+ ]
+ );
}
#[tokio::test]
@@ -3816,6 +4081,7 @@ async fn mention_login_linked_to_multiple_users_notifies_all_in_team() {
.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);
+ seed_pull_request_details_with_participants(&service, &["222"]);
let event = notification_comment_event(
"issue_comment",
"created",
@@ -4113,11 +4379,6 @@ async fn opened_pr_body_mention_notifies_mentioned_member() {
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);