Comment out unused notification functionality in ParticleController since the file is directly readable

This commit is contained in:
akastijn 2026-01-04 05:37:46 +01:00
parent af3ef7155a
commit 6cb43b412c

View File

@ -24,14 +24,14 @@ import java.nio.file.Path;
@RestController
public class ParticleController implements ParticlesApi {
@Value("${login.secret:#{null}}")
private String loginSecret;
// @Value("${login.secret:#{null}}")
// private String loginSecret;
@Value("${particles.file_path}")
private String particlesFilePath;
@Value("${notification.server.url:http://localhost:8080}")
private String notificationServerUrl;
// @Value("${notification.server.url:http://localhost:8080}")
// private String notificationServerUrl;
@Override
public ResponseEntity<Resource> downloadFile(String filename) {
@ -96,7 +96,7 @@ public class ParticleController implements ParticlesApi {
return ResponseEntity.status(404).build();
}
ResponseEntity<Void> voidResponseEntity = writeContentToFile(file, filename, content);
notifyServerOfFileUpload(filename);
// notifyServerOfFileUpload(filename);
return voidResponseEntity;
}
@ -116,35 +116,35 @@ public class ParticleController implements ParticlesApi {
}
ResponseEntity<Void> voidResponseEntity = writeContentToFile(file, filename, content);
notifyServerOfFileUpload(uuid, filename);
// notifyServerOfFileUpload(uuid, filename);
return voidResponseEntity;
}
private void notifyServerOfFileUpload(String filename) {
String notificationUrl = String.format("http://%s/notify/%s.json", notificationServerUrl, filename);
sendNotification(notificationUrl, String.format("file upload: %s", filename));
}
private void notifyServerOfFileUpload(String uuid, String filename) {
String notificationUrl = String.format("%s/notify/%s/%s.json", notificationServerUrl, uuid, filename);
sendNotification(notificationUrl, String.format("file upload for user %s: %s", uuid, filename));
}
private void sendNotification(String notificationUrl, String logDescription) {
try {
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> response = restTemplate.getForEntity(notificationUrl, String.class);
if (response.getStatusCode().is2xxSuccessful()) {
log.info("Successfully notified server of {}", logDescription);
} else {
log.warn("Failed to notify server of {}, status: {}",
logDescription, response.getStatusCode());
}
} catch (Exception e) {
log.error("Error notifying server of {}", logDescription, e);
}
}
// private void notifyServerOfFileUpload(String filename) {
// String notificationUrl = String.format("http://%s/notify/%s.json", notificationServerUrl, filename);
// sendNotification(notificationUrl, String.format("file upload: %s", filename));
// }
//
// private void notifyServerOfFileUpload(String uuid, String filename) {
// String notificationUrl = String.format("%s/notify/%s/%s.json", notificationServerUrl, uuid, filename);
// sendNotification(notificationUrl, String.format("file upload for user %s: %s", uuid, filename));
// }
//
// private void sendNotification(String notificationUrl, String logDescription) {
// try {
// RestTemplate restTemplate = new RestTemplate();
// ResponseEntity<String> response = restTemplate.getForEntity(notificationUrl, String.class);
//
// if (response.getStatusCode().is2xxSuccessful()) {
// log.info("Successfully notified server of {}", logDescription);
// } else {
// log.warn("Failed to notify server of {}, status: {}",
// logDescription, response.getStatusCode());
// }
// } catch (Exception e) {
// log.error("Error notifying server of {}", logDescription, e);
// }
// }
private ResponseEntity<Void> writeContentToFile(File dir, String filename, MultipartFile content) {