diff options
author | Santo Cariotti <santo@dcariotti.me> | 2025-01-20 16:55:39 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2025-01-20 16:55:39 +0100 |
commit | 4d065a195aac9ba71e7bf61320719d3dbafbc029 (patch) | |
tree | 8fac4f610dbab9ccf05dbf568ddb9376c9fb696a | |
parent | 90cdf5d68c64d411b79b01f6aad5de3cd421d8c9 (diff) |
Get the same notifications list for everyone
-rw-r--r-- | src/graphql/types/notification.rs | 32 |
1 files 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<Notification> = rows .iter() |