From 4d065a195aac9ba71e7bf61320719d3dbafbc029 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Mon, 20 Jan 2025 16:55:39 +0100 Subject: Get the same notifications list for everyone --- src/graphql/types/notification.rs | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/src/graphql/types/notification.rs b/src/graphql/types/notification.rs index 87d478a..45d8234 100644 --- a/src/graphql/types/notification.rs +++ b/src/graphql/types/notification.rs @@ -205,31 +205,19 @@ pub mod query { }; let rows = match alert_id { - Some(ida) if claim_user.is_admin => + Some (ida) => client .query(&format!( - "{base_query} AND n.alert_id = $1 ORDER BY n.id DESC LIMIT $2 OFFSET $3", - ), &[&ida, &limit, &offset]) + "{base_query} AND n.user_id = $1 AND n.alert_id = $2 ORDER BY n.id DESC LIMIT $3 OFFSET $4", + ), &[&claim_user.id, &ida, &limit, &offset]) .await?, - Some (ida) => - client - .query(&format!( - "{base_query} AND n.user_id = $1 AND n.alert_id = $2 ORDER BY n.id DESC LIMIT $3 OFFSET $4", - ), &[&claim_user.id, &ida, &limit, &offset]) - .await?, - None if claim_user.is_admin => client - .query( - &format!("{base_query} ORDER BY n.id DESC LIMIT $1 OFFSET $2"), - &[&limit, &offset], - ) - .await?, - None => - client.query( - &format!("{base_query} AND n.user_id = $1 ORDER BY n.id DESC LIMIT $2 OFFSET $3"), - &[&claim_user.id, &limit, &offset], - ) - .await?, - }; + None => + client.query( + &format!("{base_query} AND n.user_id = $1 ORDER BY n.id DESC LIMIT $2 OFFSET $3"), + &[&claim_user.id, &limit, &offset], + ) + .await?, + }; let notifications: Vec = rows .iter() -- cgit v1.2.3-18-g5258