diff --git a/packages/backend-rs/src/database/postgresql.rs b/packages/backend-rs/src/database/postgresql.rs index 3ca3dc1c61..13cfccb9c2 100644 --- a/packages/backend-rs/src/database/postgresql.rs +++ b/packages/backend-rs/src/database/postgresql.rs @@ -18,7 +18,7 @@ async fn init_database() -> Result<&'static DbConn, DbErr> { .sqlx_logging_level(LevelFilter::Trace) .to_owned(); - tracing::info!("Initializing PostgreSQL connection"); + tracing::info!("initializing connection"); let conn = Database::connect(option).await?; Ok(DB_CONN.get_or_init(move || conn)) diff --git a/packages/backend-rs/src/database/redis.rs b/packages/backend-rs/src/database/redis.rs index 4290c4c1b6..e152ff0f40 100644 --- a/packages/backend-rs/src/database/redis.rs +++ b/packages/backend-rs/src/database/redis.rs @@ -67,10 +67,10 @@ async fn init_conn_pool() -> Result<(), RedisError> { params.concat() }; - tracing::info!("Initializing connection manager"); + tracing::info!("initializing connection manager"); let manager = RedisConnectionManager::new(redis_url)?; - tracing::info!("Creating connection pool"); + tracing::info!("creating connection pool"); let pool = Pool::builder().build(manager).await?; CONN_POOL.get_or_init(|| async { pool }).await; diff --git a/packages/backend-rs/src/init/greet.rs b/packages/backend-rs/src/init/greet.rs index 6cc40d0013..62854d3721 100644 --- a/packages/backend-rs/src/init/greet.rs +++ b/packages/backend-rs/src/init/greet.rs @@ -16,5 +16,5 @@ pub fn greet() { println!("{}", GREETING_MESSAGE); tracing::info!("Welcome to Firefish!"); - tracing::info!("Firefish {VERSION}"); + tracing::info!("Firefish v{VERSION}"); } diff --git a/packages/backend-rs/src/misc/convert_host.rs b/packages/backend-rs/src/misc/convert_host.rs index 8f054488de..d6770ecc74 100644 --- a/packages/backend-rs/src/misc/convert_host.rs +++ b/packages/backend-rs/src/misc/convert_host.rs @@ -3,9 +3,9 @@ use crate::config::CONFIG; #[derive(thiserror::Error, Debug)] pub enum Error { #[error("Idna error: {0}")] - IdnaError(#[from] idna::Errors), + IdnaErr(#[from] idna::Errors), #[error("Url parse error: {0}")] - UrlParseError(#[from] url::ParseError), + UrlParseErr(#[from] url::ParseError), #[error("Hostname is missing")] NoHostname, } diff --git a/packages/backend-rs/src/misc/emoji.rs b/packages/backend-rs/src/misc/emoji.rs index df7d33848c..e974f8060d 100644 --- a/packages/backend-rs/src/misc/emoji.rs +++ b/packages/backend-rs/src/misc/emoji.rs @@ -1,4 +1,4 @@ -#[inline] +#[crate::ts_only_warn("Use `emojis::get(str).is_some()` instead.")] #[crate::export] pub fn is_unicode_emoji(s: &str) -> bool { emojis::get(s).is_some() @@ -6,9 +6,11 @@ pub fn is_unicode_emoji(s: &str) -> bool { #[cfg(test)] mod unit_test { + #[allow(deprecated)] use super::is_unicode_emoji; #[test] + #[allow(deprecated)] fn test_unicode_emoji_check() { assert!(is_unicode_emoji("⭐")); assert!(is_unicode_emoji("👍")); diff --git a/packages/backend-rs/src/misc/get_image_size.rs b/packages/backend-rs/src/misc/get_image_size.rs index 750d87b6df..c2fc6f9073 100644 --- a/packages/backend-rs/src/misc/get_image_size.rs +++ b/packages/backend-rs/src/misc/get_image_size.rs @@ -69,7 +69,7 @@ pub async fn get_image_size_from_url(url: &str) -> Result<ImageSize, Error> { return Err(Error::TooManyAttempts(url.to_string())); } - tracing::info!("retrieving image size from {}", url); + tracing::info!("retrieving image from {}", url); let mut response = http_client::client()?.get(url)?; diff --git a/packages/backend-rs/src/misc/get_note_all_texts.rs b/packages/backend-rs/src/misc/get_note_all_texts.rs index 1e4bee396e..3625b3e8b4 100644 --- a/packages/backend-rs/src/misc/get_note_all_texts.rs +++ b/packages/backend-rs/src/misc/get_note_all_texts.rs @@ -52,7 +52,7 @@ pub async fn all_texts(note: NoteLike) -> Result<Vec<String>, DbErr> { texts.push(c); } } else { - tracing::warn!("nonexistent renote id: {:#?}", renote_id); + tracing::warn!("nonexistent renote id: {}", renote_id); } } @@ -71,7 +71,7 @@ pub async fn all_texts(note: NoteLike) -> Result<Vec<String>, DbErr> { texts.push(c); } } else { - tracing::warn!("nonexistent reply id: {:#?}", reply_id); + tracing::warn!("nonexistent reply id: {}", reply_id); } } diff --git a/packages/backend-rs/src/misc/is_quote.rs b/packages/backend-rs/src/misc/is_quote.rs index 5e8ce056c0..42e792f956 100644 --- a/packages/backend-rs/src/misc/is_quote.rs +++ b/packages/backend-rs/src/misc/is_quote.rs @@ -1,5 +1,6 @@ use crate::model::entity::note; +// for napi export // https://github.com/napi-rs/napi-rs/issues/2060 type Note = note::Model; diff --git a/packages/backend-rs/src/misc/password.rs b/packages/backend-rs/src/misc/password.rs index b21ff73499..8b8353ad4f 100644 --- a/packages/backend-rs/src/misc/password.rs +++ b/packages/backend-rs/src/misc/password.rs @@ -15,11 +15,11 @@ pub fn hash_password(password: &str) -> Result<String, password_hash::errors::Er #[derive(thiserror::Error, Debug)] pub enum VerifyError { #[error("An error occured while bcrypt verification: {0}")] - BcryptError(#[from] bcrypt::BcryptError), + BcryptErr(#[from] bcrypt::BcryptError), #[error("Invalid argon2 password hash: {0}")] InvalidArgon2Hash(#[from] password_hash::Error), #[error("An error occured while argon2 verification: {0}")] - Argon2Error(#[from] argon2::Error), + Argon2Err(#[from] argon2::Error), } #[crate::export] diff --git a/packages/backend-rs/src/misc/reaction.rs b/packages/backend-rs/src/misc/reaction.rs index f0afe345da..a30abcdd96 100644 --- a/packages/backend-rs/src/misc/reaction.rs +++ b/packages/backend-rs/src/misc/reaction.rs @@ -1,5 +1,5 @@ use crate::database::db_conn; -use crate::misc::{convert_host::to_puny, emoji::is_unicode_emoji, meta::fetch_meta}; +use crate::misc::{convert_host::to_puny, meta::fetch_meta}; use crate::model::entity::emoji; use once_cell::sync::Lazy; use regex::Regex; @@ -58,9 +58,9 @@ pub fn count_reactions(reactions: &HashMap<String, u32>) -> HashMap<String, u32> #[derive(thiserror::Error, Debug)] pub enum Error { #[error("Idna error: {0}")] - IdnaError(#[from] idna::Errors), + IdnaErr(#[from] idna::Errors), #[error("Database error: {0}")] - DbError(#[from] DbErr), + DbErr(#[from] DbErr), } #[crate::export] @@ -72,7 +72,8 @@ pub async fn to_db_reaction(reaction: Option<&str>, host: Option<&str>) -> Resul return Ok("❤️".to_owned()); } - if is_unicode_emoji(reaction) { + // check if the reaction is an Unicode emoji + if emojis::get(reaction).is_some() { return Ok(reaction.to_owned()); } diff --git a/packages/backend-rs/src/misc/remove_old_attestation_challenges.rs b/packages/backend-rs/src/misc/remove_old_attestation_challenges.rs index a70b784bae..75b8fcd7e3 100644 --- a/packages/backend-rs/src/misc/remove_old_attestation_challenges.rs +++ b/packages/backend-rs/src/misc/remove_old_attestation_challenges.rs @@ -2,18 +2,18 @@ use crate::database::db_conn; use crate::model::entity::attestation_challenge; -use chrono::{Duration, Local}; +use chrono::{Duration, Utc}; use sea_orm::{ColumnTrait, DbErr, EntityTrait, QueryFilter}; /// Delete all entries in the "attestation_challenge" table created at more than 5 minutes ago #[crate::export] pub async fn remove_old_attestation_challenges() -> Result<(), DbErr> { let res = attestation_challenge::Entity::delete_many() - .filter(attestation_challenge::Column::CreatedAt.lt(Local::now() - Duration::minutes(5))) + .filter(attestation_challenge::Column::CreatedAt.lt(Utc::now() - Duration::minutes(5))) .exec(db_conn().await?) .await?; - tracing::info!("{} attestation challenges are removed", res.rows_affected); + tracing::info!("removed {} rows", res.rows_affected); Ok(()) } diff --git a/packages/backend-rs/src/service/antenna.rs b/packages/backend-rs/src/service/antenna.rs index 3b7c8dba3a..323690761b 100644 --- a/packages/backend-rs/src/service/antenna.rs +++ b/packages/backend-rs/src/service/antenna.rs @@ -26,6 +26,7 @@ pub enum Error { AntennaCheckErr(#[from] AntennaCheckError), } +// for napi export // https://github.com/napi-rs/napi-rs/issues/2060 type Antenna = antenna::Model; type Note = note::Model; diff --git a/packages/backend-rs/src/service/nodeinfo/fetch.rs b/packages/backend-rs/src/service/nodeinfo/fetch.rs index 8177663394..ef38ae015a 100644 --- a/packages/backend-rs/src/service/nodeinfo/fetch.rs +++ b/packages/backend-rs/src/service/nodeinfo/fetch.rs @@ -5,9 +5,9 @@ use serde::{Deserialize, Serialize}; #[derive(thiserror::Error, Debug)] pub enum Error { - #[error("Http client aquisition error: {0}")] + #[error("HTTP client aquisition error: {0}")] HttpClientErr(#[from] http_client::Error), - #[error("Http error: {0}")] + #[error("HTTP error: {0}")] HttpErr(#[from] isahc::Error), #[error("Bad status: {0}")] BadStatus(String), diff --git a/packages/backend-rs/src/service/push_notification.rs b/packages/backend-rs/src/service/push_notification.rs index 9552a76bc3..5bde31eb31 100644 --- a/packages/backend-rs/src/service/push_notification.rs +++ b/packages/backend-rs/src/service/push_notification.rs @@ -174,7 +174,7 @@ pub async fn send_push_notification( serde_json::to_string(&compact_content(&kind, content.clone())?)? ) }; - tracing::trace!("payload: {:#?}", payload); + tracing::trace!("payload: {}", payload); let encoding = if kind == PushNotificationKind::Mastodon { ContentEncoding::AesGcm diff --git a/packages/backend-rs/src/service/stream.rs b/packages/backend-rs/src/service/stream.rs index 699f45b691..d9437f3fa3 100644 --- a/packages/backend-rs/src/service/stream.rs +++ b/packages/backend-rs/src/service/stream.rs @@ -48,13 +48,13 @@ pub enum Stream { #[derive(thiserror::Error, Debug)] pub enum Error { #[error("Redis error: {0}")] - RedisError(#[from] RedisError), + RedisErr(#[from] RedisError), #[error("Redis connection error: {0}")] RedisConnErr(#[from] RedisConnError), #[error("Json (de)serialization error: {0}")] - JsonError(#[from] serde_json::Error), + JsonErr(#[from] serde_json::Error), #[error("Value error: {0}")] - ValueError(String), + ValueErr(String), } pub async fn publish_to_stream( @@ -69,7 +69,7 @@ pub async fn publish_to_stream( value.unwrap_or("null".to_string()), ) } else { - value.ok_or(Error::ValueError("Invalid streaming message".to_string()))? + value.ok_or(Error::ValueErr("Invalid streaming message".to_string()))? }; redis_conn()