Skip to content

Commit

Permalink
🧩 :: (#697) 알림 전체 구독/해제 api
Browse files Browse the repository at this point in the history
  • Loading branch information
4mjeo authored Aug 17, 2024
2 parents 1f2bd0e + 301238b commit a544bd2
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package team.retum.jobis.domain.notification.usecase.subscribe;

import lombok.RequiredArgsConstructor;
import team.retum.jobis.common.annotation.UseCase;
import team.retum.jobis.domain.notification.model.Topic;
import team.retum.jobis.domain.notification.spi.CommandNotificationPort;

@RequiredArgsConstructor
@UseCase
public class SubscribeAllTopicsUseCase {

private final CommandNotificationPort commandNotificationPort;

public void execute(String token) {
for (Topic topic : Topic.values()) {
commandNotificationPort.subscribeTopic(token, topic);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package team.retum.jobis.domain.notification.usecase.subscribe;

import lombok.RequiredArgsConstructor;
import team.retum.jobis.common.annotation.UseCase;
import team.retum.jobis.domain.notification.model.Topic;
import team.retum.jobis.domain.notification.spi.CommandNotificationPort;

@RequiredArgsConstructor
@UseCase
public class UnsubscribeAllTopicsUseCase {

private final CommandNotificationPort commandNotificationPort;

public void execute(String token) {
for (Topic topic : Topic.values()) {
commandNotificationPort.unsubscribeTopic(token, topic);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import team.retum.jobis.domain.notification.model.Topic;
import team.retum.jobis.domain.notification.usecase.QueryNotificationsUseCase;
import team.retum.jobis.domain.notification.usecase.ReadNotificationUseCase;
import team.retum.jobis.domain.notification.usecase.subscribe.SubscribeAllTopicsUseCase;
import team.retum.jobis.domain.notification.usecase.subscribe.SubscribeTopicUseCase;
import team.retum.jobis.domain.notification.usecase.subscribe.UnsubscribeAllTopicsUseCase;
import team.retum.jobis.domain.notification.usecase.subscribe.UnsubscribeTopicUseCase;

@RequiredArgsConstructor
Expand All @@ -27,6 +29,8 @@ public class NotificationWebAdapter {
private final ReadNotificationUseCase readNotificationUseCase;
private final UnsubscribeTopicUseCase unsubscribeTopicUseCase;
private final SubscribeTopicUseCase subscribeTopicUseCase;
private final SubscribeAllTopicsUseCase subscribeAllTopicsUseCase;
private final UnsubscribeAllTopicsUseCase unsubscribeAllTopicsUseCase;

@GetMapping
public QueryNotificationsResponse queryNotifications(@RequestParam(value = "is_new", required = false) Boolean isNew) {
Expand All @@ -48,4 +52,14 @@ public void subscribeTopic(@RequestParam("topic") Topic topic, @RequestParam("to
public void unsubscribeTopic(@RequestParam("topic") Topic topic, @RequestParam("token") String token) {
unsubscribeTopicUseCase.execute(token, topic);
}

@PostMapping("/topics")
public void subscribeAllTopics(@RequestParam("token") String token) {
subscribeAllTopicsUseCase.execute(token);
}

@DeleteMapping("/topics")
public void unsubscribeAllTopics(@RequestParam("token") String token) {
unsubscribeAllTopicsUseCase.execute(token);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ protected SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.requestMatchers(HttpMethod.PATCH, "/notifications/{notification-id}").authenticated()
.requestMatchers(HttpMethod.POST, "/notifications/topic").authenticated()
.requestMatchers(HttpMethod.DELETE, "/notifications/topic").authenticated()
.requestMatchers(HttpMethod.POST, "/notifications/topics").authenticated()
.requestMatchers(HttpMethod.DELETE, "/notifications/topics").authenticated()
.anyRequest().authenticated()

)
Expand Down

0 comments on commit a544bd2

Please sign in to comment.