Skip to content

Commit

Permalink
only log CreateVaultEvent if it's actually creating and not updating
Browse files Browse the repository at this point in the history
  • Loading branch information
tobihagemann committed Jul 11, 2023
1 parent d31e0ee commit 72150ea
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions backend/src/main/java/org/cryptomator/hub/api/VaultResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -363,17 +363,13 @@ public Response createOrUpdate(@PathParam("vaultId") UUID vaultId, @Valid @NotNu
vault.name = vaultDto.name;
vault.description = vaultDto.description;
vault.archived = vaultDto.archived;

try {
vault.persistAndFlush();
vault.persistAndFlush();
if (isCreated) {
CreateVaultEvent.log(currentUser.id, vault.id);
if (isCreated) {
return Response.created(URI.create(".")).contentLocation(URI.create(".")).entity(VaultDto.fromEntity(vault)).type(MediaType.APPLICATION_JSON).build();
} else {
return Response.ok(VaultDto.fromEntity(vault), MediaType.APPLICATION_JSON).build();
}
} catch (PersistenceException e) {
throw new InternalServerErrorException(e);
return Response.created(URI.create(".")).contentLocation(URI.create(".")).entity(VaultDto.fromEntity(vault)).type(MediaType.APPLICATION_JSON).build();
} else {
// TODO: log UpdateVaultEvent
return Response.ok(VaultDto.fromEntity(vault), MediaType.APPLICATION_JSON).build();
}
}

Expand Down

0 comments on commit 72150ea

Please sign in to comment.