-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* refactor: 기존 파일 삭제 * chore: Firebase config 추가 * feature: Ballots get Sender 추가 * feature: Vote Get Sender 추가 * refactor: findLoginUserId -> findLoginUser 변경 * feature: Notification 추가 * refactor: SendMessageService 수정 * featrue: UserClass 추가 * featrue: Print 문 제거 * refactor: Modify Message Service 수정 * feature: Event 추가 * feature: disableMessageNotification Domain Service 추가 * feature: Encourage Vote Notification Domain Service 추가 * config: FirebaseConfig 추가 * feat: Finder 추가 * feat: Notification infra 영역 추가 * feat: ClassmateValidator 추가 * test: UserClassTest 추가 * feat: VoteEventListener 추가 * feat: Notification infra 쪽 추가 * feat: NotificationController 추가 * feat: Request, Response 추가 * feat: Notification Scheduler 추가 * feat: SignUpVoteNotificationService 추가 * feat: RegisteredVoteNotificationService 추가 * feat: ReceivedMessageNotificationService 추가 * feat: ReadMessageByReceiverService 추가 * feat: DisabledNotificationUseCase 추가 * feat: InquiryNotificationUseCase 정의 * feat: MessageNotificationUseCase 정의 * feat: VoteNotificationUseCase 정의 * feat: VoteNotificationEventListener 추가 * feat: OpenMessageNotificationService 추가 * feat: MessageNotificationEventListener 추가 * feat: NotificationInfo 추가 * feat: EndVoteNotificationService 추가 * feat: DisabledNotificationService 추가 * feat: InquiryNotificationService 추가 * feat: NotificationSendService, Helper 추가 * feat: CreatedVoteNotificationService 추가 * feat: CreatedMessageNotificationService 추가 * feat: ReceivedMessageNotificationService Test 추가 * test: ReceivedVoteNotificationService Test 추가 * test: SignUpVoteNotificationService Test 추가 * test: EncourageVoteNotificationService Test 추가 * test: RegisteredVoteNotificationService Test 추가 * test: DisabledMessageNotificationByLimitService Test 추가 * refactor: Naming 변경 및 테스트 수정 * refactor: 슬래시 추가 * refactor: Void->Unit으로 변경... 자바 저리가 * refactor: 사용하지 않는 프린트 스택 제거 * feature: fcm 모듈 추가 * chore: 모듈 의존성 추가 * test: 인프라 변경 및 로직 변경 후 테스트 수정
- Loading branch information
Showing
94 changed files
with
3,302 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.wespot.config | ||
|
||
import com.google.auth.oauth2.GoogleCredentials | ||
import com.google.firebase.FirebaseApp | ||
import com.google.firebase.FirebaseOptions | ||
import jakarta.annotation.PostConstruct | ||
import org.springframework.context.annotation.Configuration | ||
import java.io.FileInputStream | ||
|
||
@Configuration | ||
class FirebaseConfig { | ||
|
||
@PostConstruct | ||
fun init() { | ||
try { | ||
val serviceAccount = FileInputStream("src/main/resources/config/serviceAccountKey.json") | ||
val options = FirebaseOptions.builder() | ||
.setCredentials(GoogleCredentials.fromStream(serviceAccount)) | ||
.build() | ||
|
||
if (FirebaseApp.getApps().isEmpty()) { | ||
FirebaseApp.initializeApp(options) | ||
} | ||
} catch (e: Exception) { | ||
throw IllegalArgumentException("Firebase APP 연결에 실패했습니다.") | ||
} | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/kotlin/com/wespot/notification/NotificationController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.wespot.notification | ||
|
||
import com.wespot.notification.dto.NotificationResponses | ||
import com.wespot.notification.port.`in`.InquiryNotificationUseCase | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PatchMapping | ||
import org.springframework.web.bind.annotation.PathVariable | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
|
||
@RestController | ||
@RequestMapping("/api/v1/notifications") | ||
class NotificationController( | ||
private val inquiryNotificationUseCase: InquiryNotificationUseCase | ||
) { | ||
|
||
@GetMapping | ||
fun getNotifications(): ResponseEntity<NotificationResponses> { | ||
val notifications = inquiryNotificationUseCase.getNotifications() | ||
|
||
return ResponseEntity.ok(notifications) | ||
} | ||
|
||
@PatchMapping("/{notificationId}") | ||
fun readNotification(@PathVariable notificationId: Long): ResponseEntity<Unit> { | ||
inquiryNotificationUseCase.readNotification(notificationId) | ||
|
||
return ResponseEntity.noContent() | ||
.build() | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
app/src/main/kotlin/com/wespot/notification/schedule/NotificationScheduler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.wespot.notification.schedule | ||
|
||
import com.wespot.notification.port.`in`.DisabledNotificationUseCase | ||
import com.wespot.notification.port.`in`.MessageNotificationUseCase | ||
import com.wespot.notification.port.`in`.VoteNotificationUseCase | ||
import org.springframework.scheduling.annotation.Scheduled | ||
import org.springframework.stereotype.Component | ||
import java.time.LocalDate | ||
|
||
@Component | ||
class NotificationScheduler( | ||
private val disabledNotificationUseCase: DisabledNotificationUseCase, | ||
private val voteNotificationUseCase: VoteNotificationUseCase, | ||
private val messageNotificationUseCase: MessageNotificationUseCase, | ||
) { | ||
|
||
@Scheduled(cron = "0 0 0 * * *") // 매일 00시 실행 | ||
fun disableVoteNotifications() { | ||
val today = LocalDate.now() | ||
disabledNotificationUseCase.disableVoteNotifications(today) | ||
} | ||
|
||
@Scheduled(cron = "0 0 22 * * *") // 매일 00시 실행 | ||
fun disableMessageNotifications() { | ||
val today = LocalDate.now() | ||
disabledNotificationUseCase.disableMessageNotifications(today) | ||
} | ||
|
||
@Scheduled(cron = "0 0 9,15,21 * * *") // 매일 9, 15, 21시 실행 | ||
fun encourageVote() { | ||
voteNotificationUseCase.encourageVote() | ||
} | ||
|
||
@Scheduled(cron = "0 0 17 * * *") // 매일 17시 실행 | ||
fun openMessage() { | ||
messageNotificationUseCase.openMessage() | ||
} | ||
|
||
} |
Submodule config
updated
from ae1b5a to 72a45c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
app/src/test/kotlin/com/wespot/notification/domain/NotificationInfoTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.wespot.notification.domain | ||
|
||
import com.google.firebase.messaging.Notification | ||
import com.wespot.notification.NotificationInfo | ||
import com.wespot.notification.NotificationType | ||
import io.kotest.core.spec.style.BehaviorSpec | ||
import io.kotest.matchers.shouldBe | ||
import io.mockk.every | ||
import io.mockk.mockkStatic | ||
import java.time.LocalDate | ||
|
||
class NotificationInfoTest : BehaviorSpec({ | ||
|
||
given("NotificationInfo에서") { | ||
val now = LocalDate.now() | ||
val notificationInfo = NotificationInfo.createInitialState( | ||
com.wespot.notification.Notification.createVoteInitialState( | ||
0, | ||
NotificationType.VOTE, | ||
now, | ||
"title", | ||
"body" | ||
) | ||
) | ||
`when`("Notification을") { | ||
val notification = notificationInfo.getNotification() | ||
then("반환받는다.") { | ||
notification::class shouldBe Notification::class | ||
} | ||
} | ||
`when`("Data를") { | ||
val data = notificationInfo.getData() | ||
then("반환받는다.") { | ||
data["targetId"] shouldBe "0" | ||
data["date"] shouldBe now.toString() | ||
data["type"] shouldBe "VOTE" | ||
} | ||
} | ||
} | ||
|
||
given("NotificationInfo를 생성할 때") { | ||
mockkStatic(LocalDate::class) | ||
|
||
`when`("Vote용으로") { | ||
val now = LocalDate.now() | ||
val notification = com.wespot.notification.Notification.createVoteInitialState( | ||
0, | ||
NotificationType.VOTE, | ||
now, | ||
"title", | ||
"body" | ||
) | ||
val notificationInfo = NotificationInfo.createInitialState(notification) | ||
then("생성한다.") { | ||
notificationInfo.targetId shouldBe 0 | ||
notificationInfo.date shouldBe now | ||
notificationInfo.type shouldBe NotificationType.VOTE | ||
notificationInfo.title shouldBe "title" | ||
notificationInfo.body shouldBe "body" | ||
} | ||
} | ||
`when`("Message용으로") { | ||
val now = LocalDate.now() | ||
every { LocalDate.now() } returns now | ||
val notification = com.wespot.notification.Notification.createMessageInitialState( | ||
0, | ||
NotificationType.MESSAGE, | ||
1, | ||
"title", | ||
"body" | ||
) | ||
val notificationInfo = NotificationInfo.createInitialState(notification) | ||
then("생성한다.") { | ||
notificationInfo.targetId shouldBe 1 | ||
notificationInfo.date shouldBe now | ||
notificationInfo.type shouldBe NotificationType.MESSAGE | ||
notificationInfo.title shouldBe "title" | ||
notificationInfo.body shouldBe "body" | ||
} | ||
} | ||
} | ||
|
||
}) |
Oops, something went wrong.