mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-04-07 11:26:45 +00:00
Fix clippy feedback.
This commit is contained in:
parent
d24b8241c5
commit
10cbdb1e00
@ -289,8 +289,7 @@ impl InternalService for Internal {
|
||||
} else {
|
||||
Some(
|
||||
Uuid::from_str(&req_key.tenant_id)
|
||||
.map_err(|e| e.status())?
|
||||
.into(),
|
||||
.map_err(|e| e.status())?,
|
||||
)
|
||||
};
|
||||
|
||||
|
@ -258,8 +258,8 @@ impl TenantService for Tenant {
|
||||
.await?;
|
||||
|
||||
let _ = tenant::add_user(tenant::TenantUser {
|
||||
user_id,
|
||||
tenant_id: tenant_id.into(),
|
||||
user_id: user_id.into(),
|
||||
is_admin: req_user.is_admin,
|
||||
is_device_admin: req_user.is_device_admin,
|
||||
is_gateway_admin: req_user.is_gateway_admin,
|
||||
|
@ -65,7 +65,7 @@ impl UserService for User {
|
||||
|
||||
tenant::add_user(tenant::TenantUser {
|
||||
tenant_id: tenant_id.into(),
|
||||
user_id: u.id.into(),
|
||||
user_id: u.id,
|
||||
is_admin: tu.is_admin,
|
||||
is_device_admin: tu.is_device_admin,
|
||||
is_gateway_admin: tu.is_gateway_admin,
|
||||
|
@ -3,6 +3,7 @@ use handlebars::Handlebars;
|
||||
use super::super::config;
|
||||
|
||||
pub fn run() {
|
||||
#[allow(clippy::useless_vec)]
|
||||
let template = vec![
|
||||
r#"
|
||||
# Logging configuration
|
||||
|
@ -111,18 +111,16 @@ pub async fn run(dir: &Path) -> Result<()> {
|
||||
let vendors_dir = dir.join("vendors");
|
||||
let vendors = fs::read_dir(vendors_dir)?;
|
||||
|
||||
for vendor in vendors {
|
||||
if let Ok(vendor) = vendor {
|
||||
if vendor.file_name() == "example-vendor" {
|
||||
continue;
|
||||
}
|
||||
for vendor in vendors.flatten() {
|
||||
if vendor.file_name() == "example-vendor" {
|
||||
continue;
|
||||
}
|
||||
|
||||
let span = span!(Level::INFO, "", vendor = ?vendor.file_name());
|
||||
let span = span!(Level::INFO, "", vendor = ?vendor.file_name());
|
||||
|
||||
let vendor_dir = vendor.path();
|
||||
if vendor_dir.is_dir() {
|
||||
handle_vendor(&vendor_dir).instrument(span).await?;
|
||||
}
|
||||
let vendor_dir = vendor.path();
|
||||
if vendor_dir.is_dir() {
|
||||
handle_vendor(&vendor_dir).instrument(span).await?;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -466,10 +466,10 @@ impl Data {
|
||||
// * should not be pending
|
||||
// * should not be expired
|
||||
// * in case encrypted, should have a valid FCntDown
|
||||
if qi.data.len() <= max_payload_size
|
||||
&& !qi.is_pending
|
||||
&& !(qi.expires_at.is_some() && qi.expires_at.unwrap() < Utc::now())
|
||||
&& !(qi.is_encrypted
|
||||
if !(qi.data.len() > max_payload_size
|
||||
|| qi.is_pending
|
||||
|| qi.expires_at.is_some() && qi.expires_at.unwrap() < Utc::now()
|
||||
|| qi.is_encrypted
|
||||
&& (qi.f_cnt_down.unwrap_or_default() as u32) < ds.get_a_f_cnt_down())
|
||||
{
|
||||
trace!(id = %qi.id, more_in_queue = more_in_queue, "Found device queue-item for downlink");
|
||||
|
@ -6,8 +6,8 @@ pub enum Error {
|
||||
Abort,
|
||||
|
||||
#[error(transparent)]
|
||||
AnyhowError(#[from] anyhow::Error),
|
||||
Anyhow(#[from] anyhow::Error),
|
||||
|
||||
#[error(transparent)]
|
||||
StorageError(#[from] crate::storage::error::Error),
|
||||
Storage(#[from] crate::storage::error::Error),
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::str::FromStr;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
@ -146,15 +145,13 @@ impl Device {
|
||||
|
||||
pub fn get_device_session(&self) -> Result<&internal::DeviceSession, Error> {
|
||||
self.device_session
|
||||
.as_ref()
|
||||
.map(|ds| ds.deref())
|
||||
.as_deref()
|
||||
.ok_or_else(|| Error::NotFound(self.dev_eui.to_string()))
|
||||
}
|
||||
|
||||
pub fn get_device_session_mut(&mut self) -> Result<&mut internal::DeviceSession, Error> {
|
||||
self.device_session
|
||||
.as_mut()
|
||||
.map(|ds| ds.deref_mut())
|
||||
.as_deref_mut()
|
||||
.ok_or_else(|| Error::NotFound(self.dev_eui.to_string()))
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ impl deserialize::FromSql<Numeric, Pg> for BigDecimal {
|
||||
|
||||
#[cfg(feature = "postgres")]
|
||||
impl serialize::ToSql<Numeric, Pg> for BigDecimal {
|
||||
fn to_sql<'b>(&self, out: &mut serialize::Output<'b, '_, Pg>) -> serialize::Result {
|
||||
fn to_sql(&self, out: &mut serialize::Output<'_, '_, Pg>) -> serialize::Result {
|
||||
<bigdecimal::BigDecimal as serialize::ToSql<Numeric, Pg>>::to_sql(
|
||||
&self.0,
|
||||
&mut out.reborrow(),
|
||||
|
@ -17,15 +17,11 @@ type DevNoncesPgType = Array<Nullable<Int4>>;
|
||||
#[serde(transparent)]
|
||||
#[cfg_attr(feature = "postgres", diesel(sql_type = DevNoncesPgType))]
|
||||
#[cfg_attr(feature = "sqlite", diesel(sql_type = Text))]
|
||||
#[derive(Default)]
|
||||
pub struct DevNonces(DevNoncesInner);
|
||||
|
||||
pub type DevNoncesInner = Vec<Option<i32>>;
|
||||
|
||||
impl std::default::Default for DevNonces {
|
||||
fn default() -> Self {
|
||||
Self(Vec::new())
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::AsRef<DevNoncesInner> for DevNonces {
|
||||
fn as_ref(&self) -> &DevNoncesInner {
|
||||
@ -62,7 +58,7 @@ impl deserialize::FromSql<DevNoncesPgType, Pg> for DevNonces {
|
||||
|
||||
#[cfg(feature = "postgres")]
|
||||
impl serialize::ToSql<DevNoncesPgType, Pg> for DevNonces {
|
||||
fn to_sql<'b>(&self, out: &mut serialize::Output<'b, '_, Pg>) -> serialize::Result {
|
||||
fn to_sql(&self, out: &mut serialize::Output<'_, '_, Pg>) -> serialize::Result {
|
||||
<DevNoncesInner as serialize::ToSql<DevNoncesPgType, Pg>>::to_sql(
|
||||
&self.0,
|
||||
&mut out.reborrow(),
|
||||
|
@ -34,9 +34,9 @@ impl std::convert::From<&internal::DeviceSession> for DeviceSession {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::Into<internal::DeviceSession> for DeviceSession {
|
||||
fn into(self) -> internal::DeviceSession {
|
||||
self.0
|
||||
impl std::convert::From<DeviceSession> for internal::DeviceSession {
|
||||
fn from(val: DeviceSession) -> Self {
|
||||
val.0
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,13 +21,13 @@ impl std::convert::From<uuid::Uuid> for Uuid {
|
||||
|
||||
impl std::convert::From<&uuid::Uuid> for Uuid {
|
||||
fn from(u: &uuid::Uuid) -> Self {
|
||||
Self::from(u.clone())
|
||||
Self::from(*u)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::convert::Into<uuid::Uuid> for Uuid {
|
||||
fn into(self) -> uuid::Uuid {
|
||||
self.0
|
||||
impl std::convert::From<Uuid> for uuid::Uuid {
|
||||
fn from(val: Uuid) -> Self {
|
||||
val.0
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ impl deserialize::FromSql<diesel::sql_types::Uuid, Pg> for Uuid {
|
||||
|
||||
#[cfg(feature = "postgres")]
|
||||
impl serialize::ToSql<diesel::sql_types::Uuid, Pg> for Uuid {
|
||||
fn to_sql<'b>(&self, out: &mut serialize::Output<'b, '_, Pg>) -> serialize::Result {
|
||||
fn to_sql(&self, out: &mut serialize::Output<'_, '_, Pg>) -> serialize::Result {
|
||||
<uuid::Uuid as serialize::ToSql<diesel::sql_types::Uuid, Pg>>::to_sql(
|
||||
&self.0,
|
||||
&mut out.reborrow(),
|
||||
|
@ -390,7 +390,7 @@ pub async fn get_counts_by_state(tenant_id: &Option<Uuid>) -> Result<GatewayCoun
|
||||
gateway
|
||||
where
|
||||
$1 is null or tenant_id = $1
|
||||
"#).bind::<diesel::sql_types::Nullable<fields::sql_types::Uuid>, _>(tenant_id.map(|u| fields::Uuid::from(u))).get_result(&mut get_async_db_conn().await?).await?;
|
||||
"#).bind::<diesel::sql_types::Nullable<fields::sql_types::Uuid>, _>(tenant_id.map(fields::Uuid::from)).get_result(&mut get_async_db_conn().await?).await?;
|
||||
Ok(counts)
|
||||
}
|
||||
|
||||
|
@ -465,7 +465,7 @@ pub async fn enqueue(
|
||||
for gateway_id in gateway_ids {
|
||||
let qi = MulticastGroupQueueItem {
|
||||
scheduler_run_after: scheduler_run_after_ts,
|
||||
multicast_group_id: mg.id.into(),
|
||||
multicast_group_id: mg.id,
|
||||
gateway_id: *gateway_id,
|
||||
f_cnt: mg.f_cnt,
|
||||
f_port: qi.f_port,
|
||||
@ -473,7 +473,7 @@ pub async fn enqueue(
|
||||
emit_at_time_since_gps_epoch: Some(
|
||||
emit_at_time_since_gps_epoch.num_milliseconds(),
|
||||
),
|
||||
expires_at: qi.expires_at.clone(),
|
||||
expires_at: qi.expires_at,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@ -540,13 +540,13 @@ pub async fn enqueue(
|
||||
for gateway_id in gateway_ids {
|
||||
let qi = MulticastGroupQueueItem {
|
||||
scheduler_run_after: scheduler_run_after_ts,
|
||||
multicast_group_id: mg.id.into(),
|
||||
multicast_group_id: mg.id,
|
||||
gateway_id: *gateway_id,
|
||||
f_cnt: mg.f_cnt,
|
||||
f_port: qi.f_port,
|
||||
data: qi.data.clone(),
|
||||
emit_at_time_since_gps_epoch,
|
||||
expires_at: qi.expires_at.clone(),
|
||||
expires_at: qi.expires_at,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user