private Optional<Path> resolveTemplate(Path base, MailTemplate mail) { Path templatePath = null; if (mail.locale().isPresent()) { templatePath = fileManager.resolvePermanentFilePath( base.resolve("emails")).resolve("localized") .resolve(mail.locale().get().toLanguageTag()) .resolve(mail.template() + ".twig"); if (!templatePath.toFile().isFile()) { templatePath = fileManager.resolvePermanentFilePath( base.resolve("emails")).resolve("localized") .resolve(mail.locale().get().getLanguage()) .resolve(mail.template() + ".twig"); } } if (templatePath == null || !templatePath.toFile().isFile()) { // Failed to find a localized mail, try the default one templatePath = fileManager.resolvePermanentFilePath(base.resolve("emails")) .resolve(mail.template() + ".twig"); } return templatePath.toFile().isFile() ? Optional.of(templatePath) : Optional.<Path>absent(); }
/** * @param tenant the tenant of the shop the customer checked out from * @param customerEmail the email of the customer * @param locale the locale of the customer * @return an optional notification email object, present if all information is there and valid and the template * exists, absent otherwise */ private MailTemplate getCustomerNotificationEmail(Tenant tenant, String customerEmail, Locale locale) { return new MailTemplate() .from(getTenantContactEmail(tenant)) .to(customerEmail) .template("order-paid-customer") .locale(locale); }
/** * @param tenant the tenant of the shop the customer checked out from * @param locale the main locale of the tenant * @return an optional notification email object, present if all information is there and valid and the template * exists, absent otherwise */ private MailTemplate getTenantNotificationEmail(Tenant tenant, Locale locale) { return new MailTemplate() .from(generalSettings.getNotificationsEmail()) .to(getTenantContactEmail(tenant)) .template("order-paid-tenant") .locale(locale); }