소스 검색

Prevent duplicate listing of double mentioned users

When the same user was mentioned more than once, we would previously generate
multiple notifications, but generally only one is necessary.

Later on we may want to revisit this if each notification is associated with a
given "concern" but for now this should be fine.
Mark Rousskov 5 년 전
부모
커밋
1ef4502c75
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      src/handlers/notification.rs

+ 2 - 1
src/handlers/notification.rs

@@ -11,6 +11,7 @@ use crate::{
 };
 use anyhow::Context as _;
 use regex::Regex;
+use std::collections::HashSet;
 use std::convert::TryFrom;
 
 lazy_static::lazy_static! {
@@ -78,7 +79,7 @@ pub async fn handle(ctx: &Context, event: &Event) -> anyhow::Result<()> {
     let caps = PING_RE
         .captures_iter(body)
         .map(|c| c.get(1).unwrap().as_str().to_owned())
-        .collect::<Vec<_>>();
+        .collect::<HashSet<_>>();
     log::trace!("Captured usernames in comment: {:?}", caps);
     for login in caps {
         let user = github::User { login, id: None };