Skip to content

Commit

Permalink
fix: ContactService.java 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladik-gif committed Sep 20, 2024
1 parent 6681e69 commit 41615b2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/main/java/com/chat/yourway/service/ContactService.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public Contact create(ContactRequestDto contactRequestDto) {
if (isEmailExists(contactRequestDto.getEmail())) {
log.warn("Email [{}] already in use", contactRequestDto.getEmail());
throw new ValueNotUniqException(
String.format("Email [%s] already in use", contactRequestDto.getEmail()));
String.format("Email [%s] already in use", contactRequestDto.getEmail())
);
}

Contact contact = (Contact.builder()
Expand Down Expand Up @@ -68,7 +69,8 @@ public Contact findByEmail(String email) {
.orElseThrow(() -> {
log.warn("Email [{}] wasn't found", email);
return new ContactNotFoundException(String.format("Email [%s] wasn't found", email));
});
}
);

log.info("Contact was found by email [{}]", email);
return contact;
Expand Down Expand Up @@ -144,14 +146,14 @@ public void prohibitSendingPrivateMessages() {
log.info("Prohibited sending private messages by email [{}]", contact.getEmail());
}

private void changePermissionSendingPrivateMessages(String email, boolean isPermittedSendingPrivateMessage) {
private void changePermissionSendingPrivateMessages(String email, boolean messageByContactEmail) {
if (!contactRepository.existsByEmailIgnoreCase(email)) {
throw new ContactNotFoundException(
String.format("Contact with email [%s] is not found.", email));
String.format("Contact with email [%s] is not found.", email)
);
}

contactRepository.updatePermissionSendingPrivateMessageByContactEmail(
email, isPermittedSendingPrivateMessage);
contactRepository.updatePermissionSendingPrivateMessageByContactEmail(email, messageByContactEmail);
}

@Transactional
Expand Down

0 comments on commit 41615b2

Please sign in to comment.