From 6b16a105d98aee792fb61d6bdd54a5f61ecece09 Mon Sep 17 00:00:00 2001 From: Okke Harsta Date: Fri, 20 Dec 2024 12:53:11 +0100 Subject: [PATCH] Fixes #339 --- client/src/tabs/Invitations.js | 7 +++++-- .../repository/InvitationRepository.java | 20 +++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/client/src/tabs/Invitations.js b/client/src/tabs/Invitations.js index 08d24f2..b5f51fd 100644 --- a/client/src/tabs/Invitations.js +++ b/client/src/tabs/Invitations.js @@ -290,8 +290,11 @@ export const Invitations = ({ key: "name", header: I18n.t("invitations.inviter"), mapper: invitation =>
- {invitation.name} - {invitation.inviter_email} + {invitation.inviter_email ? <> + {invitation.name} + {invitation.inviter_email} + : {invitation.remote_api_user}} +
}, { diff --git a/server/src/main/java/access/repository/InvitationRepository.java b/server/src/main/java/access/repository/InvitationRepository.java index 8d692d5..d6e1c19 100644 --- a/server/src/main/java/access/repository/InvitationRepository.java +++ b/server/src/main/java/access/repository/InvitationRepository.java @@ -30,9 +30,9 @@ public interface InvitationRepository extends JpaRepository, Q List findByStatusAndRoles_role(Status status, Role role); @Query(value = """ - SELECT i.id, i.email, i.intended_authority,i.created_at, i.expiry_date, + SELECT i.id, i.email, i.remote_api_user, i.intended_authority, i.created_at, i.expiry_date, u.id as user_id, u.name, u.email as inviter_email - FROM invitations i INNER JOIN users u ON u.id = i.inviter_id + FROM invitations i LEFT JOIN users u ON u.id = i.inviter_id WHERE i.status = ?1 """, countQuery = "SELECT count(*) FROM invitations WHERE status = ?1", @@ -41,15 +41,15 @@ public interface InvitationRepository extends JpaRepository, Q Page> searchByStatusPage(String status, Pageable pageable); @Query(value = """ - SELECT i.id, i.email, i.intended_authority,i.created_at, i.expiry_date, + SELECT i.id, i.email, i.remote_api_user, i.intended_authority,i.created_at, i.expiry_date, u.id as user_id, u.name, u.email as inviter_email - FROM invitations i INNER JOIN users u ON u.id = i.inviter_id + FROM invitations i LEFT JOIN users u ON u.id = i.inviter_id WHERE i.status = ?1 AND (MATCH(i.email) AGAINST(?2 IN BOOLEAN MODE) OR MATCH (u.given_name, u.family_name, u.email) against (?2 IN BOOLEAN MODE)) """, countQuery = """ - SELECT count(*) FROM invitations i INNER JOIN users u ON u.id = i.inviter_id + SELECT count(*) FROM invitations i LEFT JOIN users u ON u.id = i.inviter_id WHERE status = ?1 AND (MATCH(i.email) AGAINST(?2 IN BOOLEAN MODE) OR MATCH (u.given_name, u.family_name, u.email) against (?2 IN BOOLEAN MODE)) @@ -59,9 +59,9 @@ OR MATCH (u.given_name, u.family_name, u.email) against (?2 IN BOOLEAN MODE)) Page> searchByStatusPageWithKeyword(String status, String keyWord, Pageable pageable); @Query(value = """ - SELECT i.id, i.email, i.intended_authority,i.created_at, i.expiry_date, + SELECT i.id, i.email, i.remote_api_user, i.intended_authority,i.created_at, i.expiry_date, u.id as user_id, u.name, u.email as inviter_email - FROM invitations i INNER JOIN users u ON u.id = i.inviter_id INNER JOIN invitation_roles ir ON ir.invitation_id = i.id + FROM invitations i LEFT JOIN users u ON u.id = i.inviter_id INNER JOIN invitation_roles ir ON ir.invitation_id = i.id INNER JOIN roles r ON r.id = ir.role_id WHERE i.status = ?1 AND r.id = ?2 """, @@ -76,9 +76,9 @@ SELECT count(*) FROM invitations i Page> searchByStatusAndRolePage(String status, Long roleId, Pageable pageable); @Query(value = """ - SELECT i.id, i.email, i.intended_authority,i.created_at, i.expiry_date, + SELECT i.id, i.email, i.remote_api_user, i.intended_authority,i.created_at, i.expiry_date, u.id as user_id, u.name, u.email as inviter_email - FROM invitations i INNER JOIN users u ON u.id = i.inviter_id INNER JOIN invitation_roles ir ON ir.invitation_id = i.id + FROM invitations i LEFT JOIN users u ON u.id = i.inviter_id INNER JOIN invitation_roles ir ON ir.invitation_id = i.id INNER JOIN roles r ON r.id = ir.role_id WHERE i.status = ?1 AND r.id = ?2 AND (MATCH(i.email) AGAINST(?3 IN BOOLEAN MODE) @@ -88,7 +88,7 @@ OR MATCH (u.given_name, u.family_name, u.email) against (?3 IN BOOLEAN MODE)) SELECT count(*) FROM invitations i INNER JOIN invitation_roles ir ON ir.invitation_id = i.id INNER JOIN roles r ON r.id = ir.role_id - INNER JOIN users u ON u.id = i.inviter_id + LEFT JOIN users u ON u.id = i.inviter_id WHERE status = ?1 and role_id = ?2 AND (MATCH(i.email) AGAINST(?3 IN BOOLEAN MODE) OR MATCH (u.given_name, u.family_name, u.email) against (?3 IN BOOLEAN MODE))