浏览代码

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 };