From d205c15a5416ac0462064774334d9b5dc95958e7 Mon Sep 17 00:00:00 2001 From: thsghdud13 Date: Fri, 27 Sep 2024 20:17:45 +0900 Subject: [PATCH 1/3] =?UTF-8?q?Add=20:=20=EB=B9=84=EC=86=8D=EC=96=B4=20?= =?UTF-8?q?=ED=95=84=ED=84=B0=20=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 1 + .../java/Be9room/festime/config/BadWordFilteringConfig.java | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 src/main/java/Be9room/festime/config/BadWordFilteringConfig.java diff --git a/build.gradle b/build.gradle index 994c07b..f774355 100644 --- a/build.gradle +++ b/build.gradle @@ -37,6 +37,7 @@ dependencies { implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0' // Redis implementation 'org.springframework.boot:spring-boot-starter-data-redis' + implementation 'io.github.vaneproject:badwordfiltering:1.0.0' compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' diff --git a/src/main/java/Be9room/festime/config/BadWordFilteringConfig.java b/src/main/java/Be9room/festime/config/BadWordFilteringConfig.java new file mode 100644 index 0000000..3fe8064 --- /dev/null +++ b/src/main/java/Be9room/festime/config/BadWordFilteringConfig.java @@ -0,0 +1,2 @@ +package Be9room.festime.config;public class BadWordFilteringConfig { +} From 27e69c8b40f3315c3144a78ca1a31f3e9db165e6 Mon Sep 17 00:00:00 2001 From: thsghdud13 Date: Fri, 27 Sep 2024 20:18:21 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat=20:=20=EB=A9=94=EC=84=B8=EC=A7=80?= =?UTF-8?q?=EB=A1=9C=20=EB=B9=84=EC=86=8D=EC=96=B4=20=EC=98=A4=EB=A9=B4=20?= =?UTF-8?q?**=EB=A1=9C=20=ED=95=84=ED=84=B0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../festime/config/BadWordFilteringConfig.java | 13 ++++++++++++- .../festime/controller/MessageController.java | 6 +++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/Be9room/festime/config/BadWordFilteringConfig.java b/src/main/java/Be9room/festime/config/BadWordFilteringConfig.java index 3fe8064..86818ed 100644 --- a/src/main/java/Be9room/festime/config/BadWordFilteringConfig.java +++ b/src/main/java/Be9room/festime/config/BadWordFilteringConfig.java @@ -1,2 +1,13 @@ -package Be9room.festime.config;public class BadWordFilteringConfig { +package Be9room.festime.config; + +import com.vane.badwordfiltering.BadWordFiltering; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class BadWordFilteringConfig { + @Bean + public BadWordFiltering badwordFiltering(){ + return new BadWordFiltering(); + } } diff --git a/src/main/java/Be9room/festime/controller/MessageController.java b/src/main/java/Be9room/festime/controller/MessageController.java index c927f35..cd1413e 100644 --- a/src/main/java/Be9room/festime/controller/MessageController.java +++ b/src/main/java/Be9room/festime/controller/MessageController.java @@ -10,6 +10,7 @@ import Be9room.festime.service.MessageService; import Be9room.festime.service.TimeLimitService; import Be9room.festime.validation.annotation.CheckPage; +import com.vane.badwordfiltering.BadWordFiltering; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Page; @@ -29,6 +30,7 @@ public class MessageController { private final SimpMessagingTemplate template; private final MessageService messageService; private final TimeLimitService timeLimitService; + private final BadWordFiltering badWordFiltering; /** * 메세지 전송 @@ -40,8 +42,10 @@ public void message(MessageChatDto message){ //중복 입력 방지 30초 if(timeLimitService.isTimeElapsed(message.getMemberId())){ + //비속어 필터 적용 + String filteredMessage = badWordFiltering.change(message.getMessage(), new String [] {"_", "@", " ", " ", "!", "#", "$", "%", "^", "&", "*", "(", ")", "-", "+","=","/", "|", "~", "`", "?", ">", "<", ",", ".", ";", ":"}); + message.setMessage(filteredMessage); messageService.save(message); - template.convertAndSend("/topic/guestbook", message); } } From 800e2facf09a50b1eda6baea3924af9c7f84a6c4 Mon Sep 17 00:00:00 2001 From: thsghdud13 Date: Fri, 27 Sep 2024 20:18:32 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat=20:=20=EB=B9=84=EB=A3=A1=EC=9D=B4?= =?UTF-8?q?=EA=B9=8C=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/Be9room/festime/common/RandomNameGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/Be9room/festime/common/RandomNameGenerator.java b/src/main/java/Be9room/festime/common/RandomNameGenerator.java index 9f56370..d1ccb3d 100644 --- a/src/main/java/Be9room/festime/common/RandomNameGenerator.java +++ b/src/main/java/Be9room/festime/common/RandomNameGenerator.java @@ -14,7 +14,7 @@ public class RandomNameGenerator { ); List objective = Arrays.asList( - "인덕이", "안뇽이" + "인덕이", "안뇽이", "비룡이" ); public String generate(){ Collections.shuffle(adjective);