From 03b3842a56e032e4617461ab9488d6cec3006808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A3=BC=EC=98=81?= <103026521+jyk1029@users.noreply.github.com> Date: Fri, 2 Jun 2023 22:06:12 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=80=20::=20(#35)=20=EC=9E=90=EC=8B=A0?= =?UTF-8?q?=EC=9D=98=20=EA=B2=8C=EC=8B=9C=EB=AC=BC=EC=97=90=20=EC=95=8C?= =?UTF-8?q?=EB=9E=8C=20=EA=B0=80=EB=8A=94=20=EB=B2=84=EA=B7=B8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20(#103)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * πŸ› :: μžμ‹ μ˜ κ²Œμ‹œλ¬Όμ— μ•ŒλžŒ κ°€λŠ” 버그 μˆ˜μ • * ♻️ :: μ½”λ“œ μ •λ ¬ --- .../comment/api/impl/CommentApiImpl.java | 32 ++++++++++++------- .../feedlike/api/impl/FeedLikeApiImpl.java | 31 +++++++++++------- 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/feed-domain/src/main/java/com/xquare/v1servicefeed/comment/api/impl/CommentApiImpl.java b/feed-domain/src/main/java/com/xquare/v1servicefeed/comment/api/impl/CommentApiImpl.java index 1c15f109..fef2b12a 100644 --- a/feed-domain/src/main/java/com/xquare/v1servicefeed/comment/api/impl/CommentApiImpl.java +++ b/feed-domain/src/main/java/com/xquare/v1servicefeed/comment/api/impl/CommentApiImpl.java @@ -43,31 +43,39 @@ public class CommentApiImpl implements CommentApi { @Override public void saveComment(CreateCommentDomainRequest request) { Feed feed = queryFeedSpi.queryFeedById(request.getFeedId()); + UUID userId = securitySpi.getCurrentUserId(); commandCommentSpi.saveComment( Comment.builder() .content(request.getContent()) .feedId(feed.getId()) - .userId(securitySpi.getCurrentUserId()) + .userId(userId) .createAt(LocalDateTime.now()) .updatedAt(LocalDateTime.now()) .build() ); - if (feed.getType().equals(CategoryEnum.NOTICE.getName())) { - sendNotification(FEED_NOTICE_COMMENT, feed); - } else { - sendNotification(FEED_BAMBOO_COMMENT, feed); + if(feed.getUserId().equals(userId)) { + sendNotification(feed); } } - private void sendNotification(String topic, Feed feed) { - notificationSpi.sendNotification( - feed.getUserId(), - topic, - CONTENT, - feed.getId().toString() - ); + private void sendNotification(Feed feed) { + if (feed.getType().equals(CategoryEnum.NOTICE.getName())) { + notificationSpi.sendNotification( + feed.getUserId(), + FEED_NOTICE_COMMENT, + CONTENT, + feed.getId().toString() + ); + } else { + notificationSpi.sendNotification( + feed.getUserId(), + FEED_BAMBOO_COMMENT, + CONTENT, + feed.getId().toString() + ); + } } @Override diff --git a/feed-domain/src/main/java/com/xquare/v1servicefeed/feedlike/api/impl/FeedLikeApiImpl.java b/feed-domain/src/main/java/com/xquare/v1servicefeed/feedlike/api/impl/FeedLikeApiImpl.java index 47a2cade..4cee5c73 100644 --- a/feed-domain/src/main/java/com/xquare/v1servicefeed/feedlike/api/impl/FeedLikeApiImpl.java +++ b/feed-domain/src/main/java/com/xquare/v1servicefeed/feedlike/api/impl/FeedLikeApiImpl.java @@ -40,24 +40,31 @@ public void saveFeedLike(UUID feedId) { commandFeedLikeSpi.saveFeedLike( FeedLike.builder() .feedId(feed.getId()) - .userId(securitySpi.getCurrentUserId()) + .userId(userId) .build() ); - if (feed.getType().equals(CategoryEnum.NOTICE.getName())) { - sendNotification(FEED_NOTICE_LIKE, feed); - } else { - sendNotification(FEED_BAMBOO_LIKE, feed); + if (!feed.getUserId().equals(userId)) { + sendNotification(feed); } } - private void sendNotification(String topic, Feed feed) { - notificationSpi.sendNotification( - feed.getUserId(), - topic, - CONTENT, - feed.getId().toString() - ); + private void sendNotification(Feed feed) { + if (feed.getType().equals(CategoryEnum.NOTICE.getName())) { + notificationSpi.sendNotification( + feed.getUserId(), + FEED_NOTICE_LIKE, + CONTENT, + feed.getId().toString() + ); + } else { + notificationSpi.sendNotification( + feed.getUserId(), + FEED_BAMBOO_LIKE, + CONTENT, + feed.getId().toString() + ); + } } @Override