···181181async fn fetch_timeline_total_count(db: &DbConn, timeline_id: &str) -> Result<usize, LuminaError> {
182182 match db {
183183 DbConn::PgsqlConnection(pg_pool, _redis_pool) => {
184184- let client = pg_pool.get().await.map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
184184+ let client = pg_pool
185185+ .get()
186186+ .await
187187+ .map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
185188 let timeline_uuid = Uuid::parse_str(timeline_id).map_err(|_| LuminaError::UUidError)?;
186189 let row = client
187190 .query_one(
···206209) -> Result<Vec<String>, LuminaError> {
207210 match db {
208211 DbConn::PgsqlConnection(pg_pool, _redis_pool) => {
209209- let client = pg_pool.get().await.map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
212212+ let client = pg_pool
213213+ .get()
214214+ .await
215215+ .map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
210216 let timeline_uuid = Uuid::parse_str(timeline_id).map_err(|_| LuminaError::UUidError)?;
211217 let rows = client
212218 .query(
···238244239245 // Get Redis connection
240246 let mut redis_conn = match db {
241241- DbConn::PgsqlConnection(_, redis_pool) => {
242242- redis_pool.get().await.map_err(|e| LuminaError::Bb8Pool(e.to_string()))?
243243- }
247247+ DbConn::PgsqlConnection(_, redis_pool) => redis_pool
248248+ .get()
249249+ .await
250250+ .map_err(|e| LuminaError::Bb8Pool(e.to_string()))?,
244251 };
245252246253 // Log the requested timeline id for tracking
···360367 // Add to database
361368 match db {
362369 DbConn::PgsqlConnection(pg_pool, redis_pool) => {
363363- let client = pg_pool.get().await.map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
370370+ let client = pg_pool
371371+ .get()
372372+ .await
373373+ .map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
364374 let timeline_uuid = Uuid::parse_str(timeline_id).map_err(|_| LuminaError::UUidError)?;
365375 let item_uuid = Uuid::parse_str(item_id).map_err(|_| LuminaError::UUidError)?;
366376 client
···372382 .map_err(LuminaError::Postgres)?;
373383374384 // Invalidate cache
375375- let mut redis_conn = redis_pool.get().await.map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
385385+ let mut redis_conn = redis_pool
386386+ .get()
387387+ .await
388388+ .map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
376389 if let Err(e) = invalidate_timeline_cache(&mut redis_conn, timeline_id).await {
377390 error_elog!(
378391 event_logger,
···398411 // Remove from database
399412 match db {
400413 DbConn::PgsqlConnection(pg_pool, redis_pool) => {
401401- let client = pg_pool.get().await.map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
414414+ let client = pg_pool
415415+ .get()
416416+ .await
417417+ .map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
402418 let timeline_uuid = Uuid::parse_str(timeline_id).map_err(|_| LuminaError::UUidError)?;
403419 let item_uuid = Uuid::parse_str(item_id).map_err(|_| LuminaError::UUidError)?;
404420 client
···410426 .map_err(LuminaError::Postgres)?;
411427412428 // Invalidate cache
413413- let mut redis_conn = redis_pool.get().await.map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
429429+ let mut redis_conn = redis_pool
430430+ .get()
431431+ .await
432432+ .map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
414433 if let Err(e) = invalidate_timeline_cache(&mut redis_conn, timeline_id).await {
415434 error_elog!(
416435 event_logger,
+28-7
server/src/user.rs
···6262 async fn get_hashed_password(self, database: &DbConn) -> Result<String, LuminaError> {
6363 match database {
6464 DbConn::PgsqlConnection(pg_pool, _) => {
6565- let client = pg_pool.get().await.map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
6565+ let client = pg_pool
6666+ .get()
6767+ .await
6868+ .map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
6669 let row = client
6770 .query_one("SELECT password FROM users WHERE id = $1", &[&self.id])
6871 .await
···8487 bcrypt::hash(password, bcrypt::DEFAULT_COST).map_err(|_| LuminaError::BcryptError)?;
8588 match db {
8689 DbConn::PgsqlConnection(pg_pool, _) => {
8787- let client = pg_pool.get().await.map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
9090+ let client = pg_pool
9191+ .get()
9292+ .await
9393+ .map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
8894 // Some username and email validation should be done here
8995 // Check if the email is already in use
9096 let email_exists = client
···127133 };
128134 match db {
129135 DbConn::PgsqlConnection(pg_pool, _) => {
130130- let client = pg_pool.get().await.map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
136136+ let client = pg_pool
137137+ .get()
138138+ .await
139139+ .map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
131140 let user = client
132141 .query_one(
133142 &format!("SELECT id, email, username, COALESCE(foreign_instance_id, '') FROM users WHERE {} = $1", identifyer_type),
···154163 let user_id = user.id;
155164 match db {
156165 DbConn::PgsqlConnection(pg_pool, _) => {
157157- let client = pg_pool.get().await.map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
166166+ let client = pg_pool
167167+ .get()
168168+ .await
169169+ .map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
158170 let session_key = Uuid::new_v4().to_string();
159171 let id = client
160172 .query_one(
···185197 ) -> Result<User, LuminaError> {
186198 match db {
187199 DbConn::PgsqlConnection(pg_pool, _) => {
188188- let client = pg_pool.get().await.map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
200200+ let client = pg_pool
201201+ .get()
202202+ .await
203203+ .map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
189204 let user = client
190205 .query_one("SELECT users.id, users.email, users.username FROM users JOIN sessions ON users.id = sessions.user_id WHERE sessions.session_key = $1", &[&token])
191206 .await
···211226 // Check if the email or username is already in use using fastbloom algorithm with Redis, and fallback to DB check if not found. If not in either, we can go on.
212227 match db {
213228 DbConn::PgsqlConnection(pg_pool, redis_pool) => {
214214- let client = pg_pool.get().await.map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
215215- let mut redis_conn = redis_pool.get().await.map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
229229+ let client = pg_pool
230230+ .get()
231231+ .await
232232+ .map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
233233+ let mut redis_conn = redis_pool
234234+ .get()
235235+ .await
236236+ .map_err(|e| LuminaError::Bb8Pool(e.to_string()))?;
216237 // fastbloom_rs expects bytes, so we use the string as bytes
217238 let email_key = String::from("bloom:email");
218239 let username_key = String::from("bloom:username");