feat: 포인트 지급 시 FCM data-only 푸시 메시지 전송 및 실패 시 재시도 처리
This commit is contained in:
@@ -3,6 +3,7 @@ package kr.co.vividnext.sodalive.useraction
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kr.co.vividnext.sodalive.fcm.FcmService
|
||||
import kr.co.vividnext.sodalive.point.MemberPoint
|
||||
import kr.co.vividnext.sodalive.point.MemberPointRepository
|
||||
import kr.co.vividnext.sodalive.point.PointGrantLog
|
||||
@@ -16,12 +17,14 @@ class UserActionService(
|
||||
private val repository: UserActionLogRepository,
|
||||
private val policyRepository: PointRewardPolicyRepository,
|
||||
private val grantLogRepository: PointGrantLogRepository,
|
||||
private val memberPointRepository: MemberPointRepository
|
||||
private val memberPointRepository: MemberPointRepository,
|
||||
|
||||
private val fcmService: FcmService
|
||||
) {
|
||||
|
||||
private val coroutineScope = CoroutineScope(Dispatchers.IO)
|
||||
|
||||
fun recordAction(memberId: Long, actionType: ActionType) {
|
||||
fun recordAction(memberId: Long, actionType: ActionType, pushToken: String?) {
|
||||
coroutineScope.launch {
|
||||
val now = LocalDateTime.now()
|
||||
repository.save(UserActionLog(memberId, actionType))
|
||||
@@ -56,6 +59,10 @@ class UserActionService(
|
||||
policyId = policy.id!!
|
||||
)
|
||||
)
|
||||
|
||||
if (pushToken != null) {
|
||||
fcmService.sendPointGranted(pushToken, policy.pointAmount)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user