Fix TM pending in project route (#584)

This commit is contained in:
Geometrically
2023-04-22 17:44:51 -07:00
committed by GitHub
parent 72cfa683cf
commit 339ac05443
2 changed files with 10 additions and 4 deletions

View File

@@ -1053,7 +1053,7 @@ pub async fn project_edit(
if let Some(moderation_message) = &new_project.moderation_message { if let Some(moderation_message) = &new_project.moderation_message {
if !user.role.is_mod() if !user.role.is_mod()
&& (!project_item.inner.status.is_approved() || moderation_message != &None) && (!project_item.inner.status.is_approved() || moderation_message.is_some())
{ {
return Err(ApiError::CustomAuthentication( return Err(ApiError::CustomAuthentication(
"You do not have the permissions to edit the moderation message of this project!" "You do not have the permissions to edit the moderation message of this project!"
@@ -1077,7 +1077,7 @@ pub async fn project_edit(
if let Some(moderation_message_body) = &new_project.moderation_message_body { if let Some(moderation_message_body) = &new_project.moderation_message_body {
if !user.role.is_mod() if !user.role.is_mod()
&& (!project_item.inner.status.is_approved() && (!project_item.inner.status.is_approved()
|| moderation_message_body != &None) || moderation_message_body.is_some())
{ {
return Err(ApiError::CustomAuthentication( return Err(ApiError::CustomAuthentication(
"You do not have the permissions to edit the moderation message body of this project!" "You do not have the permissions to edit the moderation message body of this project!"

View File

@@ -40,7 +40,7 @@ pub async fn team_members_get_project(
let current_user = get_user_from_headers(req.headers(), &**pool).await.ok(); 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 = let team_member =
TeamMember::get_from_user_id(project.team_id, user.id.into(), &**pool) TeamMember::get_from_user_id(project.team_id, user.id.into(), &**pool)
.await .await
@@ -56,9 +56,15 @@ pub async fn team_members_get_project(
} }
} }
let user_id = current_user.map(|x| x.id.into());
let team_members: Vec<_> = members_data let team_members: Vec<_> = members_data
.into_iter() .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)) .map(|data| crate::models::teams::TeamMember::from(data, true))
.collect(); .collect();