Skip to content

Commit

Permalink
feat: 인터렉션 발송 시 앱 알람이 꺼져있을때 푸시알림만 안보내도록 한다. (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdomo authored Jul 19, 2023
1 parent d19ff0e commit 81fa86c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import com.depromeet.whatnow.events.domainEvent.InteractionFixedEvent
import mu.KLogger
import mu.KotlinLogging
import org.springframework.scheduling.annotation.Async
import org.springframework.transaction.annotation.Propagation
import org.springframework.transaction.annotation.Transactional
import org.springframework.transaction.event.TransactionPhase
import org.springframework.transaction.event.TransactionalEventListener

Expand All @@ -23,6 +25,7 @@ class InteractionFixedEventHandler(
val logger: KLogger = KotlinLogging.logger {}

@Async
@Transactional(propagation = Propagation.REQUIRES_NEW)
@TransactionalEventListener(classes = [InteractionFixedEvent::class], phase = TransactionPhase.AFTER_COMMIT)
fun handleInteractionFixedEvent(event: InteractionFixedEvent) {
val promiseId = event.promiseId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,19 @@ class InteractionHistoryRegisterHandler(
}

val targetUser = userAdapter.queryUser(event.targetUserId)
if (!targetUser.fcmNotification.appAlarm) {
return
}

val user = userAdapter.queryUser(event.userId)

val data: MutableMap<String, String> = mutableMapOf()
data["notificationType"] = NotificationType.INTERACTION.name

fcmService.sendMessageAsync(
targetUser.fcmNotification.fcmToken,
"이모지 투척!",
"from. $user.nickname",
data,
)
if (targetUser.fcmNotification.appAlarm) {
fcmService.sendMessageAsync(
targetUser.fcmNotification.fcmToken,
"이모지 투척!",
"from. $user.nickname",
data,
)
}

notificationDomainService.saveForInteraction(event.promiseId, user.id!!, event.interactionType, targetUser.id!!)
}
Expand Down

0 comments on commit 81fa86c

Please sign in to comment.