LiveActivityController.kt
// EV Supervision Lite — built by Kevin Vavelin, Codetics
// https://codetics.fr
// Copyright (c) 2026 Kevin Vavelin, Codetics
// SPDX-License-Identifier: LicenseRef-Codetics-Attribution-1.0
package fr.codetics.ev_server.controllers.notifications
import fr.codetics.ev_server.core.AppPrincipal
import fr.codetics.ev_server.models.notifications.LiveActivityInput
import fr.codetics.ev_server.models.notifications.LiveActivityStartTokenInput
import fr.codetics.ev_server.services.notifications.LiveActivityService
import org.springframework.security.access.prepost.PreAuthorize
import org.springframework.security.core.annotation.AuthenticationPrincipal
import org.springframework.web.bind.annotation.DeleteMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping("/api/v1/account/live-activities")
@PreAuthorize("isAuthenticated()")
class LiveActivityController(private val activities: LiveActivityService) {
@PostMapping
fun register(@RequestBody input: LiveActivityInput, @AuthenticationPrincipal user: AppPrincipal) =
activities.register(user, input)
@DeleteMapping("/{token}")
fun unregister(@PathVariable token: String, @AuthenticationPrincipal user: AppPrincipal) =
activities.unregister(user, token)
@PostMapping("/start-tokens")
fun registerStartToken(@RequestBody input: LiveActivityStartTokenInput, @AuthenticationPrincipal user: AppPrincipal) =
activities.registerStartToken(user, input)
@DeleteMapping("/start-tokens/{token}")
fun unregisterStartToken(@PathVariable token: String, @AuthenticationPrincipal user: AppPrincipal) =
activities.unregisterStartToken(user, token)
}