Add SSE for Razorpay QR events
All checks were successful
build-and-deploy / build-deploy (push) Successful in 34s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 34s
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.android.trisolarisserver.controller
|
||||
|
||||
import com.android.trisolarisserver.component.PropertyAccess
|
||||
import com.android.trisolarisserver.component.RazorpayQrEvents
|
||||
import com.android.trisolarisserver.controller.dto.RazorpayQrGenerateRequest
|
||||
import com.android.trisolarisserver.controller.dto.RazorpayQrEventResponse
|
||||
import com.android.trisolarisserver.controller.dto.RazorpayQrGenerateResponse
|
||||
@@ -30,6 +31,7 @@ import org.springframework.web.client.RestTemplate
|
||||
import org.springframework.web.server.ResponseStatusException
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter
|
||||
import java.time.OffsetDateTime
|
||||
import java.util.Base64
|
||||
import java.util.UUID
|
||||
@@ -42,6 +44,7 @@ class RazorpayQrPayments(
|
||||
private val settingsRepo: RazorpaySettingsRepo,
|
||||
private val qrRequestRepo: RazorpayQrRequestRepo,
|
||||
private val webhookLogRepo: RazorpayWebhookLogRepo,
|
||||
private val qrEvents: RazorpayQrEvents,
|
||||
private val restTemplate: RestTemplate,
|
||||
private val objectMapper: ObjectMapper
|
||||
) {
|
||||
@@ -259,6 +262,17 @@ class RazorpayQrPayments(
|
||||
return out
|
||||
}
|
||||
|
||||
@GetMapping("/qr/{qrId}/events/stream", produces = [MediaType.TEXT_EVENT_STREAM_VALUE])
|
||||
fun streamQrEvents(
|
||||
@PathVariable propertyId: UUID,
|
||||
@PathVariable bookingId: UUID,
|
||||
@PathVariable qrId: String,
|
||||
@AuthenticationPrincipal principal: MyPrincipal?
|
||||
): SseEmitter {
|
||||
requireRole(propertyAccess, propertyId, principal, Role.ADMIN, Role.MANAGER, Role.STAFF)
|
||||
return qrEvents.subscribe(propertyId, qrId)
|
||||
}
|
||||
|
||||
@GetMapping("/qr")
|
||||
fun listQr(
|
||||
@PathVariable propertyId: UUID,
|
||||
|
||||
Reference in New Issue
Block a user