made firebase config optional so backend starts without a key present
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good

This commit is contained in:
2026-01-13 08:50:48 +01:00
parent 23da358686
commit 7e8edab77a
5 changed files with 23 additions and 6 deletions
@@ -5,7 +5,7 @@ import SuMoC.backend.meteo.MeteoClient;
import SuMoC.backend.scheduling.ScheduledTasks;
import SuMoC.backend.trend.services.StatTableUpdateService;
import com.google.firebase.messaging.FirebaseMessaging;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
@@ -18,19 +18,27 @@ import java.time.LocalDate;
@RestController
@RequestMapping("/dev")
@Profile("dev")
@RequiredArgsConstructor
public class DevController {
private final ScheduledTasks scheduledTasks;
private final StatTableUpdateService statTableUpdateService;
private final FirebaseMessaging firebaseMessaging;
private final MeteoClient meteoClient;
private final ForecastService forecastService;
public DevController(
ScheduledTasks scheduledTasks,
StatTableUpdateService statTableUpdateService,
@Autowired(required = false) FirebaseMessaging firebaseMessaging,
MeteoClient meteoClient,
ForecastService forecastService) {
this.scheduledTasks = scheduledTasks;
this.statTableUpdateService = statTableUpdateService;
this.firebaseMessaging = firebaseMessaging;
this.meteoClient = meteoClient;
this.forecastService = forecastService;
}
@PostMapping("/trigger-trend-calculation")
public void triggerTrendCalculation() {
LocalDate dayOfLastWeek = LocalDate.now().minusDays(7);
@@ -43,6 +51,10 @@ public class DevController {
@GetMapping("/test-firebase")
public ResponseEntity<String> testFirebaseConnection() {
if (firebaseMessaging == null) {
return ResponseEntity.status(503)
.body("✗ Firebase is not configured (firebase.config.enabled=false)");
}
try {
// Send to a topic (no device registration needed)
String message = firebaseMessaging.sendAsync(