-
Notifications
You must be signed in to change notification settings - Fork 7
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
푸시 알림 기능 리팩토링 및 알림 선택 구독 기능 추가
- Loading branch information
Showing
134 changed files
with
3,300 additions
and
1,730 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
45 changes: 45 additions & 0 deletions
45
backend/src/main/java/mouda/backend/chat/implement/sender/ChatNotificationSender.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,45 @@ | ||
package mouda.backend.chat.implement.sender; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.ApplicationEventPublisher; | ||
import org.springframework.stereotype.Component; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import mouda.backend.common.config.UrlConfig; | ||
import mouda.backend.darakbangmember.domain.DarakbangMember; | ||
import mouda.backend.moim.domain.Moim; | ||
import mouda.backend.moim.implement.finder.ChatRecipientFinder; | ||
import mouda.backend.notification.domain.NotificationEvent; | ||
import mouda.backend.notification.domain.NotificationType; | ||
import mouda.backend.notification.domain.Recipient; | ||
|
||
@Component | ||
@EnableConfigurationProperties(UrlConfig.class) | ||
@RequiredArgsConstructor | ||
public class ChatNotificationSender { | ||
|
||
private final UrlConfig urlConfig; | ||
private final ChatRecipientFinder chatRecipientFinder; | ||
private final ApplicationEventPublisher eventPublisher; | ||
|
||
public void sendChatNotification(Moim moim, DarakbangMember sender, NotificationType notificationType, long chatRoomId) { | ||
List<Recipient> recipients = chatRecipientFinder.getChatNotificationRecipients(moim.getId(), sender); | ||
NotificationEvent notificationEvent = createNotificationEvent(moim, sender, notificationType, recipients, chatRoomId); | ||
|
||
eventPublisher.publishEvent(notificationEvent); | ||
} | ||
|
||
private NotificationEvent createNotificationEvent(Moim moim, DarakbangMember sender, NotificationType notificationType, List<Recipient> recipients, long chatRoomId) { | ||
String message; | ||
if (notificationType.isConfirmedType()) { | ||
message = notificationType.createMessage(moim.getTitle()); | ||
} else { | ||
message = notificationType.createMessage(sender.getNickname()); | ||
} | ||
|
||
return new NotificationEvent( | ||
notificationType, moim.getTitle(), message, urlConfig.getChatRoomUrl(moim.getDarakbangId(), chatRoomId), recipients, moim.getDarakbangId(), chatRoomId); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
backend/src/main/java/mouda/backend/common/config/UrlConfig.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,25 @@ | ||
package mouda.backend.common.config; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@ConfigurationProperties(prefix = "url") | ||
@Getter | ||
@RequiredArgsConstructor | ||
public class UrlConfig { | ||
|
||
private final String base; | ||
private final String moim; | ||
private final String chat; | ||
private final String chatroom; | ||
|
||
public String getChatRoomUrl(long darakbangId, long chatRoomId) { | ||
return base + String.format(chatroom, darakbangId, chatRoomId); | ||
} | ||
|
||
public String getMoimUrl(long darakbangId, long moimId) { | ||
return base + String.format(moim, darakbangId, moimId); | ||
} | ||
} |
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
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
Oops, something went wrong.