Compare commits
No commits in common. "bd68bfc6681dbe0010658e8dfd06103bba034555" and "6813d75db50fc5920af045dc55e459978da2be19" have entirely different histories.
bd68bfc668
...
6813d75db5
@ -245,18 +245,6 @@ impl User {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn has_membership_pdf(&self, db: &SqlitePool) -> bool {
|
|
||||||
match sqlx::query_scalar!("SELECT membership_pdf FROM user WHERE id = ?", self.id)
|
|
||||||
.fetch_one(db)
|
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
{
|
|
||||||
Some(a) if a.is_empty() => false,
|
|
||||||
None => false,
|
|
||||||
_ => true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn roles(&self, db: &SqlitePool) -> Vec<String> {
|
pub async fn roles(&self, db: &SqlitePool) -> Vec<String> {
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"SELECT r.name FROM role r JOIN user_role ur ON r.id = ur.role_id JOIN user u ON u.id = ur.user_id WHERE ur.user_id = ? AND u.deleted = 0;",
|
"SELECT r.name FROM role r JOIN user_role ur ON r.id = ur.role_id JOIN user u ON u.id = ur.user_id WHERE ur.user_id = ? AND u.deleted = 0;",
|
||||||
@ -460,7 +448,9 @@ ORDER BY last_access DESC
|
|||||||
family_id = Some(Family::insert(db).await)
|
family_id = Some(Family::insert(db).await)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.has_membership_pdf(db).await {
|
let user_with_membershippdf = UserWithMembershipPdf::from(db, self.clone()).await;
|
||||||
|
|
||||||
|
if user_with_membershippdf.membership_pdf.is_none() {
|
||||||
if let Some(membership_pdf) = data.membership_pdf {
|
if let Some(membership_pdf) = data.membership_pdf {
|
||||||
let mut stream = membership_pdf.open().await.unwrap();
|
let mut stream = membership_pdf.open().await.unwrap();
|
||||||
let mut buffer = Vec::new();
|
let mut buffer = Vec::new();
|
||||||
@ -978,7 +968,16 @@ pub struct UserWithRolesAndMembershipPdf {
|
|||||||
|
|
||||||
impl UserWithRolesAndMembershipPdf {
|
impl UserWithRolesAndMembershipPdf {
|
||||||
pub(crate) async fn from_user(db: &SqlitePool, user: User) -> Self {
|
pub(crate) async fn from_user(db: &SqlitePool, user: User) -> Self {
|
||||||
let membership_pdf = user.has_membership_pdf(db).await;
|
let membership_pdf =
|
||||||
|
match sqlx::query_scalar!("SELECT membership_pdf FROM user WHERE id = ?", user.id)
|
||||||
|
.fetch_one(db)
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
{
|
||||||
|
Some(a) if a.is_empty() => false,
|
||||||
|
None => false,
|
||||||
|
_ => true,
|
||||||
|
};
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
roles: user.roles(db).await,
|
roles: user.roles(db).await,
|
||||||
|
Loading…
Reference in New Issue
Block a user