Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#40,41,42,43,44,45,46,47 - 알림 관련 기능 구현했습니다. #61

Merged
merged 55 commits into from
Aug 3, 2024

Conversation

kpeel5839
Copy link
Contributor

@kpeel5839 kpeel5839 commented Aug 2, 2024

1. 🔗 관련 이슈

2. 📄 구현한 내용 또는 수정한 내용

알림 관련 기능 완료했어요.
알림을 조회, 읽음처리, 이벤트를 통한 알림 생성과 푸시 알림을 추가했습니다.

3. 🙌 추가적으로 알리고 싶은 내용

기천짱 브랜치 명을 이상하게 했네요 ㅠㅠ 미안해요. 일단 자고, 어디를 리뷰해야 할 지 댓글 남겨놓도록 할게요.
이번에도 테스트 코드가 많을 뿐이지, 프로덕션 코드는 1500줄 정도 될 거에요.

4. 🙄 TODO / 고민하고 있는 것들

5. ✅ 배포 Checklist

  • 본인을 Assign 해주세요.
  • 본인을 제외한 백엔드 개발자를 리뷰어로 지정해주세요.
  • 변경된 DB 업데이트 해주세요. (꼭 해주세요 배포 안돼요!!!)

@kpeel5839 kpeel5839 added 🌱기능🌱 새로운 기능을 추가해요 ! 🏋️매튜🏋️ 24기 김재연 labels Aug 2, 2024
@kpeel5839 kpeel5839 self-assigned this Aug 2, 2024
FirebaseApp.initializeApp(options)
}
} catch (e: Exception) {
e.printStackTrace()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 안지웠네 호호호

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

천천히 지워요 ㅋㅋ

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이번에 바로 지우겠읍니다.

class NotificationServiceHelperTest @Autowired constructor(
private val notificationServiceHelper: NotificationServiceHelper,
private val databaseCleanup: DatabaseCleanup
) { // TODO : Mocking 고수 기천짱 나를 도와줘..
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기천짱 요기 도와줘잉 verify 가 원하는대로 동작하지를 않아아아아

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고쳤어요!

Comment on lines +52 to +59
eventPublisher.publishEvent(
ReadMessageByReceiverEvent(
sender,
loginUser,
readMessage.id,
message.isReceiverRead
)
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수신자가 메시지를 처음 읽는 경우 알림을 보내줄 수 있도록 이벤트를 발생시키고 있어요

Comment on lines +54 to +55
) // TODO : 나중에 메시지 예약 취소하는 경우에도 해당 이벤트 발생시켜주시면 좋을 것 같아요.
// eventPublisher.publishEvent(ReceivedMessageEvent(receiver, saveMessage.id)) // TODO : 생각해보니 이것은 실제로 발송될 때, 전송되어야 하니 나중에 스케줄링 추가하실 때 해당 이벤트 추가해주실 수 있을까요?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이건 생각해보니, 이미 적용이 되었었던가 싶네요. 이거 이미 적용되어있나 기천짱?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

노노 개발해야됩니다ㅜ 나중에 개발할때 제가 추가하거나 말씀드릴게요!

import org.springframework.transaction.annotation.Transactional

@Service
class CreatedMessageNotificationService(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기는 메시지 관련 알림을 생성하고, 푸시 알림을 보내는 서비스에요

import org.springframework.stereotype.Component

@Component
class VoteNotificationEventListener(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

투표 알림 이벤트 리스너에요

requests.voteRequests
.stream()
.forEach { request -> addBallot(request, vote, user, voteTime) }
eventPublisher.publishEvent(RegisteredVoteEvent(user, vote))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

유저가 투표를 등록했을 때 이벤트에요

voteTime: LocalDateTime
) {
val receiver = VoteServiceHelper.findUser(userPort, request.userId)
eventPublisher.publishEvent(ReceivedVoteEvent(receiver))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

실제로 투표를 받은 이에게 알림을 보낼 수 있도록 해주는 이벤트에요

val readAt: LocalDateTime,
val isEnabled: Boolean,
val title: String,
val body: String,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

알림에 추가적인 사항이 생겼어요 이로 인해서 명시적으로 title과 body를 분리했어요

}

private fun isNotNotificationTrigger(numberOfSender: Int) =
numberOfSender < 5 || (numberOfSender - 5) % 3 != 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

초기 5명 이후 3명마다 알림 발생하는 로직이에요

Copy link
Contributor

@sectionr0 sectionr0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3000줄 흑흑 정말 고생하셨습니다👍👍

아무래도 길다보니 대면으로 리뷰하다보니, 많이 남길께 없네요!

수정하실 부분만 수정해주세요!

return ResponseEntity.ok(notifications)
}

@PatchMapping("{notificationId}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

슬래쉬 빠졌어요!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고마워여어어엉

}

@PatchMapping("{notificationId}")
fun readNotification(@PathVariable notificationId: Long): ResponseEntity<Void> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Void말고 코틀린이니 Unit으로 해보는건 어때요 ??

편하신대로 해주시면 떙큐!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

헐 Void 했네 ㅠㅠㅠ 미안해용 고칠게요 Java 저리갓!

Comment on lines +54 to +55
) // TODO : 나중에 메시지 예약 취소하는 경우에도 해당 이벤트 발생시켜주시면 좋을 것 같아요.
// eventPublisher.publishEvent(ReceivedMessageEvent(receiver, saveMessage.id)) // TODO : 생각해보니 이것은 실제로 발송될 때, 전송되어야 하니 나중에 스케줄링 추가하실 때 해당 이벤트 추가해주실 수 있을까요?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

노노 개발해야됩니다ㅜ 나중에 개발할때 제가 추가하거나 말씀드릴게요!

@kpeel5839 kpeel5839 merged commit 1eebd00 into develop Aug 3, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌱기능🌱 새로운 기능을 추가해요 ! 🏋️매튜🏋️ 24기 김재연
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants