Преглед изворни кода

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