diff options
author | Santo Cariotti <santo@dcariotti.me> | 2025-01-20 16:40:17 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2025-01-20 16:40:17 +0100 |
commit | b808c45af6a301587783d689138ec744bc6b9536 (patch) | |
tree | 7cc788acc2a79a3e68a27d1ee926eaf46381067d | |
parent | d38fccb092411c083ff82c5bbe65af2add225b94 (diff) |
Check tokens array length
This is much better than `.filter` because there's already a check on
the SQL query
-rw-r--r-- | src/graphql/types/alert.rs | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/graphql/types/alert.rs b/src/graphql/types/alert.rs index 481eae6..2f06225 100644 --- a/src/graphql/types/alert.rs +++ b/src/graphql/types/alert.rs @@ -389,21 +389,22 @@ pub mod mutations { .map(|row| { format!("ExponentPushToken[{}]", row.get::<usize, String>(0)) }) - .filter(|token| token.len() > 19) .collect(); - expo::send( - (*state.expo).clone(), - tokens, - "New Alert!".to_string(), - match level.text { - "One" => alert.text1.clone(), - "Two" => alert.text2.clone(), - "Three" => alert.text3.clone(), - _ => "Check it out in app!".to_string(), - }, - ) - .await?; + if tokens.len() > 0 { + expo::send( + (*state.expo).clone(), + tokens, + "New Alert!".to_string(), + match level.text { + "One" => alert.text1.clone(), + "Two" => alert.text2.clone(), + "Three" => alert.text3.clone(), + _ => "Check it out in app!".to_string(), + }, + ) + .await?; + } } alerted_positions.extend(positions.iter().map(|p| p.id).collect::<Vec<i32>>()); |