fix: ignore expired rolling vouchers on check

This commit is contained in:
etiennecollin
2025-09-07 17:17:35 -04:00
parent a83be957df
commit 89a1421efb
2 changed files with 13 additions and 11 deletions

View File

@@ -4,28 +4,28 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Voucher { pub struct Voucher {
id: String, pub id: String,
#[serde(rename = "createdAt")] #[serde(rename = "createdAt")]
pub created_at: String, pub created_at: String,
pub name: String, pub name: String,
code: String, pub code: String,
#[serde(rename = "authorizedGuestLimit")] #[serde(rename = "authorizedGuestLimit")]
authorized_guest_limit: Option<u64>, pub authorized_guest_limit: Option<u64>,
#[serde(rename = "authorizedGuestCount")] #[serde(rename = "authorizedGuestCount")]
authorized_guest_count: u64, pub authorized_guest_count: u64,
#[serde(rename = "activatedAt")] #[serde(rename = "activatedAt")]
pub activated_at: Option<String>, pub activated_at: Option<String>,
#[serde(rename = "expiresAt")] #[serde(rename = "expiresAt")]
pub expires_at: Option<String>, pub expires_at: Option<String>,
expired: bool, pub expired: bool,
#[serde(rename = "timeLimitMinutes")] #[serde(rename = "timeLimitMinutes")]
time_limit_minutes: u64, pub time_limit_minutes: u64,
#[serde(rename = "dataUsageLimitMBytes")] #[serde(rename = "dataUsageLimitMBytes")]
data_usage_limit_mbytes: Option<u64>, pub data_usage_limit_mbytes: Option<u64>,
#[serde(rename = "rxRateLimitKbps")] #[serde(rename = "rxRateLimitKbps")]
rx_rate_limit_kbps: Option<u64>, pub rx_rate_limit_kbps: Option<u64>,
#[serde(rename = "txRateLimitKbps")] #[serde(rename = "txRateLimitKbps")]
tx_rate_limit_kbps: Option<u64>, pub tx_rate_limit_kbps: Option<u64>,
} }
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
@@ -80,7 +80,7 @@ pub struct DetailsRequest {
pub struct Site { pub struct Site {
pub id: String, pub id: String,
#[serde(rename = "internalReference")] #[serde(rename = "internalReference")]
internal_reference: String, pub internal_reference: String,
pub name: String, pub name: String,
} }

View File

@@ -290,7 +290,9 @@ impl<'a> UnifiAPI<'a> {
.data .data
.iter() .iter()
.find(|voucher| { .find(|voucher| {
voucher.name.starts_with(ROLLING_VOUCHER_NAME_PREFIX) && voucher.name.ends_with(ip) !voucher.expired
&& voucher.name.starts_with(ROLLING_VOUCHER_NAME_PREFIX)
&& voucher.name.ends_with(ip)
}) })
.cloned(); .cloned();