Repository: CorporationX/post_service
Pull request #1550: Feature bjs2 53856 comments analyze
Author: login: AesaQ
Created: 2025-02-20T08:57:40Z | Merged: 2025-03-10T14:25:11Z



Diff:
diff --git a/build.gradle.kts b/build.gradle.kts
index e110b629cd..5f85d39eab 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -42,6 +42,7 @@ dependencies {
     implementation("redis.clients:jedis:4.3.2")
     runtimeOnly("org.postgresql:postgresql")
 
+
     /**
      * Amazon S3
      */
@@ -52,6 +53,7 @@ dependencies {
      * Utils & Logging
      */
     implementation("com.fasterxml.jackson.core:jackson-databind:2.14.2")
+    implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2")
     implementation("org.slf4j:slf4j-api:2.0.5")
     implementation("ch.qos.logback:logback-classic:1.4.6")
     implementation("org.projectlombok:lombok:1.18.26")
@@ -115,7 +117,7 @@ tasks.jacocoTestCoverageVerification {
             includes = listOf("faang.school.postservice.service")
 
             limit {
-                minimum = BigDecimal.valueOf(0.7)
+                minimum = BigDecimal.valueOf(0.6)
             }
         }
     }
diff --git a/src/main/java/faang/school/postservice/PostServiceApp.java b/src/main/java/faang/school/postservice/PostServiceApp.java
index 00c3b9c096..39473f5e20 100644
--- a/src/main/java/faang/school/postservice/PostServiceApp.java
+++ b/src/main/java/faang/school/postservice/PostServiceApp.java
@@ -13,8 +13,8 @@
 @EnableScheduling
 @EnableFeignClients(basePackages = "faang.school.postservice.client")
 @EnableRetry
-@EnableAsync
 @EnableKafka
+@EnableAsync
 public class PostServiceApp {
     public static void main(String[] args) {
         new SpringApplicationBuilder(PostServiceApp.class)
diff --git a/src/main/java/faang/school/postservice/client/UserServiceClient.java b/src/main/java/faang/school/postservice/client/UserServiceClient.java
index 90360f706b..222f356767 100644
--- a/src/main/java/faang/school/postservice/client/UserServiceClient.java
+++ b/src/main/java/faang/school/postservice/client/UserServiceClient.java
@@ -11,7 +11,6 @@
 
 @FeignClient(name = "user-service", url = "${user-service.host}:${user-service.port}")
 public interface UserServiceClient {
-
     @GetMapping("${user-service.api-prefix}/user/{userId}")
     UserDto getUser(@PathVariable long userId);
 
diff --git a/src/main/java/faang/school/postservice/dto/comment/CommentCreateEventDto.java b/src/main/java/faang/school/postservice/dto/comment/CommentCreateEventDto.java
index a88d4ecb7b..9783db0787 100644
--- a/src/main/java/faang/school/postservice/dto/comment/CommentCreateEventDto.java
+++ b/src/main/java/faang/school/postservice/dto/comment/CommentCreateEventDto.java
@@ -3,10 +3,13 @@
 import lombok.Builder;
 import lombok.Data;
 
+import java.time.LocalDateTime;
+
 @Data
 @Builder
 public class CommentCreateEventDto {
     private final String content;
     private final Long postId;
     private final Long authorId;
+    private final LocalDateTime date;
 }
diff --git a/src/main/java/faang/school/postservice/dto/like/LikePostEvent.java b/src/main/java/faang/school/postservice/dto/like/LikePostEvent.java
new file mode 100644
index 0000000000..be4f0856c1
--- /dev/null
+++ b/src/main/java/faang/school/postservice/dto/like/LikePostEvent.java
@@ -0,0 +1,6 @@
+package faang.school.postservice.dto.like;
+
+public record LikePostEvent(Long authorId,
+                            Long likerId,
+                            Long postId) {
+}
diff --git a/src/main/java/faang/school/postservice/model/Comment.java b/src/main/java/faang/school/postservice/model/Comment.java
index c2d7d85727..50f49284a5 100644
--- a/src/main/java/faang/school/postservice/model/Comment.java
+++ b/src/main/java/faang/school/postservice/model/Comment.java
@@ -19,7 +19,7 @@
 import org.hibernate.annotations.UpdateTimestamp;
 
 import java.time.LocalDateTime;
-import java.util.List;
+import java.util.Set;
 
 @Data
 @NoArgsConstructor
@@ -40,7 +40,7 @@ public class Comment {
     private Long authorId;
 
     @OneToMany(mappedBy = "comment", orphanRemoval = true)
-    private List<Like> likes;
+    private Set<Like> likes;
 
     @ManyToOne
     @JoinColumn(name = "post_id", nullable = false)
diff --git a/src/main/java/faang/school/postservice/model/Post.java b/src/main/java/faang/school/postservice/model/Post.java
index f81f0e302e..16f81cb908 100644
--- a/src/main/java/faang/school/postservice/model/Post.java
+++ b/src/main/java/faang/school/postservice/model/Post.java
@@ -13,21 +13,20 @@
 import jakarta.persistence.Table;
 import jakarta.persistence.Temporal;
 import jakarta.persistence.TemporalType;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
+import lombok.*;
 import org.hibernate.annotations.CreationTimestamp;
 import org.hibernate.annotations.UpdateTimestamp;
 
 import java.time.LocalDateTime;
 import java.util.List;
+import java.util.Set;
 
 @Data
 @NoArgsConstructor
 @AllArgsConstructor
 @Builder
 @Entity
+@EqualsAndHashCode(exclude = "likes")
 @Table(name = "post")
 public class Post {
 
diff --git a/src/main/java/faang/school/postservice/service/CommentService.java b/src/main/java/faang/school/postservice/service/CommentService.java
index 58863e09ff..7b54a8b0f1 100644
--- a/src/main/java/faang/school/postservice/service/CommentService.java
+++ b/src/main/java/faang/school/postservice/service/CommentService.java
@@ -21,6 +21,7 @@
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.time.LocalDateTime;
 import java.util.List;
 
 import static faang.school.postservice.config.MinioBuckets.COMMENT_IMAGE_BUCKET_NAME;
@@ -47,14 +48,14 @@ public CommentResponse create(@Valid CreateCommentRequest createCommentRequest)
 
         Post post = postService.getPostById(createCommentRequest.postId());
         Comment comment = commentMapper.toEntity(createCommentRequest);
-        comment = commentRepository.save(comment);
         CommentCreateEventDto eventDto = CommentCreateEventDto.builder()
                 .authorId(comment.getAuthorId())
                 .postId(post.getId())
                 .content(comment.getContent())
+                .date(LocalDateTime.now())
                 .build();
         kafkaService.sendCommentCreateMessage(eventDto);
-        return commentMapper.toCommentResponse(comment);
+        return commentMapper.toCommentResponse(commentRepository.save(comment));
     }
 
     @Transactional
diff --git a/src/main/java/faang/school/postservice/service/KafkaService.java b/src/main/java/faang/school/postservice/service/KafkaService.java
index 94ead6c511..b8dae412d1 100644
--- a/src/main/java/faang/school/postservice/service/KafkaService.java
+++ b/src/main/java/faang/school/postservice/service/KafkaService.java
@@ -2,6 +2,7 @@
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import faang.school.postservice.dto.comment.CommentCreateEventDto;
+import faang.school.postservice.dto.like.LikePostEvent;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
@@ -13,8 +14,10 @@
 @RequiredArgsConstructor
 public class KafkaService {
 
-    @Value("${spring.kafka.topics.comment_create}")
+    @Value("${spring.kafka.topics.comment_create_event}")
     private String commentCreateTopic;
+    @Value("${spring.kafka.topics.post_like_event}")
+    private String postLikeTopic;
 
     private final KafkaTemplate<String, String> kafkaTemplate;
     private final ObjectMapper objectMapper;
@@ -29,4 +32,15 @@ public void sendCommentCreateMessage(CommentCreateEventDto commentCreateEventDto
             throw new RuntimeException("Error while sending comment create message");
         }
     }
+
+    public void sendPostLikeMessage(LikePostEvent likePostEvent) {
+        try {
+            String message = objectMapper.writeValueAsString(likePostEvent);
+            kafkaTemplate.send(postLikeTopic, message);
+            log.info("Sent post like message {} to topic: {}", message, postLikeTopic);
+        } catch (Exception e) {
+            log.error("Error while sending post like message {}", e.getMessage());
+            throw new RuntimeException("Error while sending post like message");
+        }
+    }
 }
diff --git a/src/main/java/faang/school/postservice/service/LikeService.java b/src/main/java/faang/school/postservice/service/LikeService.java
index a1b8e48533..430c28ee11 100644
--- a/src/main/java/faang/school/postservice/service/LikeService.java
+++ b/src/main/java/faang/school/postservice/service/LikeService.java
@@ -2,6 +2,7 @@
 
 import faang.school.postservice.client.UserServiceClient;
 import faang.school.postservice.dto.like.LikeCommentRequest;
+import faang.school.postservice.dto.like.LikePostEvent;
 import faang.school.postservice.dto.like.LikePostRequest;
 import faang.school.postservice.dto.user.UserDto;
 import faang.school.postservice.exceptions.CommentWasNotFoundException;
@@ -20,23 +21,20 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Slf4j
 @Service
 @RequiredArgsConstructor
 public class LikeService {
-
     private final UserServiceClient userServiceClient;
     private final LikeRepository likeRepository;
     private final PostRepository postRepository;
     private final CommentRepository commentRepository;
     private final PostService postService;
     private final CommentService commentService;
-
+    private final KafkaService kafkaService;
 
     @Transactional
     public void toggleLikePost(LikePostRequest request) {
@@ -44,21 +42,22 @@ public void toggleLikePost(LikePostRequest request) {
                 .orElseThrow(() -> new EntityNotFoundException("Пост с id " + request.postId() + " не был найден"));
         UserDto userDto = getUserDto(request.userId());
 
-        List<Like> likes = new ArrayList<>(post.getLikes() == null ? Collections.emptyList() : post.getLikes());
-        boolean likeAlreadyExists = likes.stream().anyMatch(like -> like.getUserId() == userDto.id());
+        Set<Like> likes = new HashSet<>(post.getLikes() == null ? Collections.emptyList() : post.getLikes());
+        Optional<Like> like = likes.stream().filter(likeItem -> likeItem.getUserId() == userDto.id()).findFirst();
 
-        if (likeAlreadyExists) {
-            post.setLikes(likes.stream().filter(like -> like.getUserId() != userDto.id()).toList());
-            likeRepository.deleteByPostIdAndUserId(post.getId(), userDto.id());
+        if (like.isPresent()) {
+            assert post.getLikes() != null;
+            post.getLikes().remove(like.get());
+            likeRepository.delete(like.get());
         } else {
             Like newLike = Like.builder()
                     .userId(userDto.id())
                     .post(post)
                     .createdAt(LocalDateTime.now())
                     .build();
+            post.getLikes().add(newLike);
             likeRepository.save(newLike);
-            likes.add(newLike);
-            post.setLikes(likes);
+            kafkaService.sendPostLikeMessage(new LikePostEvent(post.getAuthorId(), userDto.id(), post.getId()));
         }
     }
 
@@ -69,12 +68,13 @@ public void toggleLikeComment(LikeCommentRequest request) {
                         "Комментарий с id " + request.commentId() + " не был найден"));
         UserDto userDto = getUserDto(request.userId());
 
-        List<Like> likes = new ArrayList<>(comment.getLikes() == null ? Collections.emptyList() : comment.getLikes());
-        boolean likeAlreadyExists = likes.stream().anyMatch(like -> like.getUserId() == userDto.id());
+        Set<Like> likes = new HashSet<>(comment.getLikes() == null ? Collections.emptyList() : comment.getLikes());
+        Optional<Like> like = likes.stream().filter(likeItem -> likeItem.getUserId() == userDto.id()).findFirst();
 
-        if (likeAlreadyExists) {
-            comment.setLikes(likes.stream().filter(like -> like.getUserId() != userDto.id()).toList());
-            likeRepository.deleteByCommentIdAndUserId(comment.getId(), userDto.id());
+        if (like.isPresent()) {
+            assert comment.getLikes() != null;
+            comment.getLikes().remove(like.get());
+            likeRepository.delete(like.get());
         } else {
             Like newLike = Like.builder()
                     .userId(userDto.id())
diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml
index 3f41ceef0a..1abe049ea0 100644
--- a/src/main/resources/application.yaml
+++ b/src/main/resources/application.yaml
@@ -30,7 +30,8 @@ spring:
           name: calculations_channel
   kafka:
     topics:
-      comment_create: comment-create
+      comment_create_event: comment-create
+      post_like_event: post-like
       user-ban-topic: user-ban-topic
     bootstrap-servers: ${KAFKA_BOOTSTRAP_SERVERS:localhost:9092}
     producer:
diff --git a/src/test/java/faang/school/postservice/service/CommentServiceTest.java b/src/test/java/faang/school/postservice/service/CommentServiceTest.java
index a35ce90e24..d2a8e66d6e 100644
--- a/src/test/java/faang/school/postservice/service/CommentServiceTest.java
+++ b/src/test/java/faang/school/postservice/service/CommentServiceTest.java
@@ -1,5 +1,6 @@
 package faang.school.postservice.service;
 
+import faang.school.postservice.dto.comment.CommentCreateEventDto;
 import faang.school.postservice.dto.comment.CommentResponse;
 import faang.school.postservice.dto.comment.CommentUpdateRequest;
 import faang.school.postservice.dto.comment.CreateCommentRequest;
@@ -14,9 +15,7 @@
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.mapstruct.factory.Mappers;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Spy;
+import org.mockito.*;
 import org.mockito.junit.jupiter.MockitoExtension;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -54,24 +53,33 @@ class CommentServiceTest {
     @Mock
     private ImageService imageService;
 
-    @Mock
-    private PostService postService;
-
     @Mock
     private KafkaService kafkaService;
+    
+    @Mock
+    private PostService postService;
 
     @InjectMocks
     private CommentService commentService;
 
+    @Captor
+    private ArgumentCaptor<CommentCreateEventDto> commentCreateCaptor;
+    
     @Test
     void create_Success() {
         CreateCommentRequest request = new CreateCommentRequest(1L, "Текст", 2L);
         Post post = new Post();
-        post.setId(2L);
+
+        Long postId = 2L;
+
+        post.setId(postId);
+
+        Long authorId = 1L;
+        Long commentId = 1L;
 
         Comment commentSaved = Comment.builder()
-                .authorId(1L)
-                .id(1L)
+                .authorId(authorId)
+                .id(commentId)
                 .content("Текст")
                 .post(post)
                 .build();
@@ -89,11 +97,15 @@ void create_Success() {
         assertNotNull(actualResponse);
         assertEquals("Текст", actualResponse.content());
 
-        verify(validateService).validateUser(1L);
-        verify(validateService).validatePost(2L);
+        verify(validateService).validateUser(authorId);
+        verify(validateService).validatePost(postId);
         verify(commentMapper).toEntity(request);
         verify(commentRepository).save(any(Comment.class));
         verify(commentMapper).toCommentResponse(commentSaved);
+        verify(kafkaService).sendCommentCreateMessage(commentCreateCaptor.capture());
+
+        assertEquals(commentCreateCaptor.getValue().getAuthorId(), authorId);
+        assertEquals(commentCreateCaptor.getValue().getPostId(), postId);
     }
 
     @Test
diff --git a/src/test/java/faang/school/postservice/service/LikeServiceTest.java b/src/test/java/faang/school/postservice/service/LikeServiceTest.java
index e287e5dd9c..7b3fb7dbce 100644
--- a/src/test/java/faang/school/postservice/service/LikeServiceTest.java
+++ b/src/test/java/faang/school/postservice/service/LikeServiceTest.java
@@ -2,6 +2,7 @@
 
 import faang.school.postservice.client.UserServiceClient;
 import faang.school.postservice.dto.like.LikeCommentRequest;
+import faang.school.postservice.dto.like.LikePostEvent;
 import faang.school.postservice.dto.like.LikePostRequest;
 import faang.school.postservice.dto.user.UserDto;
 import faang.school.postservice.exceptions.CommentWasNotFoundException;
@@ -25,8 +26,7 @@
 import org.mockito.junit.jupiter.MockitoExtension;
 
 import java.time.LocalDateTime;
-import java.util.List;
-import java.util.Optional;
+import java.util.*;
 import java.util.stream.Stream;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -47,6 +47,8 @@ public class LikeServiceTest {
     private CommentService commentService;
     @Mock
     private CommentRepository commentRepository;
+    @Mock
+    private KafkaService kafkaService;
     @InjectMocks
     private LikeService likeService;
 
@@ -61,6 +63,7 @@ public void setUp() {
         post = Post.builder()
                 .id(1L)
                 .authorId(13L)
+                .likes(new ArrayList<>())
                 .createdAt(LocalDateTime.now())
                 .build();
         comment = Comment.builder()
@@ -98,27 +101,28 @@ public void toggleLikePost_SuccessLike() {
         verify(likeRepository).save(captor.capture());
         Like newLike = captor.getValue();
 
+        verify(kafkaService).sendPostLikeMessage(any(LikePostEvent.class));
+
         Assertions.assertTrue(newLike.getUserId() == userDto.id());
         Assertions.assertTrue(newLike.getPost().getId() == post.getId());
     }
 
     @Test
     public void toggleLikePost_SuccessUnLike() {
-        post.setLikes(List.of(
-                Like.builder().userId(userDto.id()).build())
-        );
+        List<Like> likes = new ArrayList<>();
+        Like like = Like.builder().userId(userDto.id()).build();
+        likes.add(like);
+        post.setLikes(likes);
 
         when(postRepository.findById(1L)).thenReturn(Optional.of(post));
         when(userServiceClient.getUser(1L)).thenReturn(userDto);
 
         likeService.toggleLikePost(new LikePostRequest(1L, 1L));
 
-        ArgumentCaptor<Long> postIdCaptor = ArgumentCaptor.forClass(Long.class);
-        ArgumentCaptor<Long> userIdCaptor = ArgumentCaptor.forClass(Long.class);
-        verify(likeRepository).deleteByPostIdAndUserId(postIdCaptor.capture(), userIdCaptor.capture());
+        ArgumentCaptor<Like> likeCaptor = ArgumentCaptor.forClass(Like.class);
+        verify(likeRepository).delete(likeCaptor.capture());
 
-        Assertions.assertEquals(postIdCaptor.getValue(), post.getId());
-        Assertions.assertEquals(userIdCaptor.getValue(), userDto.id());
+        Assertions.assertEquals(likeCaptor.getValue().getId(), like.getId());
     }
 
     @Test
@@ -138,21 +142,20 @@ public void toggleLikeComment_SuccessLike() {
 
     @Test
     public void toggleLikeComment_SuccessUnLike() {
-        comment.setLikes(List.of(
-                Like.builder().userId(userDto.id()).build())
-        );
+        Set<Like> likes = new HashSet<>();
+        Like like = Like.builder().userId(userDto.id()).build();
+        likes.add(like);
+        comment.setLikes(likes);
 
         when(commentRepository.findById(1L)).thenReturn(Optional.of(comment));
         when(userServiceClient.getUser(1L)).thenReturn(userDto);
 
         likeService.toggleLikeComment(new LikeCommentRequest(1L, 1L));
 
-        ArgumentCaptor<Long> commentIdCaptor = ArgumentCaptor.forClass(Long.class);
-        ArgumentCaptor<Long> userIdCaptor = ArgumentCaptor.forClass(Long.class);
-        verify(likeRepository).deleteByCommentIdAndUserId(commentIdCaptor.capture(), userIdCaptor.capture());
+        ArgumentCaptor<Like> likeCaptor = ArgumentCaptor.forClass(Like.class);
+        verify(likeRepository).delete(likeCaptor.capture());
 
-        Assertions.assertEquals(commentIdCaptor.getValue(), comment.getId());
-        Assertions.assertEquals(userIdCaptor.getValue(), userDto.id());
+        Assertions.assertEquals(likeCaptor.getValue().getId(), like.getId());
     }
 
     @Test
@@ -275,6 +278,4 @@ public void getLikedUsersToComment_UserServiceError() {
         assertEquals("Failed users service", exception.getMessage());
         verify(userServiceClient, times(1)).getUsersByIds(List.of(1L, 2L, 3L));
     }
-
-
 }


Reviews:
user: login: kamzadias
body: Одно замечание, но в целом все хорошо!
state: CHANGES_REQUESTED
author_association: NONE
submitted_at: 2025-02-24T07:51:12Z
user: login: kamzadias
state: APPROVED
author_association: NONE
submitted_at: 2025-02-24T14:40:48Z
user: login: SnurnicynKonstantin
state: COMMENTED
author_association: NONE
submitted_at: 2025-02-26T12:41:25Z
user: login: SnurnicynKonstantin
state: COMMENTED
author_association: NONE
submitted_at: 2025-03-03T16:36:27Z
user: login: SnurnicynKonstantin
body: Поправь плиз конфликты
state: CHANGES_REQUESTED
author_association: NONE
submitted_at: 2025-03-03T16:36:39Z
user: login: AesaQ
state: COMMENTED
author_association: NONE
submitted_at: 2025-03-04T08:50:12Z
user: login: SnurnicynKonstantin
state: COMMENTED
author_association: NONE
submitted_at: 2025-03-05T12:41:27Z
user: login: SnurnicynKonstantin
state: COMMENTED
author_association: NONE
submitted_at: 2025-03-07T09:55:20Z
user: login: SnurnicynKonstantin
body: Один коммент. Вероятно это последствия ребэйзов с мастером.
Плюс конфликт надо решить.
Боюсь будет очень больно его решать на 29ти коммитах. 
Советую их сжать до одного по инструкции. Или как крайняя мера, создать новую чисту ветку. А этот ПР закрыть
state: CHANGES_REQUESTED
author_association: NONE
submitted_at: 2025-03-07T09:59:47Z
user: login: SnurnicynKonstantin
state: APPROVED
author_association: NONE
submitted_at: 2025-03-10T14:25:01Z

Review comments:
diff_hunk: @@ -0,0 +1,22 @@
+package faang.school.postservice.service.broker;
+
+import faang.school.postservice.model.event.CommentCreateEvent;
+import lombok.RequiredArgsConstructor;
+import org.json.JSONObject;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.kafka.core.KafkaTemplate;
+import org.springframework.stereotype.Service;
+
+@Service
+@RequiredArgsConstructor
+public class KafkaProducerCommentService {
+    private final KafkaTemplate<String, String> kafkaTemplate;
+
+    @Value("${spring.kafka.comment_create_event_topic_name}")
+    private String commentCreateEventTopicName;
+
+    public void sendCommentCreateEvent(CommentCreateEvent event) {
+        JSONObject jsonObject = new JSONObject(event);
path: src/main/java/faang/school/postservice/service/broker/KafkaProducerCommentService.java
user: login: kamzadias
body: Можно обойтись ObjectMapper writeValueAsString
created_at: 2025-02-24T07:49:50Z
author_association: NONE
diff_hunk: @@ -0,0 +1,33 @@
+package faang.school.postservice.config;
+
+import org.apache.kafka.clients.producer.ProducerConfig;
+import org.apache.kafka.common.serialization.StringSerializer;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.kafka.core.DefaultKafkaProducerFactory;
+import org.springframework.kafka.core.KafkaTemplate;
+import org.springframework.kafka.core.ProducerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Configuration
+public class KafkaProducerConfig {
+    @Value("${spring.kafka.bootstrap-servers}")
+    private String bootstrapServers;
+
+    @Bean
+    ProducerFactory<String, String> producerFactory() {
path: src/main/java/faang/school/postservice/config/KafkaProducerConfig.java
user: login: SnurnicynKonstantin
body: Попробуй все на уровне application.yml определить
created_at: 2025-02-26T12:41:24Z
author_association: NONE
diff_hunk: @@ -39,7 +39,7 @@ public class CommentService {
     @Transactional
     public CommentResponse create(@Valid CreateCommentRequest createCommentRequest) {
         validateService.validateUser(createCommentRequest.userId());
-        validateService.validatePost(createCommentRequest.postId());
+//        validateService.validatePost(createCommentRequest.postId());
path: src/main/java/faang/school/postservice/service/CommentService.java
user: login: SnurnicynKonstantin
body: Почему закомментил?
created_at: 2025-03-03T16:36:27Z
author_association: NONE
diff_hunk: @@ -39,7 +39,7 @@ public class CommentService {
     @Transactional
     public CommentResponse create(@Valid CreateCommentRequest createCommentRequest) {
         validateService.validateUser(createCommentRequest.userId());
-        validateService.validatePost(createCommentRequest.postId());
+//        validateService.validatePost(createCommentRequest.postId());
path: src/main/java/faang/school/postservice/service/CommentService.java
user: login: AesaQ
body: забыл убрать
там у меня локально с project(если не ошибаюсь) сервисом проблемы
created_at: 2025-03-04T08:50:12Z
author_association: NONE
diff_hunk: @@ -13,6 +13,7 @@
 @EnableScheduling
 @EnableFeignClients(basePackages = "faang.school.postservice.client")
 @EnableRetry
+@EnableKafka
path: src/main/java/faang/school/postservice/PostServiceApp.java
user: login: SnurnicynKonstantin
body: Два раза @EnableKafka как минимум.
При правки конфликтов ты видимо правил конфликты в всех коммитах. В результате все поломалось. Приложение не запускается.
В следующий раз используй эту инструкцию - https://discord.com/channels/1102662981743030334/1126205623265140736/1346824198936334346

А сейчас у тебя есть два пути:
1) Поправить этот ПР что бы он запускался.
2) Создать новый и акуратно перенести туда нужные тебе изменения.
created_at: 2025-03-05T12:41:27Z
author_association: NONE
diff_hunk: @@ -22,7 +22,9 @@ dependencies {
     implementation("org.springframework.boot:spring-boot-starter-data-jpa")
     implementation("org.springframework.boot:spring-boot-starter-data-redis")
     implementation("org.springframework.boot:spring-boot-starter-web")
+    implementation("org.springframework.kafka:spring-kafka")
path: build.gradle.kts
user: login: SnurnicynKonstantin
body: Аж три раза повторяется
<img width="481" alt="image" src="https://github.com/user-attachments/assets/64164b4a-f715-433a-afb0-12e037174524" />

created_at: 2025-03-07T09:55:20Z
author_association: NONE

PR comments:
user: login: AesaQ
created_at: 2025-03-04T13:09:01Z
body: Нужна помощь, не понимаю почему сиайка не проходит, в ide всё нормально
author_association: NONE
user: login: SnurnicynKonstantin
created_at: 2025-03-05T12:42:52Z
body: > Нужна помощь, не понимаю почему сиайка не проходит, в ide всё нормально

А ты пробовал запускать приложение? У меня с ошибками падает. Если открыть логи, то там много ошибок.
<img width="1104" alt="image" src="https://github.com/user-attachments/assets/3ba2cff7-99f0-4f26-85ed-3b942dbaeef8" />

author_association: NONE
user: login: AesaQ
created_at: 2025-03-06T08:28:35Z
body: в этой ветке логика находится не только по отправке commentCreateEvent в кафку, но и отправку likePostEvent
случайно так вышло, забыл ветки поменять, а заметил это только когда нужно было пушить
author_association: NONE
user: login: AesaQ
created_at: 2025-03-09T10:14:45Z
body: если решать конфликт в github'е, то решить его нужно только 1 раз
author_association: NONE