diff --git a/src/main/kotlin/org/gitanimals/render/domain/UserService.kt b/src/main/kotlin/org/gitanimals/render/domain/UserService.kt index 5b69185..444f3a9 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/UserService.kt +++ b/src/main/kotlin/org/gitanimals/render/domain/UserService.kt @@ -53,7 +53,7 @@ class UserService( @Retryable(retryFor = [ObjectOptimisticLockingFailureException::class], maxAttempts = 100) @Transactional - fun giveBonusPersona(name: String, persona: String) { + fun givePersonaByCoupon(name: String, persona: String) { requireIdempotency("$name:bonus") val user = getUserByName(name) diff --git a/src/main/kotlin/org/gitanimals/render/saga/UsedCouponSagaHandlers.kt b/src/main/kotlin/org/gitanimals/render/saga/UsedCouponSagaHandlers.kt index 3f3e407..c62027e 100644 --- a/src/main/kotlin/org/gitanimals/render/saga/UsedCouponSagaHandlers.kt +++ b/src/main/kotlin/org/gitanimals/render/saga/UsedCouponSagaHandlers.kt @@ -14,11 +14,15 @@ class UsedCouponSagaHandlers( @SagaCommitListener(event = CouponUsed::class) fun handleCouponUsedCommitEvent(sagaCommitEvent: SagaCommitEvent) { val couponUsed = sagaCommitEvent.decodeEvent(CouponUsed::class) - if (couponUsed.code != "NEW_USER_BONUS_PET") { + if ((couponUsed.code in acceptableCouponCodes).not()) { return } sagaCommitEvent.setNextEvent(couponUsed) - userService.giveBonusPersona(couponUsed.username, couponUsed.dynamic) + userService.givePersonaByCoupon(couponUsed.username, couponUsed.dynamic) + } + + private companion object { + private val acceptableCouponCodes = listOf("NEW_USER_BONUS_PET", "HALLOWEEN_2024", "HALLOWEEN_2024_STAR_BONUS") } }