Selaa lähdekoodia

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 vuotta sitten
vanhempi
commit
1ef4502c75
1 muutettua tiedostoa jossa 2 lisäystä ja 1 poistoa
  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 };