-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BE] refactor: 알림 서비스 다른 도메인 의존성 제거 (#740)
- Loading branch information
Showing
8 changed files
with
117 additions
and
101 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
44 changes: 44 additions & 0 deletions
44
backend/src/main/java/com/happy/friendogly/notification/service/ChatNotificationService.java
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,44 @@ | ||
package com.happy.friendogly.notification.service; | ||
|
||
import static com.happy.friendogly.notification.domain.NotificationType.CHAT; | ||
|
||
import com.happy.friendogly.chatsocket.dto.response.ChatMessageSocketResponse; | ||
import com.happy.friendogly.club.domain.Club; | ||
import com.happy.friendogly.notification.repository.DeviceTokenRepository; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class ChatNotificationService { | ||
|
||
private final DeviceTokenRepository deviceTokenRepository; | ||
private final NotificationService notificationService; | ||
|
||
public ChatNotificationService( | ||
DeviceTokenRepository deviceTokenRepository, | ||
NotificationService notificationService | ||
) { | ||
this.deviceTokenRepository = deviceTokenRepository; | ||
this.notificationService = notificationService; | ||
} | ||
|
||
public void sendChatNotification(Long chatRoomId, ChatMessageSocketResponse response, Club club) { | ||
List<String> receiverTokens = deviceTokenRepository | ||
.findAllByChatRoomIdWithoutMine(chatRoomId, response.senderMemberId()); | ||
|
||
Map<String, String> data = Map.of( | ||
"chatRoomId", chatRoomId.toString(), | ||
"messageType", response.messageType().toString(), | ||
"senderMemberId", response.senderMemberId().toString(), | ||
"senderName", response.senderName(), | ||
"content", response.content(), | ||
"createdAt", response.createdAt().toString(), | ||
"profilePictureUrl", response.profilePictureUrl() == null ? "" : response.profilePictureUrl(), | ||
"clubPictureUrl", club.getImageUrl() == null ? "" : club.getImageUrl(), | ||
"clubTitle", club.getTitle().getValue() | ||
); | ||
|
||
notificationService.sendNotification("채팅", data, CHAT, receiverTokens); | ||
} | ||
} |
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
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
22 changes: 14 additions & 8 deletions
22
backend/src/main/java/com/happy/friendogly/notification/service/NotificationService.java
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 |
---|---|---|
@@ -1,16 +1,22 @@ | ||
package com.happy.friendogly.notification.service; | ||
|
||
import com.happy.friendogly.chatsocket.dto.response.ChatMessageSocketResponse; | ||
import com.happy.friendogly.club.domain.Club; | ||
import com.happy.friendogly.notification.domain.NotificationType; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public interface NotificationService { | ||
|
||
void sendFootprintNotification(String title, String content, String receiverToken); | ||
void sendNotification( | ||
String title, | ||
String content, | ||
NotificationType notificationType, | ||
List<String> receiverTokens | ||
); | ||
|
||
void sendFootprintNotification(String title, String content, List<String> receiverTokens); | ||
|
||
void sendChatNotification(Long chatRoomId, ChatMessageSocketResponse response, Club club); | ||
|
||
void sendPlaygroundJoinNotification(String title, String content, List<String> receiverTokens); | ||
void sendNotification( | ||
String title, | ||
Map<String, String> contents, | ||
NotificationType notificationType, | ||
List<String> receiverTokens | ||
); | ||
} |
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
Oops, something went wrong.