this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: work on warning reduction and linting

+224 -125
+8 -1
Cargo.toml
··· 2 2 resolver = "3" 3 3 members = ["./server"] 4 4 default-members = ["./server"] 5 - license = "AGPL-3" 5 + 6 + [workspace.lints.clippy] 7 + expect_used = { level = "deny", priority = 0 } 8 + panic_in_result_fn = { level = "deny", priority = 0 } 9 + arithmetic_side_effects = "warn" 10 + missing_docs = "forbid" 11 + missing_panics_doc = "warn" 12 + pedantic = { level = "warn", priority = -1 }
+4
mise/tasks/check.toml
··· 18 18 tools.watchexec = "latest" 19 19 description = "Run the server in development mode with file watching" 20 20 run = "mise watch --restart -e rs,gleam,toml,css,ts,json --clear=clear check" 21 + 22 + [clippy_watch] 23 + tools.watchexec = "latest" 24 + run = "watchexec -c clear -restart -e rs,toml 'clear ; cargo clippy'"
+4 -3
server/src/client_communication.rs
··· 297 297 LuminaError::AuthenticationWrongPassword => { 298 298 authentication_error_elog!(ev_log,"User {} {} authenticated: Incorrect credentials", email_username.color_bright_cyan(), "not".color_red()); 299 299 } 300 - LuminaError::AuthenticationUserNotFound => { 301 - authentication_error_elog!(ev_log,"User {} {} authenticated: User not found", email_username.color_bright_cyan(), "not".color_red()); 302 - } 300 + // LuminaError::AuthenticationUserNotFound => { 301 + // authentication_error_elog!(ev_log,"User {} {} authenticated: User not found", email_username.color_bright_cyan(), "not".color_red()); 302 + // } 303 303 _ => { 304 304 authentication_error_elog!(ev_log,"User {} {} authenticated: {:?}", email_username.color_bright_cyan(), "not".color_red(), s); 305 305 } ··· 541 541 Web, 542 542 // NativeApp will one day mean a native application, like a mobile app. 543 543 // For now, it is nothing. 544 + #[expect(dead_code, reason="Will be used when other clients are added.")] 544 545 NativeApp, 545 546 }
+64 -13
server/src/database.rs
··· 119 119 .connect(postgres::tls::NoTls) 120 120 .await 121 121 .map_err(LuminaError::Postgres)?; 122 - let _ = tokio::spawn(conn.1); 122 + tokio::spawn(conn.1); 123 123 // Create a second connection to the database for spawning the maintain function 124 124 let conn_two: (Client, Connection<Socket, NoTlsStream>) = pg_config 125 125 .connect(postgres::tls::NoTls) 126 126 .await 127 127 .map_err(LuminaError::Postgres)?; 128 - let _ = tokio::spawn(conn_two.1); 128 + tokio::spawn(conn_two.1); 129 129 { 130 - let _ = conn 130 + conn 131 131 .0 132 132 .batch_execute(include_str!("../../SQL/create_pg.sql")) 133 133 .await ··· 162 162 let conn_clone = conn_two.0; 163 163 let pg_config_clone = pg_config.clone(); 164 164 let redis_pool_clone = redis_pool.clone(); 165 - let _ = tokio::spawn(async move { 165 + tokio::spawn(async move { 166 166 maintain(DbConn::PgsqlConnection( 167 167 (conn_clone, pg_config_clone), 168 168 redis_pool_clone, ··· 175 175 176 176 /// This enum contains the postgres and redis connection and pool respectively. It used to have more variants before, and maybe it will once again. 177 177 #[derive()] 178 - pub(crate) enum DbConn { 178 + pub enum DbConn { 179 179 // The config is also shared, so that for example the logger can set up its own connection, use this sparingly. 180 180 /// The main database is a Postgres database in this variant. 181 181 PgsqlConnection((Client, postgres::Config), Pool<redis::Client>), 182 182 } 183 183 184 - impl DbConn { 184 + pub(crate) trait DatabaseConnections { 185 185 /// Get a reference to the redis pool 186 186 /// This is useful for functions that need to access redis but not the main database 187 187 /// such as timeline cache management 188 - /// This returns a clone of the pool, so it is cheap to call 189 - pub(crate) fn get_redis_pool(&self) -> Pool<redis::Client> { 190 - match self { 191 - DbConn::PgsqlConnection((_, _), redis_pool) => redis_pool.clone(), 192 - } 193 - } 188 + /// This returns a clone of the pool without recreating it entirely, so it is cheap to call 189 + fn get_redis_pool(&self) -> Pool<redis::Client>; 190 + 191 + /// Recreate the database connection. 192 + async fn recreate(&self) -> Result<Self, LuminaError> 193 + where 194 + Self: Sized; 195 + } 194 196 197 + impl DatabaseConnections for DbConn { 195 198 /// Recreate the database connection. 196 199 /// This clones the pool on sqlite and for redis, and creates a new connection on postgres. 197 - pub(crate) async fn recreate(&self) -> Result<Self, LuminaError> { 200 + async fn recreate(&self) -> Result<Self, LuminaError> { 198 201 match self { 199 202 DbConn::PgsqlConnection((_, config), redis_pool) => { 200 203 let c = config ··· 206 209 207 210 Ok(DbConn::PgsqlConnection((c, config.to_owned()), r)) 208 211 } 212 + } 213 + } 214 + 215 + fn get_redis_pool(&self) -> Pool<redis::Client> { 216 + match self { 217 + DbConn::PgsqlConnection((_, _), redis_pool) => redis_pool.clone(), 218 + } 219 + } 220 + } 221 + 222 + impl DatabaseConnections for PgConn { 223 + fn get_redis_pool(&self) -> Pool<redis::Client> { 224 + self.redis_pool.clone() 225 + } 226 + 227 + async fn recreate(&self) -> Result<Self, LuminaError> { 228 + let postgres = self 229 + .postgres_config 230 + .connect(tokio_postgres::tls::NoTls) 231 + .await 232 + .map_err(LuminaError::Postgres)? 233 + .0; 234 + let postgres_config = self.postgres_config.to_owned(); 235 + let redis_pool = self.redis_pool.clone(); 236 + Ok(PgConn { 237 + postgres, 238 + postgres_config, 239 + redis_pool, 240 + }) 241 + } 242 + } 243 + /// Simplified type only accounting for the Postgres struct, since the enum adds some future flexibility, but also a lot of overhead. 244 + /// If all goes well, this PgConn type will have replaced DbConn entirely after a few iterations of improvement over the years. 245 + pub struct PgConn { 246 + pub(crate) postgres: Client, 247 + postgres_config: postgres::Config, 248 + pub(crate) redis_pool: Pool<redis::Client>, 249 + } 250 + 251 + impl DbConn { 252 + /// Converts/unwraps the generic DbConn type to it's more concrete PgConn counterpart. 253 + pub(crate) fn to_pgconn(db: Self) -> PgConn { 254 + match db { 255 + Self::PgsqlConnection((a, b), c) => PgConn { 256 + postgres: a, 257 + postgres_config: b, 258 + redis_pool: c, 259 + }, 209 260 } 210 261 } 211 262 }
+8 -6
server/src/errors.rs
··· 22 22 23 23 #[derive(Debug)] 24 24 pub(crate) enum LuminaError { 25 - ConfMissing(String), 26 25 ConfInvalid(String), 27 26 R2D2Pool(r2d2::Error), 28 27 Postgres(crate::postgres::Error), 29 28 Unknown, 30 - RocketFaillure(rocket::Error), 31 - BcryptError(bcrypt::BcryptError), 29 + /// Rocket failure wrapper, due to size, we only store the error source here. Construct with: 30 + /// ```rust 31 + /// (LuminaError::RocketFaillure, Some<rocket::Error>) 32 + /// ``` 33 + RocketFaillure, 34 + BcryptError, 32 35 RegisterEmailInUse, 33 36 RegisterUsernameInUse, 34 37 RegisterEmailNotValid, 35 38 RegisterUsernameInvalid(String), 36 39 RegisterPasswordNotValid(String), 37 40 AuthenticationWrongPassword, 38 - AuthenticationUserNotFound, 39 - UUidError(uuid::Error), 40 - RegexError(regex::Error), 41 + UUidError, 42 + RegexError, 41 43 Redis(redis::RedisError), 42 44 SerializationError(String), 43 45 JoinFaillure,
+49 -44
server/src/helpers/events.rs
··· 23 23 * along with this program. If not, see <https://www.gnu.org/licenses/>. 24 24 */ 25 25 26 - use crate::database::DbConn; 27 - use crate::{LuminaError, database}; 26 + use crate::LuminaError; 27 + use crate::database::{DatabaseConnections, DbConn, PgConn}; 28 28 use cynthia_con::{CynthiaColors, CynthiaStyles}; 29 29 use time::OffsetDateTime; 30 30 ··· 50 50 /// The database log entry is simple, with the log type, the message, and a timestamp. 51 51 pub enum EventLogger { 52 52 /// Variant created when logger has a database, and the database nor environment have any settings blocking database logging. 53 - WithDatabase { db: DbConn }, 53 + WithDatabase(Box<PgConn>), 54 54 /// Only log to stdout 55 55 OnlyStdout, 56 56 } ··· 58 58 impl EventLogger { 59 59 /// Creates a new logger instance. 60 60 /// The `db` parameter can be `None` if the database isn't connected. 61 - pub async fn new(db: &Option<DbConn>) -> Self { 61 + pub async fn new(db: &Option<PgConn>) -> Self { 62 62 // For quick implementation we'll just check if not none and that's all. 63 63 match db { 64 64 Some(d) => Self::from_db(d).await, 65 65 None => Self::OnlyStdout, 66 66 } 67 67 } 68 + pub async fn new_l(db: &Option<DbConn>) -> Self { 69 + // For quick implementation we'll just check if not none and that's all. 70 + match db { 71 + Some(d) => Self::from_db_l(d).await, 72 + None => Self::OnlyStdout, 73 + } 74 + } 68 75 69 - pub async fn from_db(db: &DbConn) -> Self { 70 - match db { 71 - DbConn::PgsqlConnection((_, pg_config), redis_pool) => { 72 - match pg_config 73 - .connect(tokio_postgres::tls::NoTls) 74 - .await 75 - .map_err(LuminaError::Postgres) 76 - { 77 - Ok((client, _)) => { 78 - let new_dbconn = database::DbConn::PgsqlConnection( 79 - (client, pg_config.clone()), 80 - redis_pool.clone(), 81 - ); 82 - Self::WithDatabase { db: new_dbconn } 83 - } 76 + pub async fn from_db_l(db_: &DbConn) -> Self { 77 + match db_.recreate().await { 78 + Ok(db) => { 79 + let new_db = DbConn::to_pgconn(db); 80 + Self::WithDatabase(Box::new(new_db)) 81 + } 82 + Err(error) => { 83 + let n = Self::OnlyStdout; 84 + n.error( 85 + format!("Could not connect the logger to the database! {:?}", error).as_str(), 86 + ) 87 + .await; 88 + n 89 + } 90 + } 91 + } 84 92 85 - Err(error) => { 86 - let n = Self::OnlyStdout; 87 - n.error( 88 - format!("Could not connect the logger to the database! {:?}", error) 89 - .as_str(), 90 - ) 91 - .await; 92 - n 93 - } 94 - } 93 + pub async fn from_db(db_: &PgConn) -> Self { 94 + match db_.recreate().await { 95 + Ok(new_db) => Self::WithDatabase(Box::new(new_db)), 96 + Err(error) => { 97 + let n = Self::OnlyStdout; 98 + n.error( 99 + format!("Could not connect the logger to the database! {:?}", error).as_str(), 100 + ) 101 + .await; 102 + n 95 103 } 96 104 } 97 105 } 98 106 99 107 pub async fn clone(&self) -> Self { 100 108 match self { 101 - EventLogger::WithDatabase { db } => Self::from_db(db).await, 109 + EventLogger::WithDatabase(db) => Self::from_db(db).await, 102 110 EventLogger::OnlyStdout => Self::OnlyStdout, 103 111 } 104 112 } ··· 158 166 159 167 // Log to the database if a connection is available. 160 168 match self { 161 - EventLogger::WithDatabase { db: db_conn } => { 169 + EventLogger::WithDatabase(db_conn) => { 162 170 // Log to stdout with the prefix. 163 171 if use_eprintln { 164 172 eprintln!("{stdoutmsg}"); ··· 179 187 EventType::HTTPCode(code) => format!("HTTP/{}", code), 180 188 }; 181 189 let ansi_regex = regex::Regex::new(r"\x1B\[[0-?]*[ -/]*[@-~]") 182 - .map_err(LuminaError::RegexError) 190 + .map_err(|_| LuminaError::RegexError) 183 191 .unwrap(); 184 192 185 193 let message_db: String = ansi_regex ··· 192 200 .format(&time::format_description::well_known::Rfc3339) 193 201 .unwrap(); 194 202 195 - match db_conn { 196 - crate::database::DbConn::PgsqlConnection((client, _), _) => { 197 - let _ = client 198 - .execute( 199 - "INSERT INTO logs (type, message, timestamp) VALUES ($1, $2, $3)", 200 - &[&level_str, &message_db, &ts], 201 - ) 202 - .await; 203 - } 204 - } 205 - } 206 - EventLogger::OnlyStdout { .. } => { 203 + let _ = db_conn 204 + .postgres 205 + .execute( 206 + "INSERT INTO logs (type, message, timestamp) VALUES ($1, $2, $3)", 207 + &[&level_str, &message_db, &ts], 208 + ) 209 + .await; 210 + } 211 + EventLogger::OnlyStdout => { 207 212 // Log to stdout with the prefix. 208 213 if use_eprintln { 209 214 eprintln!("{stdoutmsg}");
+34 -32
server/src/main.rs
··· 49 49 port: u16, 50 50 host: IpAddr, 51 51 } 52 + use crate::database::DatabaseConnections; 52 53 use crate::errors::LuminaError; 53 54 use cynthia_con::{CynthiaColors, CynthiaStyles}; 54 55 use dotenv::dotenv; ··· 96 97 let mut interval = 97 98 tokio::time::interval(std::time::Duration::from_millis(3000)); 98 99 let mut db_mut: Option<DbConn> = None; 99 - let mut ev_log: EventLogger = EventLogger::new(&db_mut).await; 100 + let ev_log: EventLogger = EventLogger::new(&None).await; 100 101 101 102 let mut db_tries: usize = 0; 102 103 while db_mut.is_none() { 103 104 interval.tick().await; 104 105 db_mut = match database::setup().await { 105 106 Ok(db) => Some(db), 106 - Err(LuminaError::ConfMissing(a)) => { 107 - error_elog!( 108 - ev_log, 109 - "Missing environment variable {}, which is required to continue. Please make sure it is set, or change other variables to make it redundant, if possible.", 110 - a.color_bright_orange() 111 - ); 112 - None 113 - } 107 + // Err(LuminaError::ConfMissing(a)) => { 108 + // error_elog!( 109 + // ev_log, 110 + // "Missing environment variable {}, which is required to continue. Please make sure it is set, or change other variables to make it redundant, if possible.", 111 + // a.color_bright_orange() 112 + // ); 113 + // None 114 + // } 114 115 Err(LuminaError::ConfInvalid(a)) => { 115 116 error_elog!( 116 117 ev_log, ··· 155 156 ); 156 157 process::exit(1); 157 158 } 158 - } else { 159 - // update ev_log, since clearly, it's no longer a question 160 - ev_log = EventLogger::new(&db_mut).await; 161 - 162 - success_elog!(ev_log, "Database connected.") 163 159 } 164 160 } 165 - let ev_log = EventLogger::new(&db_mut).await; 161 + // If we got here, we have a database connection. 162 + 163 + 166 164 let db = db_mut.unwrap(); 165 + let pg = DbConn::to_pgconn(db.recreate().await.unwrap()); 166 + let ev_log = EventLogger::from_db(&pg).await; 167 + success_elog!(ev_log, "Database connected."); 167 168 168 169 if cfg!(debug_assertions) { 169 170 let mut redis_conn = db.get_redis_pool().get().unwrap(); ··· 236 237 }; 237 238 238 239 match (user_1_, user_2_) { 239 - (Ok(user_1), Ok(user_2)) => { 240 + (Ok(user_1), Ok(_)) => { 240 241 println!( 241 242 "Created two users with password 'MyTestPassw9292!' and usernames 'testuser1' and 'testuser2'." 242 243 ); ··· 251 252 add_clone, 252 253 &db, 253 254 "00000000-0000-0000-0000-000000000000", 254 - &generated_uuid.to_string().as_str(), 255 + generated_uuid.to_string().as_str(), 255 256 ) 256 257 .await 257 258 .unwrap_or(()); 258 - () 259 + 259 260 } 260 261 z => { 261 262 println!( 262 263 "Ran into some issues: user 1: {:?}, user 2: {:?} ", 263 264 z.0, z.1 264 265 ); 265 - () 266 + 266 267 } 267 268 } 268 269 } ··· 366 367 let result = { 367 368 let g = s.await; 368 369 match g { 369 - Ok(x) => x.map_err(LuminaError::RocketFaillure), 370 - Err(..) => Err(LuminaError::JoinFaillure), 370 + Ok(x) => x.map_err(|e| { 371 + (LuminaError::RocketFaillure, Some(e)) 372 + }), 373 + Err(..) => Err((LuminaError::JoinFaillure, None)), 371 374 } 372 375 }; 373 376 match result { 374 377 Ok(_) => {} 375 - Err(LuminaError::RocketFaillure(e)) => { 378 + Err((LuminaError::RocketFaillure, Some(e))) => { 376 379 // This handling should slowly expand as I run into newer ones, the 'defh' (default handling) is good enough, but for the most-bumped into errors, I'd like to give more human responses. 377 380 let defh = 378 381 async || error_elog!(ev_log, "Error starting server: {:?}", e); ··· 404 407 } 405 408 } 406 409 } 407 - Err(LuminaError::ConfMissing(a)) => { 408 - error_elog!( 409 - ev_log, 410 - "Missing environment variable {}, which is required to continue. Please make sure it is set, or change other variables to make it redundant, if possible.", 411 - a.color_bright_orange() 412 - ); 413 - process::exit(1); 414 - } 410 + // Err(LuminaError::ConfMissing(a)) => { 411 + // error_elog!( 412 + // ev_log, 413 + // "Missing environment variable {}, which is required to continue. Please make sure it is set, or change other variables to make it redundant, if possible.", 414 + // a.color_bright_orange() 415 + // ); 416 + // process::exit(1); 417 + // } 415 418 Err(LuminaError::ConfInvalid(a)) => { 416 419 error_elog!( 417 420 ev_log, ··· 446 449 .split("\n") 447 450 .map(|s| s.style_centered()) 448 451 .collect(); 449 - let d = s.join("\n"); 450 - d 452 + s.join("\n") 451 453 } 452 454 println!("{}", me); 453 455 {
+47 -19
server/src/timeline.rs
··· 22 22 23 23 use crate::errors::LuminaError; 24 24 use crate::helpers::events::EventLogger; 25 - use crate::{DbConn, error_elog, info_elog, success_elog, user, warn_elog}; 25 + use crate::{DbConn, error_elog, info_elog, user}; 26 26 use redis::Commands; 27 27 use serde::{Deserialize, Serialize}; 28 28 use uuid::Uuid; ··· 169 169 async fn fetch_timeline_total_count(db: &DbConn, timeline_id: &str) -> Result<usize, LuminaError> { 170 170 match db { 171 171 DbConn::PgsqlConnection((client, _pg_config), _redis_pool) => { 172 - let timeline_uuid = Uuid::parse_str(timeline_id).map_err(LuminaError::UUidError)?; 172 + let timeline_uuid = Uuid::parse_str(timeline_id).map_err(|_| LuminaError::UUidError)?; 173 173 let row = client 174 174 .query_one( 175 175 "SELECT COUNT(*) FROM timelines WHERE tlid = $1", ··· 193 193 ) -> Result<Vec<String>, LuminaError> { 194 194 match db { 195 195 DbConn::PgsqlConnection((client, _pg_config), _redis_pool) => { 196 - let timeline_uuid = Uuid::parse_str(timeline_id).map_err(LuminaError::UUidError)?; 196 + let timeline_uuid = Uuid::parse_str(timeline_id).map_err(|_| LuminaError::UUidError)?; 197 197 let rows = client 198 198 .query( 199 199 "SELECT item_id FROM timelines WHERE tlid = $1 ORDER BY timestamp DESC LIMIT $2 OFFSET $3", ··· 238 238 let should_cache = is_high_traffic_timeline(&mut redis_conn, timeline_id).await?; 239 239 240 240 // Try to get from cache if it's a high-traffic timeline 241 - if should_cache { 242 - if let Some(cached_page) = 241 + if should_cache 242 + && let Some(cached_page) = 243 243 get_cached_timeline_page(&mut redis_conn, timeline_id, page).await? 244 - { 245 - let has_more = (page + 1) * TIMELINE_PAGE_SIZE < cached_page.total_count; 246 - return Ok((cached_page.post_ids, cached_page.total_count, has_more)); 247 - } 244 + { 245 + let has_more = (page + 1) * TIMELINE_PAGE_SIZE < cached_page.total_count; 246 + return Ok((cached_page.post_ids, cached_page.total_count, has_more)); 248 247 } 249 248 250 249 // Cache miss or low-traffic timeline - fetch from database ··· 257 256 258 257 // Cache the result if it's high-traffic 259 258 if should_cache { 260 - if let Err(e) = 261 - cache_timeline_page(&mut redis_conn, timeline_id, page, &post_ids, total_count) 262 - .await 259 + match cache_timeline_page(&mut redis_conn, timeline_id, page, &post_ids, total_count) 260 + .await 263 261 { 264 - error_elog!(event_logger, "Failed to cache timeline page: {:?}", e); 265 - } 262 + Ok(_) => info_elog!( 263 + event_logger, 264 + "Cached timeline {} page {} with {} posts", 265 + timeline_id, 266 + page, 267 + post_ids.len() 268 + ), 269 + Err(e) => match e { 270 + LuminaError::SerializationError(s) => error_elog!( 271 + event_logger, 272 + "Failed to serialize timeline {} page {} for caching: {}", 273 + timeline_id, 274 + page, 275 + s 276 + ), 277 + LuminaError::Redis(redis_err) => error_elog!( 278 + event_logger, 279 + "Failed to cache timeline {} page {}: {:?}", 280 + timeline_id, 281 + page, 282 + redis_err 283 + ), 284 + _ => error_elog!( 285 + event_logger, 286 + "Unexpected error while caching timeline {} page {}: {:?}", 287 + timeline_id, 288 + page, 289 + e 290 + ), 291 + }, 292 + }; 266 293 } 267 294 268 295 let has_more = (page + 1) * TIMELINE_PAGE_SIZE < total_count; ··· 291 318 ); 292 319 // For now, only global timeline is supported. 293 320 if timeline_name == "global" { 294 - let timeline_uuid = Uuid::parse_str(GLOBAL_TIMELINE_ID).map_err(LuminaError::UUidError)?; 321 + let timeline_uuid = Uuid::parse_str(GLOBAL_TIMELINE_ID).map_err(|_| LuminaError::UUidError)?; 295 322 let (post_ids, total_count, has_more) = 296 323 fetch_timeline_post_ids(event_logger, db, GLOBAL_TIMELINE_ID, page).await?; 297 324 Ok((timeline_uuid, post_ids, total_count, has_more)) ··· 316 343 // Add to database 317 344 match db { 318 345 DbConn::PgsqlConnection((client, _pg_config), redis_pool) => { 319 - let timeline_uuid = Uuid::parse_str(timeline_id).map_err(LuminaError::UUidError)?; 320 - let item_uuid = Uuid::parse_str(item_id).map_err(LuminaError::UUidError)?; 346 + let timeline_uuid = Uuid::parse_str(timeline_id).map_err(|_| LuminaError::UUidError)?; 347 + let item_uuid = Uuid::parse_str(item_id).map_err(|_| LuminaError::UUidError)?; 321 348 client 322 349 .execute( 323 350 "INSERT INTO timelines (tlid, item_id, timestamp) VALUES ($1, $2, NOW())", ··· 342 369 Ok(()) 343 370 } 344 371 372 + #[expect(dead_code, reason = "Not used yet")] 345 373 /// Remove a post from a timeline and invalidate cache if necessary 346 374 pub async fn remove_from_timeline( 347 375 event_logger: EventLogger, ··· 352 380 // Remove from database 353 381 match db { 354 382 DbConn::PgsqlConnection((client, _pg_config), redis_pool) => { 355 - let timeline_uuid = Uuid::parse_str(timeline_id).map_err(LuminaError::UUidError)?; 356 - let item_uuid = Uuid::parse_str(item_id).map_err(LuminaError::UUidError)?; 383 + let timeline_uuid = Uuid::parse_str(timeline_id).map_err(|_| LuminaError::UUidError)?; 384 + let item_uuid = Uuid::parse_str(item_id).map_err(|_| LuminaError::UUidError)?; 357 385 client 358 386 .execute( 359 387 "DELETE FROM timelines WHERE tlid = $1 AND item_id = $2",
+6 -7
server/src/user.rs
··· 22 22 use crate::{ 23 23 LuminaError, 24 24 database::DbConn, 25 - helpers::{self, events::EventLogger}, 25 + helpers::{events::EventLogger}, 26 26 info_elog, 27 27 }; 28 28 use cynthia_con::CynthiaColors; 29 - use std::str::FromStr; 30 29 use uuid::Uuid; 31 30 32 31 #[derive(Debug, Clone)] ··· 34 33 pub id: Uuid, 35 34 pub email: String, 36 35 pub username: String, 36 + #[expect(dead_code, reason = "Will be used for federated posts in the future")] 37 37 pub foreign_instance_id: String, // Added to handle foreign_instance_id 38 38 } 39 39 ··· 58 58 Err(e) => Err(e), 59 59 }?; 60 60 let hashed_password = user.clone().get_hashed_password(db).await?; 61 - if bcrypt::verify(password, &hashed_password).map_err(LuminaError::BcryptError)? { 61 + if bcrypt::verify(password, &hashed_password).map_err(|_| LuminaError::BcryptError)? { 62 62 user.create_session(db, ev_log).await 63 63 } else { 64 64 Err(LuminaError::AuthenticationWrongPassword) ··· 82 82 password: String, 83 83 db: &DbConn, 84 84 ) -> Result<User, LuminaError> { 85 - let _ = 86 - register_validitycheck(email.clone(), username.clone(), password.clone(), db).await?; 85 + register_validitycheck(email.clone(), username.clone(), password.clone(), db).await?; 87 86 // hash the password 88 87 let password = 89 - bcrypt::hash(password, bcrypt::DEFAULT_COST).map_err(LuminaError::BcryptError)?; 88 + bcrypt::hash(password, bcrypt::DEFAULT_COST).map_err(|_| LuminaError::BcryptError)?; 90 89 match db { 91 90 DbConn::PgsqlConnection((client, _), _) => { 92 91 // Some username and email validation should be done here ··· 284 283 let email_regex = regex::Regex::new( 285 284 r"^([a-z0-9_+]([a-z0-9_+.]*[a-z0-9_+])?)@([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{1,6})", 286 285 ) 287 - .map_err(LuminaError::RegexError)?; 286 + .map_err(|_| {LuminaError::RegexError})?; 288 287 if !email_regex.is_match(&email) { 289 288 return Err(LuminaError::RegisterEmailNotValid); 290 289 };