Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: get page view should handle situation where last editor or document owner cannot be found #1171

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions libs/database/src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ pub async fn select_name_and_email_from_uuid(
Ok((row.name, row.email))
}

pub async fn select_web_user_from_uid(pool: &PgPool, uid: i64) -> Result<AFWebUser, AppError> {
pub async fn select_web_user_from_uid(
pool: &PgPool,
uid: i64,
) -> Result<Option<AFWebUser>, AppError> {
let row = sqlx::query_as!(
AFWebUser,
r#"
Expand All @@ -264,7 +267,7 @@ pub async fn select_web_user_from_uid(pool: &PgPool, uid: i64) -> Result<AFWebUs
"#,
uid
)
.fetch_one(pool)
.fetch_optional(pool)
.await
.map_err(|err| anyhow::anyhow!("Unable to get user detail for {}: {}", uid, err))?;

Expand Down
4 changes: 2 additions & 2 deletions src/biz/workspace/page_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1290,11 +1290,11 @@ pub async fn get_page_view_collab(
)))?;

let owner = match view.created_by {
Some(uid) => Some(select_web_user_from_uid(pg_pool, uid).await?),
Some(uid) => select_web_user_from_uid(pg_pool, uid).await?,
None => None,
};
let last_editor = match view.last_edited_by {
Some(uid) => Some(select_web_user_from_uid(pg_pool, uid).await?),
Some(uid) => select_web_user_from_uid(pg_pool, uid).await?,
None => None,
};
let publish_view_ids = select_published_view_ids_for_workspace(pg_pool, workspace_id)
Expand Down
Loading