From bb80505b7626579cf5295a984a07a5ef990255f5 Mon Sep 17 00:00:00 2001 From: Geometrically <18202329+Geometrically@users.noreply.github.com> Date: Tue, 18 Apr 2023 14:16:41 -0700 Subject: [PATCH] Return pending TMs, fix notifs serde (#575) * Return pending TMs, fix notifs serde * fix compile --- src/models/notifications.rs | 2 +- src/routes/v2/teams.rs | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/models/notifications.rs b/src/models/notifications.rs index 253ebf30..77f6d043 100644 --- a/src/models/notifications.rs +++ b/src/models/notifications.rs @@ -18,12 +18,12 @@ pub struct NotificationId(pub u64); pub struct Notification { pub id: NotificationId, pub user_id: UserId, - #[serde(rename = "type")] pub read: bool, pub created: DateTime, pub body: NotificationBody, // DEPRECATED: use body field instead + #[serde(rename = "type")] pub type_: Option, pub title: String, pub text: String, diff --git a/src/routes/v2/teams.rs b/src/routes/v2/teams.rs index bdcbc0d5..153df578 100644 --- a/src/routes/v2/teams.rs +++ b/src/routes/v2/teams.rs @@ -90,7 +90,7 @@ pub async fn team_members_get( let current_user = get_user_from_headers(req.headers(), &**pool).await.ok(); - if let Some(user) = current_user { + if let Some(user) = ¤t_user { let team_member = TeamMember::get_from_user_id(id.into(), user.id.into(), &**pool) .await @@ -106,9 +106,15 @@ pub async fn team_members_get( } } + let user_id = current_user.map(|x| x.id.into()); let team_members: Vec<_> = members_data .into_iter() - .filter(|x| x.accepted) + .filter(|x| { + x.accepted + || user_id + .map(|y: crate::database::models::UserId| y == x.user.id) + .unwrap_or(false) + }) .map(|data| crate::models::teams::TeamMember::from(data, true)) .collect();