Skip to content

Commit

Permalink
feat: 알림이 특정 키를 가지도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Dltmd202 committed Aug 22, 2024
1 parent c85d4f5 commit 09e75d8
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ import java.io.Serializable

interface Notification : Serializable {
val method: NotificationMethod
val keyPrefix: String
val keyValue: String

fun getNotificationKey(): String {
return "$keyPrefix:$keyValue"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ import com.backgu.amaker.domain.user.UserDevice
class PushNotification(
override val method: NotificationMethod,
val userDevices: List<UserDevice>,
) : Notification
) : Notification{
override val keyPrefix: String
get() = "PUSH"

override val keyValue: String
get() = userDevices.first().userId
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ import com.backgu.amaker.domain.user.User
class UserFulfilledNotification(
val user: User,
override val method: RealTimeNotificationMethod,
) : RealTimeBasedNotification(method)
) : RealTimeBasedNotification(method){
override val keyPrefix: String
get() = "USER"

override val keyValue: String
get() = user.id
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ import com.backgu.amaker.domain.notifiacation.method.RealTimeNotificationMethod
open class UserNotification(
val userId: String,
override val method: RealTimeNotificationMethod,
) : RealTimeBasedNotification(method)
) : RealTimeBasedNotification(method) {
override val keyPrefix: String
get() = "USER"

override val keyValue: String
get() = userId
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ import com.backgu.amaker.domain.notifiacation.method.RealTimeNotificationMethod
open class WorkspaceNotification(
open val workspaceId: Long,
override val method: RealTimeNotificationMethod,
) : RealTimeBasedNotification(method)
) : RealTimeBasedNotification(method){
override val keyPrefix: String
get() = "WORKSPACE"

override val keyValue: String
get() = workspaceId.toString()
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ class KafkaNotificationEventService(
private val kafkaTemplate: KafkaTemplate<String, Notification>,
) : NotificationEventService {
override fun publishNotificationEvent(notification: Notification) {
kafkaTemplate.send(KafkaConfig.NOTIFICATION_TOPIC, notification)
kafkaTemplate.send(KafkaConfig.NOTIFICATION_TOPIC, notification.getNotificationKey(), notification)
}
}

0 comments on commit 09e75d8

Please sign in to comment.