Return pending TMs, fix notifs serde (#575)

* Return pending TMs, fix notifs serde

* fix compile
This commit is contained in:
Geometrically
2023-04-18 14:16:41 -07:00
committed by GitHub
parent a560f6e9f6
commit bb80505b76
2 changed files with 9 additions and 3 deletions

View File

@@ -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<Utc>,
pub body: NotificationBody,
// DEPRECATED: use body field instead
#[serde(rename = "type")]
pub type_: Option<String>,
pub title: String,
pub text: String,

View File

@@ -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) = &current_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();