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

[BE] feat: 채팅을 보낼 때 FCM으로 데이터를 같이 전송 #451

Merged
merged 5 commits into from
Aug 19, 2024

Conversation

takoyakimchi
Copy link
Contributor

@takoyakimchi takoyakimchi commented Aug 17, 2024

이슈

개발 사항

  • 채팅 메시지를 전송하면 FCM으로도 같이 전송한다.

리뷰 요청 사항 (없으면 삭제해 주세요)

  • 큰 변동 사항은 없고 subquery 쓰는 JPQL 부분만 봐주시면 좋을 것 같아요!

전달 사항 (없으면 삭제해 주세요)

  • 안드로이드랑 연결해서 작동하는 것 확인되면 추가로 리팩토링 진행할 수도 있어요.

@takoyakimchi takoyakimchi added 🖥 backend backend ✨ feat 기능 개발 labels Aug 17, 2024
@takoyakimchi takoyakimchi added this to the Sprint4 milestone Aug 17, 2024
@takoyakimchi takoyakimchi self-assigned this Aug 17, 2024
Copy link

github-actions bot commented Aug 17, 2024

Test Results

151 tests  +148   151 ✅ +148   17s ⏱️ +17s
 31 suites + 30     0 💤 ±  0 
 31 files   + 30     0 ❌ ±  0 

Results for commit 4395ff2. ± Comparison against base commit 3acce8d.

This pull request removes 3 and adds 151 tests. Note that renamed tests count towards both.
com.happy.friendogly.ExampleUnitTest ‑ addition_isCorrect
com.happy.friendogly.ExampleUnitTest ‑ addition_isCorrect2
com.happy.friendogly.ExampleUnitTest ‑ addition_isCorrect3
com.happy.friendogly.chat.service.ChatRoomCommandServiceTest ‑ 1대1 채팅방 저장 과정에서, 이미 채팅방이 존재하면 기존 채팅방 ID를 반환한다.
com.happy.friendogly.chat.service.ChatRoomCommandServiceTest ‑ 모임에 참여하지 않은 경우, 모임 채팅방에서 나갈 수 없다.
com.happy.friendogly.chat.service.ChatRoomCommandServiceTest ‑ 새로운 1대1 채팅방을 개설할 수 있다.
com.happy.friendogly.chat.service.ChatRoomCommandServiceTest ‑ 채팅방에 참여한 경우, 채팅방에서 나갈 수 있다.
com.happy.friendogly.chat.service.ChatRoomQueryServiceTest ‑ 내가 속해 있는 채팅방을 찾을 수 있다.
com.happy.friendogly.chat.service.ChatRoomQueryServiceTest ‑ 자신이 참여한 채팅방이 아니면 채팅방에서 모임 정보를 받아올 수 없다.
com.happy.friendogly.chat.service.ChatRoomQueryServiceTest ‑ 채팅방 ID로부터 모임 ID, 허용 펫 사이즈, 허용 펫 성별을 조회할 수 있다.
com.happy.friendogly.chat.service.ChatRoomQueryServiceTest ‑ 채팅방 내 멤버 세부정보를 조회할 수 있다.
com.happy.friendogly.club.domain.AddressTest ‑ [1] provinceInput=null
com.happy.friendogly.club.domain.AddressTest ‑ [2] provinceInput=
…

♻️ This comment has been updated with latest results.

Comment on lines 13 to 20
@Query("""
SELECT dt.deviceToken
FROM DeviceToken dt
WHERE dt.member.id IN (SELECT chatRoomMember.member.id
FROM ChatRoomMember chatRoomMember
WHERE chatRoomMember.chatRoom.id = :chatRoomId)
""")
List<String> findAllByChatRoomId(Long chatRoomId);
Copy link
Contributor

Choose a reason for hiding this comment

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

서브쿼리를 INNER JOIN으로 대체할 수 있겠어요.

SELECT dt.deviceToken
FROM DeviceToken dt
JOIN ChatRoomMember cm ON dt.member.id = cm.member.id
WHERE cm.chatRoom.id = :chatRoomId

JOIN을 사용하지 않고 서브 쿼리를 사용한 이유가 있을까요?

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.

서브쿼리가 단계적으로 생각하기 쉽기는 하죠

Comment on lines 87 to 88
@Override
public void sendChat(Long chatRoomId, ChatMessageResponse response) {
Copy link
Contributor

Choose a reason for hiding this comment

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

해당 메서드에서는 실제 채팅을 보내는 것이 아닌, 채팅에 대한 알람만을 보내고 있어요.
sendChatNotification() 와 같이 명시적으로 표현하면 어떨까요?

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

@ehtjsv2 ehtjsv2 left a comment

Choose a reason for hiding this comment

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

굳 추가 리팩토링한다면 그 PR에서 더 상세하게 보겠습니다

ehtjsv2
ehtjsv2 previously approved these changes Aug 18, 2024
@Profile("!local")
public class FcmNotificationService implements NotificationService {

private static final String DEFAULT_TITLE = "반갑개";
Copy link
Contributor

Choose a reason for hiding this comment

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

TITLE은 디폴트로 "반갑개"가 될수가 없을 수도 있을거 같아요
TITLE은 알림에서 상단에 진하게 뜨는 글씨입니다. 채팅알림에서는 보통 TITLE이 상대방의 이름 또는 채팅방이름이 되겠죠!


현재 발자국알림에서는 타이틀을 그렇게 띄워주고있는데, 채팅에서는 안드로이드쪽에서 어떻게 띄어주냐에따라 디폴트로 반갑개를 해놓아도 될 수도 있겠네요

Copy link
Contributor Author

Choose a reason for hiding this comment

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

오호 그렇군요 ~~~~!!! 모든 FCM 공통인 줄 알았어요
반영해야겠네요

jimi567
jimi567 previously approved these changes Aug 18, 2024
Copy link
Member

@jimi567 jimi567 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다.

@takoyakimchi takoyakimchi dismissed stale reviews from jimi567 and ehtjsv2 via 07d2c86 August 19, 2024 04:15
@takoyakimchi takoyakimchi merged commit 0485cb7 into develop Aug 19, 2024
3 checks passed
@takoyakimchi takoyakimchi deleted the feature/be/#446 branch August 19, 2024 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🖥 backend backend ✨ feat 기능 개발
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

채팅 메시지를 FCM + 소켓으로 송신
4 participants