Skip to content

Commit

Permalink
Fix for comment from Vitaliy
Browse files Browse the repository at this point in the history
  • Loading branch information
VasylyshynDmytro committed Dec 12, 2024
1 parent 9fa9da6 commit 0376baa
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/src/main/resources/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ profile.text=If you no longer wish to receive these emails, you can unsubscribe
profile=profile
advice.general.ubs=You are receiving this email because you are a registered member of Pick Up City.
read.more=READ MORE
your.place.status.changed=The status of your place has been updated. You are receiving this email because the status of your place was changed. Thank you for using our service!
your.place.status.changed=The status of your place has been updated. You are receiving this email because the status of your place was changed. Thank you for using our service!
2 changes: 1 addition & 1 deletion core/src/main/resources/messages_uk.properties
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ profile.text=\u042f\u043a\u0449\u043e\u0020\u0432\u0438\u0020\u0431\u0456\u043b\
profile=\u043f\u0440\u043e\u0444\u0456\u043b\u0456
advice.general.ubs=\u0412\u0438\u0020\u043e\u0442\u0440\u0438\u043c\u0430\u043b\u0438\u0020\u0446\u0435\u0439\u0020\u0435\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u0438\u0439\u0020\u043b\u0438\u0441\u0442\u002c\u0020\u0442\u043e\u043c\u0443\u0020\u0449\u043e\u0020\u0454\u0020\u0437\u0430\u0440\u0435\u0454\u0441\u0442\u0440\u043e\u0432\u0430\u043d\u0438\u043c\u0020\u043a\u043b\u0456\u0454\u043d\u0442\u043e\u043c\u0020\u0050\u0069\u0063\u006b\u0020\u0055\u0070\u0020\u0043\u0069\u0074\u0079\u002e
read.more=\u0427\u0418\u0422\u0410\u0422\u0418 \u0414\u0410\u041b\u0406
your.place.status.changed=\u0421\u0442\u0430\u0442\u0443\u0441\u0020\u0432\u0430\u0448\u043E\u0433\u043E\u0020\u043C\u0456\u0441\u0446\u044F\u0020\u0431\u0443\u0432\u0020\u043E\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u0439\u002E\u0020\u0412\u0438\u0020\u043E\u0442\u0440\u0438\u043C\u0430\u043B\u0438\u0020\u0446\u0435\u0439\u0020\u043B\u0438\u0441\u0442\u002C\u0020\u0442\u043E\u043C\u0443\u0020\u0449\u043E\u0020\u0441\u0442\u0430\u0442\u0443\u0441\u0020\u0432\u0430\u0448\u043E\u0433\u043E\u0020\u043C\u0456\u0441\u0446\u044F\u0020\u0431\u0443\u043B\u043E\u0020\u0437\u043C\u0456\u043D\u0435\u043D\u043E\u002E\u0020\u0414\u044F\u043A\u0443\u0454\u043C\u043E\u002C\u0020\u0449\u043E\u0020\u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0454\u0442\u0435\u0441\u044C\u0020\u043D\u0430\u0448\u0438\u043C\u0020\u0441\u0435\u0440\u0432\u0456\u0441\u043E\u043C\u0021
your.place.status.changed=\u0421\u0442\u0430\u0442\u0443\u0441\u0020\u0432\u0430\u0448\u043E\u0433\u043E\u0020\u043C\u0456\u0441\u0446\u044F\u0020\u0431\u0443\u0432\u0020\u043E\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u0439\u002E\u0020\u0412\u0438\u0020\u043E\u0442\u0440\u0438\u043C\u0430\u043B\u0438\u0020\u0446\u0435\u0439\u0020\u043B\u0438\u0441\u0442\u002C\u0020\u0442\u043E\u043C\u0443\u0020\u0449\u043E\u0020\u0441\u0442\u0430\u0442\u0443\u0441\u0020\u0432\u0430\u0448\u043E\u0433\u043E\u0020\u043C\u0456\u0441\u0446\u044F\u0020\u0431\u0443\u043B\u043E\u0020\u0437\u043C\u0456\u043D\u0435\u043D\u043E\u002E\u0020\u0414\u044F\u043A\u0443\u0454\u043C\u043E\u002C\u0020\u0449\u043E\u0020\u043A\u043E\u0440\u0438\u0441\u0442\u0443\u0454\u0442\u0435\u0441\u044C\u0020\u043D\u0430\u0448\u0438\u043C\u0020\u0441\u0435\u0440\u0432\u0456\u0441\u043E\u043C\u0021
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public class PlaceStatusChangeDto {
private String userName;

@NotNull
private String userEmail;
private String email;
}
23 changes: 17 additions & 6 deletions service/src/main/java/greencity/service/EmailServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@
import greencity.dto.user.UserActivationDto;
import greencity.dto.user.UserDeactivationReasonDto;
import greencity.dto.violation.UserViolationMailDto;
import greencity.entity.User;
import greencity.exception.exceptions.NotFoundException;
import greencity.message.PlaceStatusChangeDto;
import greencity.message.ScheduledEmailMessage;
import greencity.message.SendReportEmailMessage;
import greencity.repository.LanguageRepo;
import greencity.repository.UserRepo;
import greencity.validator.EmailAddressValidator;
import jakarta.mail.MessagingException;
import jakarta.mail.internet.MimeMessage;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.Executor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -43,22 +48,26 @@ public class EmailServiceImpl implements EmailService {
private final String senderEmailAddress;
private final MessageSource messageSource;
private static final String PARAM_USER_ID = "&user_id=";
private final UserRepo userRepo;
private final LanguageRepo languageRepo;

/**
* Constructor.
*/
@Autowired
public EmailServiceImpl(JavaMailSender javaMailSender,
ITemplateEngine templateEngine,
@Qualifier("sendEmailExecutor") Executor executor,
@Value("${client.address}") String clientLink,
@Value("${sender.email.address}") String senderEmailAddress, MessageSource messageSource) {
ITemplateEngine templateEngine,
@Qualifier("sendEmailExecutor") Executor executor,
@Value("${client.address}") String clientLink,
@Value("${sender.email.address}") String senderEmailAddress, MessageSource messageSource, UserRepo userRepo, LanguageRepo languageRepo) {
this.javaMailSender = javaMailSender;
this.templateEngine = templateEngine;
this.executor = executor;
this.clientLink = clientLink;
this.senderEmailAddress = senderEmailAddress;
this.messageSource = messageSource;
this.userRepo = userRepo;
this.languageRepo = languageRepo;
}

/**
Expand Down Expand Up @@ -321,14 +330,16 @@ private Map<String, Object> buildModelMapForPasswordRestore(Long userId, String
@Override
public void sendPlaceStatusChangeNotification(PlaceStatusChangeDto dto) {
Map<String, Object> model = new HashMap<>();
User user = userRepo.findByEmail(dto.getEmail())
.orElseThrow(() -> new NotFoundException("user with email " + dto.getEmail() + " does not exist."));
model.put(EmailConstants.CLIENT_LINK, clientLink);
model.put(EmailConstants.USER_NAME, dto.getUserName());
model.put(EmailConstants.PLACE_NAME, dto.getPlaceName());
model.put(EmailConstants.PLACE_STATUS, dto.getNewStatus().name());
model.put(EmailConstants.LANGUAGE, "en");
model.put(EmailConstants.LANGUAGE, user.getLanguage().getCode());

String template = createEmailTemplate(model, EmailConstants.PLACE_STATUS_CHANGE_PAGE);
sendEmail(dto.getUserEmail(), "Status of your place has been updated", template);
sendEmail(dto.getEmail(), "Status of your place has been updated", template);
}

private String getClientLinkByIsUbs(boolean isUbs) {
Expand Down

0 comments on commit 0376baa

Please sign in to comment.