From 5b523fccc9f1f57709dd73269d4175455338f48e Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Fri, 26 Jan 2024 21:08:37 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=80=9A=E7=9F=A5=E3=81=AE=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=82=BF=E3=83=BC=E3=83=95=E3=82=A7=E3=82=A4=E3=82=B9?= =?UTF-8?q?=E3=82=92=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/model/notification/Notification.kt | 12 +++++++ .../NotificationManagimentService.kt | 7 ++++ .../notification/NotificationRequest.kt | 36 +++++++++++++++++++ .../notification/NotificationService.kt | 8 +++++ 4 files changed, 63 insertions(+) create mode 100644 src/main/kotlin/dev/usbharu/hideout/core/domain/model/notification/Notification.kt create mode 100644 src/main/kotlin/dev/usbharu/hideout/core/service/notification/NotificationManagimentService.kt create mode 100644 src/main/kotlin/dev/usbharu/hideout/core/service/notification/NotificationRequest.kt create mode 100644 src/main/kotlin/dev/usbharu/hideout/core/service/notification/NotificationService.kt diff --git a/src/main/kotlin/dev/usbharu/hideout/core/domain/model/notification/Notification.kt b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/notification/Notification.kt new file mode 100644 index 00000000..e1b48e5d --- /dev/null +++ b/src/main/kotlin/dev/usbharu/hideout/core/domain/model/notification/Notification.kt @@ -0,0 +1,12 @@ +package dev.usbharu.hideout.core.domain.model.notification + +import java.time.Instant + +data class Notification( + val userId: Long, + val sourceActorId: Long?, + val postId: Long?, + val text: String?, + val reactionId: Long?, + val createdAt: Instant +) diff --git a/src/main/kotlin/dev/usbharu/hideout/core/service/notification/NotificationManagimentService.kt b/src/main/kotlin/dev/usbharu/hideout/core/service/notification/NotificationManagimentService.kt new file mode 100644 index 00000000..3281087d --- /dev/null +++ b/src/main/kotlin/dev/usbharu/hideout/core/service/notification/NotificationManagimentService.kt @@ -0,0 +1,7 @@ +package dev.usbharu.hideout.core.service.notification + +import dev.usbharu.hideout.core.domain.model.relationship.Relationship + +interface NotificationManagimentService { + fun sendNotification(relationship: Relationship, notificationRequest: NotificationRequest): Boolean +} diff --git a/src/main/kotlin/dev/usbharu/hideout/core/service/notification/NotificationRequest.kt b/src/main/kotlin/dev/usbharu/hideout/core/service/notification/NotificationRequest.kt new file mode 100644 index 00000000..3080c32e --- /dev/null +++ b/src/main/kotlin/dev/usbharu/hideout/core/service/notification/NotificationRequest.kt @@ -0,0 +1,36 @@ +package dev.usbharu.hideout.core.service.notification + +sealed class NotificationRequest(open val userId: Long, open val sourceActorId: Long) + +interface PostId { + val postId: Long +} + +data class MentionNotificationRequest( + override val userId: Long, override val sourceActorId: Long, override val postId: Long +) : NotificationRequest( + userId, sourceActorId +), PostId + +data class PostNotificationRequest( + override val userId: Long, override val sourceActorId: Long, override val postId: Long + +) : NotificationRequest(userId, sourceActorId), PostId + +data class RepostNotificationRequest( + override val userId: Long, override val sourceActorId: Long, override val postId: Long +) : NotificationRequest(userId, sourceActorId), PostId + +data class FollowNotificationRequest( + override val userId: Long, override val sourceActorId: Long, override val postId: Long + +) : NotificationRequest(userId, sourceActorId), PostId + +data class FollowRequestNotificationRequest( + override val userId: Long, override val sourceActorId: Long, override val postId: Long +) : NotificationRequest(userId, sourceActorId), PostId + +data class ReactionNotificationRequest( + override val userId: Long, override val sourceActorId: Long, override val postId: Long, val reactionId: Long + +) : NotificationRequest(userId, sourceActorId), PostId diff --git a/src/main/kotlin/dev/usbharu/hideout/core/service/notification/NotificationService.kt b/src/main/kotlin/dev/usbharu/hideout/core/service/notification/NotificationService.kt new file mode 100644 index 00000000..9c453e49 --- /dev/null +++ b/src/main/kotlin/dev/usbharu/hideout/core/service/notification/NotificationService.kt @@ -0,0 +1,8 @@ +package dev.usbharu.hideout.core.service.notification + +import dev.usbharu.hideout.core.domain.model.notification.Notification + +interface NotificationService { + suspend fun publishNotify(notificationRequest: NotificationRequest): Notification + suspend fun unpublishNotify(notificationId: Long) +}