diff --git a/src/main/java/com/nonononoki/alovoa/repo/UserRepository.java b/src/main/java/com/nonononoki/alovoa/repo/UserRepository.java index b37ca24b..6cf1f8db 100644 --- a/src/main/java/com/nonononoki/alovoa/repo/UserRepository.java +++ b/src/main/java/com/nonononoki/alovoa/repo/UserRepository.java @@ -29,6 +29,8 @@ default List usersSearch(UserSearchRequest request, Pageable page) { request.getLikeIds(), request.getHideIds(), request.getBlockIds(), request.getGenderIds(), page); } + List findByConfirmedIsFalse(); + @Query(value = "SELECT u FROM User u WHERE u.disabled = FALSE AND u.admin = FALSE AND u.confirmed = TRUE AND u.intention IS NOT NULL AND " + "u.locationLatitude IS NOT NULL AND u.locationLongitude IS NOT NULL AND u.profilePicture IS NOT NULL " + "AND TIMESTAMPDIFF(YEAR, u.dates.dateOfBirth, CURDATE()) + u.preferedMaxAge >= :age AND TIMESTAMPDIFF(YEAR, u.dates.dateOfBirth, CURDATE()) + u.preferedMinAge <= :age AND u.dates.dateOfBirth >= :minDate AND u.dates.dateOfBirth <= :maxDate " diff --git a/src/main/java/com/nonononoki/alovoa/service/ScheduleService.java b/src/main/java/com/nonononoki/alovoa/service/ScheduleService.java index 05713529..081eb8fb 100644 --- a/src/main/java/com/nonononoki/alovoa/service/ScheduleService.java +++ b/src/main/java/com/nonononoki/alovoa/service/ScheduleService.java @@ -47,6 +47,9 @@ public class ScheduleService { @Value("${app.schedule.delay.contact}") private long contactDelay; + @Value("${app.schedule.delay.user.cleanup:}") + private long nonConfirmedUsersCleanupDelay; + private static final int HIDE_MAX = 20; @Scheduled(fixedDelayString = "${app.schedule.short}") @@ -63,9 +66,23 @@ public void scheduleLong() { if (enableSchedules) { Date date = new Date(); cleanContact(date); + cleanNonConfirmedUsers(date); } } + private void cleanNonConfirmedUsers(final Date date) { + long ms = date.getTime(); + ms -= nonConfirmedUsersCleanupDelay; + Date d = new Date(ms); + + List users = userRepo.findByConfirmedIsFalse().stream() + .filter(user -> (user.getDates() != null && user.getDates().getCreationDate().before(d))) + .toList(); + + userRepo.deleteAll(users); + userRepo.flush(); + } + public void cleanCaptcha(Date date) { long ms = date.getTime(); ms -= captchaDelay; diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 443e524c..e0ddeb6e 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -21,6 +21,10 @@ spring.datasource.url=jdbc:mariadb://localhost:3306/alovoa?createDatabaseIfNotEx #spring.datasource.hikari.maxLifetime=1800000 #Insert your oauth2 ids and secrets here +spring.security.oauth2.client.registration.google.client-id=test +spring.security.oauth2.client.registration.google.client-secret=test +spring.security.oauth2.client.registration.facebook.client-id=test +spring.security.oauth2.client.registration.facebook.client-secret=test #spring.security.oauth2.client.registration.google.client-id= #spring.security.oauth2.client.registration.google.client-secret= #spring.security.oauth2.client.registration.facebook.client-id= @@ -60,17 +64,18 @@ spring.jpa.properties.hibernate.plan_parameter_metadata_max_size=16 spring.jpa.properties.hibernate.query.in_clause_parameter_padding=true ### KEYS AND CREDENTIALS ### -#spring.datasource.password= -#spring.datasource.username= +spring.datasource.password=mypass +spring.datasource.username=root #keys for transparent database encryption -#app.text.key= #key must be 16, 24 or 32 bytes long -#app.text.salt= #salt must be 16 bytes long -#app.admin.email= +app.text.key=bqupWgmhCj3fedLxYdNAy2QFA2bS9XJX +app.text.salt=sFRKQAhwdrZq44FQ#app.admin.email= +app.admin.email=admin@alovoa.com +app.admin.key=password #app.admin.key= -#spring.mail.password= -spring.mail.host=mail.gmx.net +spring.mail.password=5550f635c82e7e +spring.mail.host=sandbox.smtp.mailtrap.io spring.mail.port=587 -spring.mail.username=nonononoki@gmx.de +spring.mail.username=e81ae4ff934777 spring.mail.properties.mail.smtp.auth=true spring.mail.properties.mail.smtp.starttls.enable=true spring.mail.test-connection=true @@ -78,7 +83,7 @@ spring.mail.properties.mail.smtp.ssl.checkserveridentity=false # logging logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n -logging.level.org.springframework.web=INFO +logging.level.org.springframework.web=DEBUG logging.level.org.hibernate.SQL=ERROR logging.level.org.hibernate=ERROR logging.file.name=./logs/spring.log @@ -304,3 +309,5 @@ app.schedule.delay.captcha=300000 app.schedule.delay.hide=9720000000 #90 days app.schedule.delay.contact=9720000000 +#14 days +app.schedule.delay.user.cleanup=1209600000