Merge pull request 'dev' (#32) from dev into master

Reviewed-on: #32
This commit is contained in:
Thibaut Valentin 2025-02-08 14:01:04 +01:00
commit 2cdb495402
4 changed files with 12 additions and 4 deletions

View File

@ -245,7 +245,7 @@ public class AffiliationService {
keycloakService.setClubGroupMembre(m, club).map(__ -> m.getUserId()))
.call(userId -> keycloakService.setAutoRoleMembre(userId, m.getRole(), m.getGrade_arbitrage())))
.call(m -> Mutiny.fetch(m.getLicences())
.call(l1 -> l1.stream().anyMatch(l -> l.getSaison() == saison) ?
.call(l1 -> l1 != null && l1.stream().anyMatch(l -> l.getSaison() == saison) ?
Uni.createFrom().nullItem() :
Panache.withTransaction(() -> licenceRepository.persist(
new LicenceModel(null, m, saison, null, true)))));

View File

@ -185,7 +185,7 @@ public class AffiliationRequestEndpoints {
})
public Uni<Response> getStatus(
@Parameter(description = "L'identifiant de la demande d'affiliation") @PathParam("id") long id) throws URISyntaxException {
return Utils.getMediaFile(id, media, "aff_request/status", "affiliation_request_" + id + ".pdf",
return Utils.getMediaFile(id, media, "aff_request/status", "affiliation_request_" + id,
Uni.createFrom().nullItem());
}
}

View File

@ -305,7 +305,7 @@ public class ClubEndpoints {
return clubService.getById(id).onItem().invoke(checkPerm).chain(Unchecked.function(clubModel -> {
try {
return Utils.getMediaFile(clubModel.getId(), media, "clubStatus",
"statue-" + clubModel.getName() + ".pdf", Uni.createFrom().nullItem());
"statue-" + clubModel.getName(), Uni.createFrom().nullItem());
} catch (URISyntaxException e) {
throw new InternalError();
}

View File

@ -162,12 +162,20 @@ public class Utils {
return Uni.createFrom().item(() -> {
String mimeType = URLConnection.guessContentTypeFromName(filePair.getKey().getName());
String filename = out_filename;
if (filename != null && (filename.length() < 5 || filename.lastIndexOf(
'.') <= filename.length() - 6)) {
filename += filePair.getKey().getName()
.substring(filePair.getKey().getName().lastIndexOf('.'));
}
Response.ResponseBuilder resp = Response.ok(filePair.getValue());
resp.type(MediaType.APPLICATION_OCTET_STREAM);
resp.header(HttpHeaders.CONTENT_LENGTH, filePair.getValue().length);
resp.header(HttpHeaders.CONTENT_TYPE, mimeType);
resp.header(HttpHeaders.CONTENT_DISPOSITION,
"inline; " + ((out_filename == null) ? "" : "filename=\"" + out_filename + "\""));
"inline; " + ((filename == null) ? "" : "filename=\"" + filename + "\""));
return resp.build();
});
}