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

♻️ Refactor notification event data #19

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies {
implementation 'org.springframework.cloud:spring-cloud-aws-messaging:2.2.4.RELEASE'
implementation 'org.springframework.kafka:spring-kafka'
implementation 'software.amazon.awssdk:sns:2.21.37'
implementation 'io.github.lotteon-maven:blooming-blooms-utils:202312140709'
implementation 'io.github.lotteon-maven:blooming-blooms-utils:202312180304'

testImplementation 'org.mockito:mockito-core:4.8.0'

Expand Down Expand Up @@ -80,7 +80,7 @@ jacocoTestCoverageVerification {
value = 'COVEREDRATIO'
minimum = 0.80
}
excludes = ["*.mapper*", "**.emitter.**"]
excludes = ["*.mapper*", "**.emitter.**", "**.infrastructure.**"]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public static UnreadNotificationCount getData(Long unreadNotificationCount) {
@AllArgsConstructor
public static class NotificationInformation {
private Long id;
private String type;
private String content;
private String redirectUrl;
private String phoneNumber;
Expand All @@ -91,7 +92,8 @@ public static List<NotificationInformation> getResaleNotificationData(
item ->
NotificationInformation.builder()
.id(item.getUserId())
.content(
.content(restoreNotification.getPublishInformation().getContent())
.type(
restoreNotification
.getPublishInformation()
.getNotificationKind()
Expand All @@ -112,7 +114,7 @@ public static NotificationInformation getSSEData(
.role(publishNotificationInformation.getRole())
.notificationKind(publishNotificationInformation.getNotificationKind())
.redirectUrl(publishNotificationInformation.getNotificationUrl())
.content(publishNotificationInformation.getNotificationKind().getMessage())
.type(publishNotificationInformation.getNotificationKind().getMessage())
.build();
}

Expand All @@ -121,7 +123,7 @@ public static NotificationInformation getDeliveryNotificationData(
return NotificationInformation.builder()
.role(notificationData.getPublishInformation().getRole())
.phoneNumber(notificationData.getWhoToNotify().getPhoneNumber())
.content(notificationData.getWhoToNotify().getDeliveryStatus().getMessage())
.type(notificationData.getWhoToNotify().getDeliveryStatus().getMessage())
.redirectUrl(notificationData.getPublishInformation().getNotificationUrl())
.id(notificationData.getWhoToNotify().getUserId())
.notificationKind(notificationData.getPublishInformation().getNotificationKind())
Expand All @@ -136,7 +138,7 @@ public static NotificationInformation getSMSData(
.id(notification.getWhoToNotify().getUserId())
.phoneNumber(notification.getWhoToNotify().getPhoneNumber())
.redirectUrl(notification.getPublishInformation().getNotificationUrl())
.content(notification.getPublishInformation().getNotificationKind().getMessage())
.type(notification.getPublishInformation().getNotificationKind().getMessage())
.build();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public void consumeOrderCancelNotificationQueue(
ack.acknowledge();
}

@SqsListener(
@SqsListener(
value = "${cloud.aws.sqs.inquery-response-notification-queue.name}",
deletionPolicy = SqsMessageDeletionPolicy.NEVER)
public void consumeInqueryResponseNotificationQueue(
Expand All @@ -284,7 +284,8 @@ public void consumeInqueryResponseNotificationQueue(
message,
objectMapper
.getTypeFactory()
.constructParametricType(NotificationData.class, InqueryResponseNotification.class));
.constructParametricType(
NotificationData.class, InqueryResponseNotification.class));
NotificationData<InqueryResponseNotification> notification =
NotificationData.notifyData(
orderCancel.getWhoToNotify(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,21 @@ public class SendSMS implements InfrastructureActionHandler<NotificationInformat
private final AWSConfiguration awsConfiguration;

private static PublishRequest makePublishRequest(NotificationInformation notifyData) {
return PublishRequest.builder()
.message(notifyData.getContent() + "\n" + notifyData.getRedirectUrl())
.phoneNumber("+82" + notifyData.getPhoneNumber())
.build();
if (notifyData.getContent() == null)
return PublishRequest.builder()
.message(notifyData.getType() + "\n" + notifyData.getRedirectUrl())
.phoneNumber("+82" + notifyData.getPhoneNumber())
.build();
else
return PublishRequest.builder()
.message(
notifyData.getType()
+ "\n"
+ notifyData.getContent()
+ "\n"
+ notifyData.getRedirectUrl())
.phoneNumber("+82" + notifyData.getPhoneNumber())
.build();
}

private static void setSMSAttribute(SnsClient snsClient) {
Expand Down
Loading