diff --git a/pom.xml b/pom.xml index 1ccb4269..5c79fbb4 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.9.RELEASE + 2.5.3 com.alovoa diff --git a/src/main/java/com/nonononoki/alovoa/config/WebMvcConfig.java b/src/main/java/com/nonononoki/alovoa/config/WebMvcConfig.java index d9188d12..2f84875b 100644 --- a/src/main/java/com/nonononoki/alovoa/config/WebMvcConfig.java +++ b/src/main/java/com/nonononoki/alovoa/config/WebMvcConfig.java @@ -1,52 +1,46 @@ package com.nonononoki.alovoa.config; import java.nio.charset.StandardCharsets; -import java.util.Locale; -import org.springframework.context.MessageSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.support.ReloadableResourceBundleMessageSource; -import org.springframework.web.servlet.LocaleResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.i18n.CookieLocaleResolver; import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; - + @Configuration @EnableWebMvc @ComponentScan public class WebMvcConfig implements WebMvcConfigurer { - + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/**").addResourceLocations("classpath:/static/"); + } + @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - registry - .addResourceHandler("/**") - .addResourceLocations("classpath:/static/"); - } - - @Bean(name = "localeResolver") - public LocaleResolver getLocaleResolver() { - CookieLocaleResolver clr = new CookieLocaleResolver(); - clr.setDefaultLocale(Locale.ENGLISH); - return clr; - } - - @Bean(name = "messageSource") - public MessageSource getMessageResource() { - ReloadableResourceBundleMessageSource messageResource= new ReloadableResourceBundleMessageSource(); - messageResource.setBasename("classpath:i18n/messages"); - messageResource.setDefaultEncoding(StandardCharsets.UTF_8.name()); - return messageResource; - } - @Override - public void addInterceptors(InterceptorRegistry registry) { - LocaleChangeInterceptor localeInterceptor = new LocaleChangeInterceptor(); - localeInterceptor.setParamName("lang"); - registry.addInterceptor(localeInterceptor).addPathPatterns("/*"); - } - + public void addInterceptors(InterceptorRegistry registry) { + LocaleChangeInterceptor localeInterceptor = new LocaleChangeInterceptor(); + localeInterceptor.setParamName("lang"); + registry.addInterceptor(localeInterceptor).addPathPatterns("/*"); + } + + @Bean + public CookieLocaleResolver localeResolver() { + return new CookieLocaleResolver(); + } + + @Bean + public ReloadableResourceBundleMessageSource messageSource() { + ReloadableResourceBundleMessageSource messageResource = new ReloadableResourceBundleMessageSource(); + messageResource.setBasename("classpath:i18n/messages"); + messageResource.setDefaultEncoding(StandardCharsets.UTF_8.name()); + return messageResource; + } + } \ No newline at end of file diff --git a/src/main/java/com/nonononoki/alovoa/service/UserService.java b/src/main/java/com/nonononoki/alovoa/service/UserService.java index 086f4e5e..27e6d88d 100644 --- a/src/main/java/com/nonononoki/alovoa/service/UserService.java +++ b/src/main/java/com/nonononoki/alovoa/service/UserService.java @@ -547,9 +547,8 @@ public void addImage(String imgB64) throws AlovoaException, IOException { public void deleteImage(long id) throws AlovoaException { User user = authService.getCurrentUser(); - UserImage img = userImageRepo.getOne(id); - - if (user.getImages().contains(img)) { + UserImage img = userImageRepo.findById(id).orElse(null); + if (img != null && user.getImages().contains(img)) { user.getImages().remove(img); userRepo.saveAndFlush(user); } @@ -667,9 +666,9 @@ public void likeUser(String idEnc) throws AlovoaException, GeneralSecurityExcept notificationService.newLike(user); user.getDates().setNotificationDate(new Date()); - + currUser.getHiddenUsers().removeIf(hide -> hide.getUserTo().getId().equals(user.getId())); - + userRepo.saveAndFlush(user); userRepo.saveAndFlush(currUser); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 83c41354..8eac8681 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -9,9 +9,11 @@ server.port=${PORT:8443} #server.ssl.key-store-password=alovoa #server.ssl.key-alias=alovoa +spring.main.allow-bean-definition-overriding=true + server.http2.enabled=true -spring.datasource.platform=mysql +spring.sql.init.platform=mysql spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/alovoa?createDatabaseIfNotExist=true&serverTimezone=UTC&useLegacyDatetimeCode=false @@ -23,7 +25,7 @@ spring.datasource.url=jdbc:mysql://localhost:3306/alovoa?createDatabaseIfNotExis #we keep the default /login/oauth2/code/{registrationId} scheme -spring.mvc.locale=en_EN +spring.web.locale=en_EN spring.security.oauth2.client.registration.google.scope[0]=email spring.security.oauth2.client.registration.google.scope[1]=profile