From eebf9c1543c79fe9f47b45bf705a87cf2926214f Mon Sep 17 00:00:00 2001 From: Vladik-gif Date: Fri, 20 Sep 2024 12:59:40 +0300 Subject: [PATCH] updated: Added Transactional for methods --- src/main/java/com/chat/yourway/service/ContactService.java | 3 +++ src/main/java/com/chat/yourway/service/TopicService.java | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/chat/yourway/service/ContactService.java b/src/main/java/com/chat/yourway/service/ContactService.java index 67de683..ec9fff8 100644 --- a/src/main/java/com/chat/yourway/service/ContactService.java +++ b/src/main/java/com/chat/yourway/service/ContactService.java @@ -153,6 +153,7 @@ private void changePermissionSendingPrivateMessages(String email, boolean isPerm email, isPermittedSendingPrivateMessage); } + @Transactional public void addUnreadMessageToTopicSubscribers(Contact excludeСontact, Message message) { List topicSubscribers = message.getTopic().getTopicSubscribers() .stream() @@ -164,11 +165,13 @@ public void addUnreadMessageToTopicSubscribers(Contact excludeСontact, Message } } + @Transactional public void deleteUnreadMessage(Contact contact, Message message) { contact.getUnreadMessages().remove(message); save(contact); } + @Transactional public Contact getCurrentContact() { try { Contact principal = (Contact) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); diff --git a/src/main/java/com/chat/yourway/service/TopicService.java b/src/main/java/com/chat/yourway/service/TopicService.java index 344f95b..ee37ae5 100644 --- a/src/main/java/com/chat/yourway/service/TopicService.java +++ b/src/main/java/com/chat/yourway/service/TopicService.java @@ -272,8 +272,7 @@ private void validateRecipientEmail(String sendTo) { if (!contactService.isEmailExists(sendTo)) { log.error("Private topic cannot be created, recipient email={} does not exist", sendTo); throw new ContactEmailNotExist(String.format( - "Private topic cannot be created because recipient email: %s does not exist", - sendTo)); + "Private topic cannot be created because recipient email: %s does not exist", sendTo)); } } }