From 139acb2ec53548e4211a7f5d2074991bfc4e357f Mon Sep 17 00:00:00 2001 From: philipp Date: Mon, 29 Apr 2024 21:10:34 +0200 Subject: [PATCH] treat empty membership pdf as non-existing --- src/model/user.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/model/user.rs b/src/model/user.rs index dc9bb4a..07c9f93 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -989,12 +989,16 @@ pub struct UserWithRolesAndMembershipPdf { impl UserWithRolesAndMembershipPdf { pub(crate) async fn from_user(db: &SqlitePool, user: User) -> Self { - let membership_pdf: bool = - sqlx::query_scalar!("SELECT membership_pdf FROM user WHERE id = ?", user.id) + let membership_pdf = + match sqlx::query_scalar!("SELECT membership_pdf FROM user WHERE id = ?", user.id) .fetch_one(db) .await .unwrap() - .is_some(); + { + Some(a) if a.is_empty() => false, + None => false, + _ => true, + }; Self { roles: user.roles(db).await, -- 2.45.2