basic firebase connection + notification structure
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package SuMoC.backend.dev;
|
||||
|
||||
import SuMoC.backend.scheduling.ScheduledTasks;
|
||||
import SuMoC.backend.trenddetection.services.StatTableUpdateService;
|
||||
import SuMoC.backend.trend.services.StatTableUpdateService;
|
||||
import com.google.firebase.messaging.FirebaseMessaging;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -20,6 +23,8 @@ public class DevController {
|
||||
|
||||
private final StatTableUpdateService statTableUpdateService;
|
||||
|
||||
private final FirebaseMessaging firebaseMessaging;
|
||||
|
||||
@PostMapping("/trigger-trend-calculation")
|
||||
public void triggerTrendCalculation() {
|
||||
LocalDate dayOfLastWeek = LocalDate.now().minusDays(7);
|
||||
@@ -29,4 +34,21 @@ public class DevController {
|
||||
statTableUpdateService.updateWeeklyMobilityStatsForAllUsers(day2WeeksAgo);
|
||||
statTableUpdateService.updateWeeklyMobilityStatsForAllUsers(day3WeeksAgo);
|
||||
}
|
||||
|
||||
@GetMapping("/test-firebase")
|
||||
public ResponseEntity<String> testFirebaseConnection() {
|
||||
try {
|
||||
// Send to a topic (no device registration needed)
|
||||
String message = firebaseMessaging.sendAsync(
|
||||
com.google.firebase.messaging.Message.builder()
|
||||
.setTopic("test-topic")
|
||||
.putData("test", "connection-check")
|
||||
.build()
|
||||
).get();
|
||||
return ResponseEntity.ok("✓ Firebase message sent to topic: " + message);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(500).body("✗ Failed: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user