Skip to content

Commit

Permalink
updated: Added Transactional for methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladik-gif committed Sep 20, 2024
1 parent 4fe3563 commit eebf9c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/main/java/com/chat/yourway/service/ContactService.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ private void changePermissionSendingPrivateMessages(String email, boolean isPerm
email, isPermittedSendingPrivateMessage);
}

@Transactional
public void addUnreadMessageToTopicSubscribers(Contact excludeСontact, Message message) {
List<Contact> topicSubscribers = message.getTopic().getTopicSubscribers()
.stream()
Expand All @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/chat/yourway/service/TopicService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}

0 comments on commit eebf9c1

Please sign in to comment.